Some props/prop values deprecated in SWAN v3.3
Refer to the information on props/prop values provided further down this page. Find more information and migration documentation in the Deprecation roadmap.
Combobox
Combobox is only available in the React API for SWAN.
Use Combobox...
- To enable users to either pick a predefined value from a list or input their own.
- As our default Search Input with options.
- When you have a list of 15 or more options that you want to be searchable.
Basic Combobox
A BasicCombobox
is a simple-to-use convenience component that handles most typical use cases of a Combobox.
It takes a set of ComboboxOption
components as children:
- Each
ComboboxOption
must have a uniquekey
prop holding that option's value. - The child contents of the
ComboboxOption
will be displayed in the popover of suggestions once the user starts typing. - Any
ComboboxOption
that contains more than basic text (such as a Callout, thumbnail, or custom JSX) must have a textValue prop. This is required for Accessibility - Any
ComboboxOption
that contains more than basic text (such as a Callout, thumbnail, or custom JSX) must have a textValue prop. This is required for accessibility and is also the value that is displayed in the text input on selection..
Any ComboboxOption
that contain more than basic text (such as a Callout, thumbnail, or custom JSX) must have a textValue prop. This is required for accessibility and is also the value that is displayed in the text input on selection.
The preview has been updated.
Full Combobox
A Full Combobox allows you to put additional content inside the ComboboxPopover sub-component, notably a ComboboxPopoverTitle
above the ComboboxList
.
The preview has been updated.
With thumbnail container
Use ComboboxOptionThumbnailContainer
, which contains a square FluidImage
, to display square thumbnail images in selections.
The preview has been updated.
With floating label
Use ComboboxWithFloatingLabel
to move the label inside the input above the selection. This creates visual harmony with other form elements like text inputs that support floating labels. Keep label text short or use the fullWidth
prop to maximize width.
With Search Input
Use ComboboxWithSearchInput
to transform a Combobox in our default search field.
Refer to Search Input guidelines
The preview has been updated.
Allow custom value
Use allowsCustomValue
when you want to allow users to enter custom text in a Combobox, even if the entered text does not match any of the predefined options.
This will not change when or how onSelectionChange
is called when an option is selected.
The preview has been updated.
Managing state
Add the disableAutoFilter
prop to the Combobox when you also want to control the list of filtered options.
For better performance with large or dynamic data, use the dynamic collections API by passing an array into the items
prop of the Combobox and a render function as the child of ComboboxList
.
The preview has been updated.
Dynamic collections
Use the dynamic collections API for optimal performance with large or dynamic data. Pass an array into the items prop of the Combobox and a render function as the child of ComboboxList.
The useAsyncList
hook can be used when dealing with async data in order to fetch remote data (this is optional). Alternatively, you can manage async data similarly as in the controlled Combobox example above. Refer to the React-Area documentation for useAsyncList.
By default, the popover will remain closed if there are no results, typically before the initial request after a keypress has resolved. To enable the popover to open and display results after the request concludes, include the allowEmptyCollection
prop. Consider incorporating a loading state into the popover to prevent presenting an empty popover.
Props
<div />
as the root element. You can utilize the native attributes supported by <div />
tag. The ref
is directly assigned to the root element, allowing you to access and manipulate it as needed.prop | type | required | description | default |
---|---|---|---|---|
aria-label | string | false | Defines a string value that labels the current element.
Label for accessibility
@see aria-labelledby. | null |
aria-labelledby | string | false | Identifies the element (or elements) that labels the current element.
Label for accessibility
@see aria-describedby. | null |
children | ReactNode | false | The content to be displayed within the popover. | null |
items | Iterable<any> | false | Optional collection of dynamic options. Use with a render function as a child of ListboxList | null |
onSelectionChange | ((key: string | number) => void) | false | Callback trigger on selection change | null |
selectedKey | string | number | false | Specify the selected key | null |
disabledKeys | Set<string | number> | false | Specify the array of keys that should be disabled | null |
inputValue | string | false | Specify the input value | null |
defaultInputValue | string | false | Default input value | null |
onInputChange | ((value: string) => void) | false | Callback function that triggers on input change | null |
disableAutoFilter | boolean | false | Whether the auto filtering should be enable or disabled | null |
allowsCustomValue | boolean | false | Allows a custom input value that doesn't match an option in the list
This also prevents the input text from clearing when the input loses focus | null |
allowEmptyCollection | boolean | false | Allows the popover to open even there are no items present.
Useful when fetching data asynchronously or to display a loading or empty state | null |
size | "standard" | "mini" | null | false | ⚠️ Deprecated - This is deprecated without a replacement.
The size variation
Available options: 'standard', 'mini', | null |
skin | "standard" | "error" | null | false | The visual variant.
Note that error is implied if the TextInput is used inside of a FormInput that also contains a FormError.
Available options: 'standard', 'error' | standard |
placement | Placement | false | The placement of the popover. eg: "bottom start", "top end", "top", "bottom" | bottom start |
offset | number | false | The offset distance from the trigger element. | null |
isNonModal | boolean | false | Specifies whether the popover is used in a non-modal context. | null |
hideArrow | boolean | false | Specifies whether to hide the arrow of the popover. | true |
fullBleed | boolean | false | Specifies whether the popover should take up the full available width. | null |
labelText | string | false | The label text for accessibility. | null |
portalContainer | Element | false | The container for the portal where the popover is rendered. | null |
inModal | boolean | null | false | Set to "true" if the Listbox Popover is rendering inside a Modal. | null |
<div />
as the root element. You can utilize the native attributes supported by <div />
tag. The ref
is directly assigned to the root element, allowing you to access and manipulate it as needed.prop | type | required | description | default |
---|---|---|---|---|
aria-label | string | false | Defines a string value that labels the current element.
Label for accessibility
@see aria-labelledby. | null |
aria-labelledby | string | false | Identifies the element (or elements) that labels the current element.
Label for accessibility
@see aria-describedby. | null |
items | Iterable<any> | false | Optional collection of dynamic options. Use with a render function as a child of ListboxList | null |
onSelectionChange | ((key: string | number) => void) | false | Callback trigger on selection change | null |
selectedKey | string | number | false | Specify the selected key | null |
disabledKeys | Set<string | number> | false | Specify the array of keys that should be disabled | null |
inputValue | string | false | Specify the input value | null |
defaultInputValue | string | false | Default input value | null |
onInputChange | ((value: string) => void) | false | Callback function that triggers on input change | null |
disableAutoFilter | boolean | false | Whether the auto filtering should be enable or disabled | null |
allowsCustomValue | boolean | false | Allows a custom input value that doesn't match an option in the list
This also prevents the input text from clearing when the input loses focus | null |
allowEmptyCollection | boolean | false | Allows the popover to open even there are no items present.
Useful when fetching data asynchronously or to display a loading or empty state | null |
<input />
as the root element. You can utilize the native attributes supported by <input />
tag. The ref
is directly assigned to the root element, allowing you to access and manipulate it as needed.prop | type | required | description | default |
---|---|---|---|---|
size | "standard" | "mini" | null | false | ⚠️ Deprecated - This is deprecated without a replacement.
The size variation
Available options: 'standard', 'mini', | null |
skin | "standard" | "error" | null | false | The visual variant.
Note that error is implied if the TextInput is used inside of a FormInput that also contains a FormError.
Available options: 'standard', 'error' | standard |
<ul />
as the root element. You can utilize the native attributes supported by <ul />
tag. The ref
is directly assigned to the root element, allowing you to access and manipulate it as needed.<li />
as the root element. You can utilize the native attributes supported by <li />
tag. The ref
is directly assigned to the root element, allowing you to access and manipulate it as needed.prop | type | required | description | default |
---|---|---|---|---|
label | ReactNodeLike | false | The contents to render inside the ListboxButton. Can include JSX | null |
disabled | boolean | null | false | Whether or not the option is disabled. | null |
textValue | string | null | false | The option's human-readable string. Required if using JSX inside of an option | null |
withThumbnail | boolean | null | false | Whether or not the option has a thumbnail. | null |
<div />
as the root element. You can utilize the native attributes supported by <div />
tag. The ref
is directly assigned to the root element, allowing you to access and manipulate it as needed.prop | type | required | description | default |
---|---|---|---|---|
children | ReactNode | false | The content to be displayed within the popover. | null |
placement | Placement | false | The placement of the popover. eg: "bottom start", "top end", "top", "bottom" | bottom start |
offset | number | false | The offset distance from the trigger element. | null |
isNonModal | boolean | false | Specifies whether the popover is used in a non-modal context. | null |
hideArrow | boolean | false | Specifies whether to hide the arrow of the popover. | true |
fullBleed | boolean | false | Specifies whether the popover should take up the full available width. | null |
labelText | string | false | The label text for accessibility. | null |
portalContainer | Element | false | The container for the portal where the popover is rendered. | null |
inModal | boolean | null | false | Set to "true" if the Listbox Popover is rendering inside a Modal. | null |
<h4 />
as the root element. You can utilize the native attributes supported by <h4 />
tag. The ref
is directly assigned to the root element, allowing you to access and manipulate it as needed.<div />
as the root element. You can utilize the native attributes supported by <div />
tag. The ref
is directly assigned to the root element, allowing you to access and manipulate it as needed.<div />
as the root element. You can utilize the native attributes supported by <div />
tag. The ref
is directly assigned to the root element, allowing you to access and manipulate it as needed.