ComponentesComponents

Campo de textoText field

Campo y área de texto con etiqueta, ayuda y error.Input and textarea with label, hint and error.

DiseñoDesign: coss ui (MIT) · input.tsx, textarea.tsx, field.tsxMITambos · densidaddensity media · sobriaMarkdownJSON

CódigoCode

<form class="c-form" novalidate data-c-validate data-c-demo>
  <div class="c-field">
    <label class="c-label" for="tf-name">Nombre</label>
    <span class="c-input"><input class="c-input__field" id="tf-name" name="name" type="text" autocomplete="name" placeholder="Ada Lovelace" required aria-describedby="tf-name-err" data-c-msg="Escribe tu nombre."></span>
    <p class="c-field__error" id="tf-name-err"></p>
  </div>
  <div class="c-field">
    <label class="c-label" for="tf-email">Correo</label>
    <span class="c-input"><input class="c-input__field" id="tf-email" name="email" type="email" autocomplete="email" placeholder="tu@correo.com" required spellcheck="false" aria-describedby="tf-email-help tf-email-err" data-c-msg="Escribe un correo con el formato nombre@dominio.com."></span>
    <p class="c-field__description" id="tf-email-help">Solo para avisarte cuando se publique.</p>
    <p class="c-field__error" id="tf-email-err"></p>
  </div>
  <div class="c-field">
    <label class="c-label" for="tf-note">Mensaje <span class="c-label__optional">(opcional)</span></label>
    <span class="c-textarea"><textarea class="c-textarea__field" id="tf-note" name="note" placeholder="Escribe aquí…"></textarea></span>
  </div>
  <div class="c-field">
    <label class="c-label" for="tf-disabled">Código de invitación</label>
    <span class="c-input"><input class="c-input__field" id="tf-disabled" type="text" value="MIRO-2026" disabled></span>
  </div>
  <div class="c-btn-row">
    <button class="c-btn c-btn--primary" type="submit">Enviar</button>
    <span class="c-field__description" role="status" data-c-form-status></span>
  </div>
</form>

«Todo» trae tokens, dependencias y componente en un solo archivo, listo para abrir o dárselo a un agente.“All” bundles tokens, dependencies and the component in one file, ready to open or hand to an agent.

InstalaciónInstallation

  1. Agrega una vezAdd once tokens.css (colores, radios, tema oscuro).(colors, radii, dark theme).
  2. Agrega también:Also add: BotónButton.
  3. Copia los archivos:Copy the files: text-field.html, text-field.css, text-field.js.
  4. Para el tema oscuro, pon la claseFor the dark theme, add the class dark ento <html>.

Cuándo usarloWhen to use it

ÚsaloUse it

  • Para texto libre corto o largo.
  • Siempre con etiqueta visible.
  • For short or long free text.
  • Always with a visible label.

Mejor noAvoid

  • Con el placeholder como única etiqueta.
  • With the placeholder as the only label.

AccesibilidadAccessibility

textbox
TabPasa al siguiente campoMoves to the next field
  • Ayuda y error se enlazan con aria-describedby.
  • Al enviar con errores, el foco va al primer campo inválido.
  • El error se quita al escribir un valor válido, no al salir del campo (así no se mueve la página bajo el clic).
  • Hint and error are linked with aria-describedby.
  • On a failed submit, focus moves to the first invalid field.
  • Errors clear while typing a valid value, not on blur (so the page doesn't shift under the click).

Cómo probarloHow to test it

  • Envía vacío: el foco salta a «Nombre» y se lee su error.
  • Submit empty: focus jumps to “Name” and its error is read.

CréditosCredits