Search the documentation

Type to search page titles, component names and descriptions.

    Data Entry

    Combobox

    Searchable single choice, multiple choice and tags.

    import { Combobox, MultiCombobox, TagPicker } from 'faifo-design'

    Combobox chooses one option from a list the reader can search. MultiCombobox chooses several, and TagPicker shows the chosen values as tags. The query, the open state and the selected values are controlled by the URL or by application state.

    #When to use

    • Use it when a Select would be too long to scan.
    • The options are data the application provides. For records fetched from a server as the reader types, use RelationPicker.

    #Examples

    Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.

    #Combobox and tags

    Query, open state and selected values remain controlled by URL or application state.

    Show codeHide code
    import { Avatar, Combobox, MultiCombobox, Stack, TagPicker } from 'faifo-design'
    
    export const Example = () => {
      const options = [
        { value: 'linh', label: 'Ngọc Linh', description: 'Sales operations' },
        { value: 'minh', label: 'Minh Anh', description: 'Fulfilment' },
      ]
      return (
        <Stack
          items={[
            <Combobox
              id="owner"
              name="owner"
              label="Owner"
              query="Ngọc"
              value="linh"
              options={options.map((option) => ({
                ...option,
                leading: <Avatar name={option.label} size="small" />,
              }))}
              open
              openHref="#comboboxes"
              closeHref="#comboboxes"
            />,
            <MultiCombobox
              id="watchers"
              name="watchers"
              label="Watchers"
              query=""
              options={options}
              values={['linh']}
              open={false}
              openHref="#comboboxes"
              closeHref="#comboboxes"
              removeHref={() => '#comboboxes'}
            />,
            <TagPicker
              id="tags"
              name="tags"
              label="Tags"
              query=""
              options={[{ value: 'urgent', label: 'Urgent' }]}
              values={['urgent']}
              open={false}
              openHref="#comboboxes"
              closeHref="#comboboxes"
              removeHref={() => '#comboboxes'}
            />,
          ]}
        />
      )
    }

    #API

    Generated from the package source. A property without a description has none in the source yet.

    #ComboboxComponent

    PropertyDescriptionTypeDefault
    idrequired–string–
    namerequired–string–
    queryNameName used for the human-readable search text; defaults to ${name}Query.string–
    labelrequired–string–
    queryrequired–string–
    value–string | null–
    optionsrequired–readonly ComboboxOption[]–
    openrequired–boolean–
    openHrefrequired–string–
    closeHrefrequired–string–
    help–string | null–
    error–string | null–
    issues–readonly FieldIssue[]–
    required–boolean–
    disabled–boolean–
    loading–boolean–
    loadingLabel–string–
    noResultsLabel–string–
    openLabelNames the toggle that opens the options; the default is English, so a page in another language passes it.string–
    closeLabelNames the toggle that closes the open options.string–
    span–'half' | 'full'–
    widthHow long the chosen value is (Field width): a short choice keeps a short control.'xs' | 'sm' | 'md'–

    #MultiComboboxComponent

    PropertyDescriptionTypeDefault
    idrequired–string–
    namerequired–string–
    queryNameName used for the human-readable search text; defaults to ${name}Query.string–
    labelrequired–string–
    queryrequired–string–
    optionsrequired–readonly ComboboxOption[]–
    openrequired–boolean–
    openHrefrequired–string–
    closeHrefrequired–string–
    help–string | null–
    error–string | null–
    issues–readonly FieldIssue[]–
    required–boolean–
    disabled–boolean–
    loading–boolean–
    loadingLabel–string–
    noResultsLabel–string–
    openLabelNames the toggle that opens the options; the default is English, so a page in another language passes it.string–
    closeLabelNames the toggle that closes the open options.string–
    span–'half' | 'full'–
    widthHow long the chosen value is (Field width): a short choice keeps a short control.'xs' | 'sm' | 'md'–
    valuesrequired–readonly string[]–
    removeHrefrequired–(value: string) => string–

    #TagPickerComponent

    PropertyDescriptionTypeDefault
    idrequired–string–
    namerequired–string–
    queryNameName used for the human-readable search text; defaults to ${name}Query.string–
    labelrequired–string–
    queryrequired–string–
    optionsrequired–readonly ComboboxOption[]–
    openrequired–boolean–
    openHrefrequired–string–
    closeHrefrequired–string–
    help–string | null–
    error–string | null–
    issues–readonly FieldIssue[]–
    required–boolean–
    disabled–boolean–
    loading–boolean–
    loadingLabel–string–
    noResultsLabel–string–
    openLabelNames the toggle that opens the options; the default is English, so a page in another language passes it.string–
    closeLabelNames the toggle that closes the open options.string–
    span–'half' | 'full'–
    widthHow long the chosen value is (Field width): a short choice keeps a short control.'xs' | 'sm' | 'md'–
    valuesrequired–readonly string[]–
    removeHrefrequired–(value: string) => string–

    #Types

    #ComboboxOption

    PropertyDescriptionTypeDefault
    valuerequired–string–
    labelrequired–string–
    description–string–
    disabled–boolean–
    leadingDecorative identity or color alongside the option name; does not change its accessible name.JSXChild–

    #ComboboxProps

    The properties of Combobox, listed above.

    #MultiComboboxProps

    The properties of TagPicker, listed above.

    #Hooks

    The data-ui values these components render. Select them in tests and behaviour; their look belongs to the design system. See Contract.

    • combobox
    • combobox-input-row
    • combobox-toggle
    • combobox-listbox
    • combobox-option
    • combobox-option-leading
    • combobox-empty
    • tag-picker