Saltar al contenido
El Muestrario

componente · @solu30/ui-kit/input

Select

Selector de una opción que suma buscador a partir de cierta cantidad de opciones, con limpieza opcional.

Seguir leyendo — 3 párrafos más

Custom select component with integrated search, filtering, and clearable support. Uses CSS variables for theming: --ui-bg-raised, --ui-accent, --ui-border, --ui-content-primary, --ui-error.

NOTE (portal ancestry): The floating panel is portalled to document.body. It is NOT a DOM descendant of the trigger wrapper. CSS :focus-within on the wrapper, descendant selectors targeting the panel, and ancestor-based DOM queries (e.g. .closest()) will NOT reach the panel. Target the panel via [data-ui-overlay="select"] instead.

A11Y (WAI-ARIA APG, "select-only combobox" + managed focus): the trigger is role="combobox" — query it with getByRole('combobox'), NOT 'button'. It carries aria-expanded / aria-controls / aria-invalid / aria-describedby, and takes its accessible name from label (wired via aria-labelledby) or, when there is no visible label, from the ariaLabel prop. error renders with role="alert" so validation failures are announced when they appear.

325 sitios de import en 10 de 15 verticales — un archivo que la importa cuenta una vez, monte una instancia o veinte.

  • TheCharterPanel
  • carlosmartinpavon
  • cmp-packages
  • dietaly
  • easycharter
  • elliot
  • gestorsalon
  • luigi
  • raquetea
  • zentrya

El componente, montado

Cargando el espécimen…

Éste es el conjunto completo. Abajo, los mismos casos por separado, cada uno con su código.

Cómo se usa

import { Select } from '@solu30/ui-kit/input'
<Select
  label="Tipo de evento"
  value={tipo}
  options={[
    { id: "boda", name: "Boda" },
    { id: "cumple", name: "Cumpleaños" },
  ]}
  onChange={(o) => setTipo(o.id)}
/>

Props

17 props declaradas en los tipos de la versión instalada.
PropRequeridaTipoQué hace
labelopcionalstringLabel for the select
valuesíTCurrently selected value
optionssíSelectOption<T>[]Available options
onChangesí(option: SelectOption<T>) => voidCallback when selection changes
placeholderopcionalstringPlaceholder when nothing is selected
disabledopcionalbooleanWhether the select is disabled
classNameopcionalstringAdditional CSS class
erroropcionalstringError message to display
helpTextopcionalstringHelp text to display below the select
fullWidthopcionalbooleanWhether the select should take full width
clearableopcionalbooleanWhether the select allows clearing the selection
onClearopcional() => voidCallback when selection is cleared
searchThresholdopcionalnumberMinimum options count to show the search input (default: 10)
searchPlaceholderopcionalstringPlaceholder for the search input
noResultsTextopcionalstringText shown when no options match the search
ariaLabelopcionalstringAccessible name when there is no visible `label`. A11y: `role="combobox"` does NOT take its name from content, so a Select without `label` and without this prop is announced as an unnamed combobox. Pass one whenever the field's purpose lives in surrounding layout (toolbar filters, inline table editors) instead of a visible label.
clearLabelopcionalstringAccessible name for the clear (×) affordance. Only rendered when `clearable`.

Simple

Para elegir un valor de una lista corta y fija, cuando alcanza con label y placeholder — sin borrado propio ni error.

Cargando el espécimen…

Con borrado

Cuando el campo puede quedar sin selección después de haber elegido algo — el filtro de un listado, no un campo obligatorio de un formulario.

Cargando el espécimen…

Deshabilitado

Cuando no hay opciones disponibles todavía y el campo tiene que mostrarlo sin dejar interactuar — el placeholder explica el motivo, no un label vacío.

Cargando el espécimen…

Con error

Para marcar que el campo quedó sin completar en una validación — el mensaje va pegado al campo, no en un aviso aparte.

Cargando el espécimen…

Composición

Cuando el select necesita grupos con encabezado propio o ítems deshabilitados dentro de la lista — la API de composición estilo Radix. A diferencia de «Select», esta no tiene prop «error»: mismo concepto, dos vocabularios en la misma familia.

Cargando el espécimen…

Ejemplo del paquete

<Select
  label="Status"
  value={status}
  options={[
    { id: 'active', name: 'Active' },
    { id: 'inactive', name: 'Inactive' }
  ]}
  onChange={handleChange}
/>

<Select<number>
  label="Category"
  value={categoryId}
  options={categories}
  onChange={handleCategoryChange}
  error="Must select a category"
  clearable
/>

Del @example del JSDoc de @solu30/ui-kit, sin editar: son 65 de los 541 símbolos. La sangría y los renglones en blanco son los del paquete.