No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

The component failed to render properly, likely due to a configuration issue in Storybook. Here are some common causes and how you can address them:

  1. Missing Context/Providers: You can use decorators to supply specific contexts or providers, which are sometimes necessary for components to render correctly. For detailed instructions on using decorators, please visit the Decorators documentation.
  2. Misconfigured Webpack or Vite: Verify that Storybook picks up all necessary settings for loaders, plugins, and other relevant parameters. You can find step-by-step guides for configuring Webpack or Vite with Storybook.
  3. Missing Environment Variables: Your Storybook may require specific environment variables to function as intended. You can set up custom environment variables as outlined in the Environment Variables documentation.

Combobox

Comboboxes combine a text entry with a picker menu, allowing users to filter longer lists to only the selections matching a query.

Usage notes

General notes

  • Combobox uses .spectrum-PickerButton instead of a .spectrum-Picker
  • The following classes must be added:
    • .spectrum-Combobox-textfield is required on the Textfield outer element (.spectrum-Textfield)
    • .spectrum-Combobox-input is required on the <input> element inside of Textfields (.spectrum-Textfield-input)
    • .spectrum-Combobox-button is required on the FieldButton (.spectrum-ActionButton spectrum-ActionButton--sizeM)

Indicating validity and focus

Validity and focus must be bubbled up to the parent so descendants siblings can be styled. Implementations should add the following classes to the .spectrum-Combobox parent class in the following situations:

  • .is-focused
    • when the input or button is focused with the mouse
  • .is-keyboardFocused
    • when the input or button is focused with the keyboard
  • .is-valid
    • when the input has an explicit valid state
  • .is-invalid
    • when the input has an explicit invalid state
  • .is-disabled
    • when the control is disabled; should also add to the .spectrum-Combobox-textfield and include a [disabled] attribute to the .spectrum-Combobox-button
  • .is-loading
    • when the progress circle is being shown

Don't use placeholder text

Putting instructions for how to complete an input, requirements, or any other essential information into placeholder text is not accessible. Once a value is entered, placeholder text is no longer viewable; if someone is using an automatic form filler, they will never get the information in the placeholder text.

Instead of placeholder text, use the help text description to convey requirements or to show any formatting examples that would help user comprehension. If there's placeholder text and help text at the same time, it becomes redundant and distracting, especially if they're communicating the same thing.

Variants

Default

Closed
Closed invalid
Closed loading
Closed disabled
Open
Open with label

Quiet

Closed
Closed invalid
Closed loading
Closed disabled
Open
Open with label

Read-only

Comboboxes have a read-only option for when content in the disabled state still needs to be shown. This allows for content to be copied, but not interacted with or changed. A combobox does not have a read-only option if no selection has been made. To enable this feature, add the .isReadOnly class to the combobox. To enable this feature, add the .isReadOnly class to the combobox. Then within the nested textfield component, add the .isReadOnly class and readonly attribute to the <input> element.

Properties

The component accepts the following inputs (properties):

NameDescriptionDefault
Component
Size*
string
-
Quiet styling
boolean
-
Show field label
boolean
-
State
Open
boolean
-
Invalid
boolean
-
Focused
boolean
-
Keyboard Focused
boolean
-
Loading
boolean
-
Disabled
boolean
-
Read-only
boolean
-
Content
Value
The value shows the option that a user has selected.
string
-

Modifiable custom properties

These are empty CSS custom property hooks available in this component that enable one-off customizations specific to a product implementation.

Property
--mod-combobox-alert-icon-color
--mod-combobox-background-color-default
--mod-combobox-background-color-disabled
--mod-combobox-background-color-focus
--mod-combobox-background-color-focus-hover
--mod-combobox-background-color-hover
--mod-combobox-background-color-key-focus
--mod-combobox-block-size
--mod-combobox-block-spacing-edge-to-alert
--mod-combobox-block-spacing-edge-to-progress-circle
--mod-combobox-border-color-default
--mod-combobox-border-color-disabled
--mod-combobox-border-color-focus
--mod-combobox-border-color-focus-hover
--mod-combobox-border-color-hover
--mod-combobox-border-color-invalid-default
--mod-combobox-border-color-invalid-focus
--mod-combobox-border-color-invalid-focus-hover
--mod-combobox-border-color-invalid-hover
--mod-combobox-border-color-invalid-key-focus
--mod-combobox-border-color-key-focus
--mod-combobox-border-radius
--mod-combobox-border-width
--mod-combobox-button-inline-offset
--mod-combobox-button-width
--mod-combobox-focus-indicator-color
--mod-combobox-focus-indicator-gap
--mod-combobox-focus-indicator-thickness
--mod-combobox-font-color-default
--mod-combobox-font-color-disabled
--mod-combobox-font-color-focus
--mod-combobox-font-color-focus-hover
--mod-combobox-font-color-hover
--mod-combobox-font-color-key-focus
--mod-combobox-font-color-placeholder
--mod-combobox-font-family
--mod-combobox-font-size
--mod-combobox-font-style
--mod-combobox-font-weight
--mod-combobox-icon-size
--mod-combobox-inline-size
--mod-combobox-line-height
--mod-combobox-min-inline-size
--mod-combobox-readonly-border-color-disabled
--mod-combobox-readonly-input-border-color
--mod-combobox-spacing-block-end-edge-to-text
--mod-combobox-spacing-block-start-edge-to-text
--mod-combobox-spacing-edge-to-menu
--mod-combobox-spacing-inline-end-edge-to-text
--mod-combobox-spacing-inline-icon-to-button
--mod-combobox-spacing-inline-start-edge-to-text
--mod-combobox-spacing-label-to-combobox

Tagged releases