Saltar al contenido
El Muestrario

componente · @solu30/ui-kit/input

Combobox

Selector con búsqueda que además permite crear una opción nueva con el texto que se tipeó.

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

  • cmp-packages
  • gestorsalon
  • luigi
  • raquetea

El componente, montado

Cargando el espécimen…

Cómo se usa

import { Combobox } from '@solu30/ui-kit/input'

Props

15 props declaradas en los tipos de la versión instalada.
PropRequeridaTipoQué hace
optionssíComboboxOption[]Available options.
valueopcionalstringCurrently selected value (matches `ComboboxOption.value`).
onChangesí(value: string) => voidCallback when an existing option is selected.
onCreateopcional(label: string) => void | Promise<void>When provided, enables creatable mode: if the typed text has no exact (case-insensitive) match among `options`, a "Crear «texto»" row appears at the end of the list and calls this with the trimmed typed label.
placeholderopcionalstringPlaceholder shown on the closed trigger when nothing is selected.
searchPlaceholderopcionalstringPlaceholder for the search input inside the popup.
createLabelopcionalstringLabel prefix for the create row. Default: "Crear".
labelopcionalstringLabel above the trigger.
erroropcionalstringError message — renders below the trigger and marks it invalid.
disabledopcionalbooleanDisables the trigger entirely.
loadingopcionalbooleanShows a spinner on the trigger and disables interaction (e.g. while `onCreate` is in flight upstream).
clearableopcionalbooleanShows a clear ("x") affordance when a value is selected.
onClearopcional() => voidCalled when the clear affordance is activated.
noResultsTextopcionalstringText shown when there are no matches and creation isn't available/eligible.
classNameopcionalstringExtra classes on the root wrapper.

Ejemplo del paquete

<Combobox
  label="Puesto"
  options={puestos.map((p) => ({ value: p.id, label: p.nombre }))}
  value={puestoId}
  onChange={setPuestoId}
  onCreate={async (nombre) => {
    const created = await createPuesto({ nombre })
    setPuestoId(created.id)
  }}
  placeholder="Seleccionar puesto..."
  searchPlaceholder="Buscar puesto..."
/>

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.