ComponentesComponents

Select

El select del navegador con el aspecto del de coss ui.The browser's select with coss ui's look.

DiseñoDesign: coss ui (MIT) · select.tsxMITambos · densidaddensity media · sobriaMarkdownJSON

CódigoCode

<div class="c-select-field">
  <label class="c-select-label" for="sel-framework">Formato</label>
  <span class="c-select">
    <select class="c-select__field" id="sel-framework" name="format">
      <option value="1:1">Cuadrado · 1:1</option>
      <option value="4:5" selected>Póster · 4:5</option>
      <option value="9:16">Historia · 9:16</option>
      <option value="16:9">Pantalla · 16:9</option>
    </select>
    <svg class="c-select__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/></svg>
  </span>
</div>
<div class="c-select-field">
  <label class="c-select-label" for="sel-country">País</label>
  <span class="c-select">
    <select class="c-select__field" id="sel-country" name="country" required>
      <option value="" disabled selected>Elige un país</option>
      <optgroup label="Sudamérica"><option>Argentina</option><option>Chile</option><option>Colombia</option><option>Perú</option></optgroup>
      <optgroup label="Centro y Norteamérica"><option>Guatemala</option><option>México</option></optgroup>
    </select>
    <svg class="c-select__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/></svg>
  </span>
</div>

«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. Copia los archivos:Copy the files: select.html, select.css.
  3. 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 elegir una opción entre 5 y 30.
  • To pick one of 5 to 30 options.

Mejor noAvoid

  • Con 2 a 4 opciones: usa radios.
  • Para acciones: usa un menú.
  • With 2 to 4 options: use radios.
  • For actions: use a menu.

AccesibilidadAccessibility

comboboxlistboxoption
Espacio EnterAbre la listaOpens the list
↑ ↓Cambia de opciónChanges option
Letra LetterSalta a la opciónJumps to the option
  • Es el <select> nativo: teclado, lector y la rueda del móvil vienen del navegador.
  • En Chrome 135+ la lista abierta también toma el estilo (appearance: base-select).
  • It is the native <select>: keyboard, screen reader and mobile picker come from the browser.
  • In Chrome 135+ the open list is styled too (appearance: base-select).

Cómo probarloHow to test it

  • Enfoca «País» y escribe «p»: salta a Perú.
  • Focus “Country” and type “p”: it jumps to Perú.

Límites conocidosKnown issues

  • En Safari y Firefox la lista abierta es la del sistema.
  • Safari and Firefox show the system list when open.

CréditosCredits