Comboboxes
A widget that provides a user with an input field that is either an autocomplete or readonly, accompanied with a listbox of pre-definfined options.
Interactive Examples
Base
- Acme
- Salesforce.com, Inc.
Base: With subheader
Base: Inherit Menu Width
Base: Predefined options only
- Acme
- Salesforce.com, Inc.
Base With Scroll
- Acme
- Salesforce.com, Inc.
Base: With dialog
Inline single selection
Inline single selection invalid
Inline: Single Selection with Entity Selection
Inline: Single Selection with Search and Add Menu Items
Inline: Multiple Selection with Loading State
Read-only: Single Selection (Picklist)
Read-only: Multiple Selection (Picklist)
Required Input and Error State
Need more examples? Find a bug?
For even more examples, please take a preview of our development environment built on the popular Storybook platform that is an always up-to-date deploy of this repository's master
branch. All example code on this page can be found in the /components/combobox/__examples__/
folder. Storybook example code can be found in /components/combobox/__docs__/storybook-stories.jsx
.
Property Details
All public, supported component props are listed below. If you believe there is a clearer way to describe a property, please submit a pull request. Property descriptions are built from source code comments (written in Markdown) located within propTypes
objects which are typically found in each component's index.jsx
. Pull requests to update these descriptions can easily be done without cloning this repository by clicking "Edit this file" in the Github user interface.
Name | Type | Required | Default | Description |
---|---|---|---|---|
assistiveText | shape | { loadingMenuItems: Loading, optionSelectedInMenu: Current Selection:, removeSingleSelectedOption: Remove selected option, removePill: , Press delete or backspace to remove, selectedListboxLabel: Selected Options:, } | Assistive text for accessibility This object is merged with the default props object on every render.
| |
aria-describedby | string | The | ||
className | union | CSS classes to be added to tag with | ||
classNameContainer | union | CSS classes to be added to top level tag with | ||
classNameMenu | union | CSS classes to be added to tag with | ||
classNameMenuSubHeader | union | CSS classes to be added to tag with | ||
events | shape | {} | Event Callbacks
| |
errorText | string | Message to display when the input is in an error state. When this is present, also visually highlights the component as in error. Tested with snapshot testing. | ||
fieldLevelHelpTooltip | node | A Tooltip component that is displayed next to the | ||
hasDeselect | bool | If true, | ||
hasInputSpinner | bool | If true, loading spinner appears inside input on right hand side. | ||
hasMenuSpinner | bool | Add loading spinner below the options | ||
hasStaticAlignment | bool | By default, dialogs will flip their alignment (such as bottom to top) if they extend beyond a boundary element such as a scrolling parent or a window/viewpoint. | ||
id | string | HTML id for component. Tested with snapshot testing. | ||
input | node | An Input component. The props from this component will override any default props. | ||
labels | shape | {
deselectOption: None,
cancelButton: Cancel,
doneButton: | Text labels for internationalization This object is merged with the default props object on every render.
| |
isOpen | bool | Forces the dropdown to be open or closed. See controlled/uncontrolled callback/prop pattern for more on suggested use view Concepts and Best Practices Tested with snapshot testing. | ||
inheritWidthOf | string: target | menu | none | target | Sets the dialog width to the width of one of the following:
| |
onRenderMenuItem | func | Accepts a custom menu item rendering function that becomes a custom component. It should return a React node. The checkmark is still rendered in readonly variants. This function is passed the following props:
Tested with snapshot testing. | ||
inputRef | func | This callback exposes the input reference / DOM node to parent components. | ||
menuPosition | string: absolute | overflowBoundaryElement | relative | absolute | Please select one of the following:
| |
menuMaxWidth | string | Sets a maximum width that the menu will be used if | ||
multiple | bool | Allows multiple selections Tested with mocha testing. | ||
options | arrayOf | Array of item objects in the dropdown menu. Each object can contain:
| ||
menuItemVisibleLength | string: 5 | 7 | 10 | Determines the height of the menu based on SLDS CSS classes. This is a | ||
predefinedOptionsOnly | bool | Limits auto-complete input submission to one of the provided options. Tested with mocha testing. | ||
popover | node | A | ||
required | bool | false | Applies label styling for a required form element. Tested with snapshot testing. | |
selection | arrayOf | [] | Accepts an array of item objects. For single selection, pass in an array of one object. For item object keys, see | |
selectedListboxRef | func | This callback exposes the selected listbox reference / DOM node to parent components. | ||
singleInputDisabled | bool | false | Disables the input and prevents editing the contents. This only applies for single readonly and inline-listbox variants. | |
tooltipMenuItemDisabled | element | Accepts a tooltip that is displayed when hovering on disabled menu items. | ||
value | string | Value of input. This is a controlled component, so you will need to control the input value by passing the | ||
defaultValue | string | Default value of input. Provide uncontroled behaviour | ||
optionsAddItem | arrayOf | [] | Array of item objects in the dropdown menu that is displayed below the list of
| |
optionsSearchEntity | arrayOf | [] | Array of item objects in the dropdown menu that is displayed above the list of
| |
entityCombobox | node | Node of type Combobox for creating grouped comboboxes. | ||
variant | string: base | inline-listbox | popover | readonly | base | Defines Combobox variant styling and functionality |