Components / primitive
Combobox
Picks one value from a list by typing to filter it.
Generated from @oods/foundry 0.10.1
- Categories
- primitive
- Contexts
- form
- Readiness
react-and-vue
Playground
This component's contract doesn't list typed props, so the playground shows its documented example.
Documented example combobox-filter-and-pick : type to filter, then Down and Enter, or click an option, the picked value emitted once and the list closed.
The render follows the page's theme switch: light, dark or high contrast. Both frameworks render the same example.
- Australia
- Canada
- France
- Germany
- Japan
- Mexico
- United Kingdom
- United States
Type to filter. We do not ship to Japan yet.
- Australia
- Canada
- France
- Germany
- Japan
- Mexico
- United Kingdom
- United States
Type to filter. We do not ship to Japan yet.
Events it emits: change, update. Use either render above, and each event shows here with the framework that sent it.
Code
The documented example. HTML is the markup the React component renders for it, which @oods/component-styles styles.
import { Combobox } from '@oods/components-react';
import '@oods/component-styles/css';
const options = [
{
"value": "au",
"label": "Australia"
},
{
"value": "ca",
"label": "Canada"
},
{
"value": "fr",
"label": "France"
},
{
"value": "de",
"label": "Germany"
},
{
"value": "jp",
"label": "Japan",
"disabled": true
},
{
"value": "mx",
"label": "Mexico"
},
{
"value": "gb",
"label": "United Kingdom"
},
{
"value": "us",
"label": "United States"
}
];
export function Example() {
return (
<Combobox
id="shipping-country"
label="Shipping country"
value="ca"
placeholder="Search countries"
help="Type to filter. We do not ship to Japan yet."
options={options}
/>
);
}Props, slots and events
Contract version 1.1.0. Types are from the React declarations in @oods/components-react.
| Prop | Type | Required | Documented example |
|---|---|---|---|
id | string | yes | shipping-country |
label | ReactNode | yes | Shipping country |
options | readonly ComboboxOption[] | undefined | no | [{"value":"au","label":"Australia"},{"value":"ca","label":"Canada"},{"value":"fr","label":"France"},{"value":"de","label":"Germany"},{"value":"jp","label":"Japan","disabled":true},{"value":"mx","label":"Mexico"},{"value":"gb","label":"United Kingdom"},{"value":"us","label":"United States"}] |
value | string | undefined | no | ca |
default | string | undefined | no | |
placeholder | string | undefined | no | Search countries |
name | string | undefined | no | |
required | boolean | undefined | no | |
disabled | boolean | undefined | no | |
help | ReactNode | no | Type to filter. We do not ship to Japan yet. |
validation | FieldValidation | undefined | no | |
size | "xs" | "sm" | "md" | "lg" | undefined | no |
Slots
label, help, validation
Events
change, update
States
closed, open, no-matches, selected, disabled, invalid
Accessibility
- Role
combobox- How it gets its name
labeloninput[role="combobox"]
Keyboard
| Key | What it does |
|---|---|
| Tab | Move focus to the named native control; an open list closes without picking |
| x | Type to filter the options by label |
| ArrowDown | Open the list and move to the next option |
| ArrowUp | Move to the previous option; with the list closed, open it at the last option |
| Home | Move to the first option of an open list |
| End | Move to the last option of an open list |
| Enter | Pick the active option and close the list |
| Escape | Close the list; with the list closed, clear the field |
Obligations in the contract
- An input with role combobox controls a listbox popup and reports aria-expanded, aria-autocomplete list and, while an option is active, aria-activedescendant; focus stays in the input
- The visible label names the combobox and its listbox; help and error text describe the input
- The chosen option reports aria-selected and shows a check mark; a disabled option reports aria-disabled and is skipped
- Down opens the list and moves, Up moves, Home and End go to the ends, Enter picks the active option, Escape closes the list and then clears the field, and Tab closes the list without picking
Typing filters the options to those whose label contains the typed text, ignoring case, and opens the list; when none matches the popup says No matches, which is not an option. value (controlled) or defaultValue (uncontrolled) names the chosen option, and the input shows its label. Picking an option (Enter on the active one, or a click) emits change and update with its value and closes the list; Escape with the list closed empties the input and, when an option was chosen, emits them with an empty value. An outside click or Tab closes the list without picking, and leaving the field restores the chosen label. size is the control height: xs 24, sm 28, md 32 (default) or lg 40, as Input, Select and Button. name submits the chosen value through a hidden input. The HTML renderer writes the same markup with the list closed and appends an inline script (data-oods-runtime="combobox") that gives it the same behaviour; without the script the input still shows the chosen label. One value only: no multiple selection, async loading, created values, grouped options or virtualization.
Tokens
The token roles this component reads.
input.backgroundinput.borderinput.textinput.placeholderinput.focuscombobox.popupcombobox.shadowcombobox.optioncombobox.optionActivecombobox.checkfield.message
Readiness
The evidence recorded for this component, with its label.
react-and-vue: catalog_list gives this label when the React and Vue components have complete readiness evidence, but the sweep's generated apps don't use the component in both.
| Evidence | React | Vue |
|---|---|---|
| state | implemented-evidence-complete | implemented-evidence-complete |
| versioned contract | passed | passed |
| target implementation | passed | passed |
| package export | passed | passed |
| public declaration | passed | passed |
| dependency closure | passed | passed |
| framework scenario | passed | passed |
| accessibility | verified | verified |
| interaction | verified | verified |
| visual themes | verified | verified |
Use your own
You can replace this component with your own React or Vue component. Map it, and generated code imports yours at the exact version you name. A contract report, run in a real browser, lists what your component met, what it didn't, and what wasn't checked.
The component_map call, with the parts in angle brackets yours to fill:
{
"action": "create",
"apply": true,
"externalSystem": "<your design system>",
"externalComponent": "<YourCombobox>",
"oodsTraits": [
"<trait names>"
],
"substitution": {
"component": "Combobox",
"react": {
"package": "<your-package>/react",
"version": "<exact version>",
"export": "<YourCombobox>"
},
"vue": {
"package": "<your-package>/vue",
"version": "<exact version>",
"export": "<YourCombobox>"
}
}
} How this page was made
Generated at build from the published data, each source with the hash of what was read. The page's manifest.
- Contract:
@oods/component-contracts@0.10.1 componentContracts.Comboboxsha256:5f47a8255353… - Documented example:
@oods/component-contracts@0.10.1 sharedScenarios combobox-filter-and-picksha256:103a3b387abd… - Catalog entry (catalog_list):
generated/0.10.1/system/catalog.json Comboboxsha256:6bbb68a42aad… - React readiness:
@oods/components-react@0.10.1 readiness Comboboxsha256:ee0b91102606… - Vue readiness:
@oods/components-vue@0.10.1 readiness Comboboxsha256:2421c99eda16… - Prop types:
generated/0.10.1/components/prop-types.json Comboboxsha256:baca099af2ae…