Skip to content

About

Created with CodeSandbox

Resources

Stars

82 stars

Watchers

2 watching

Forks

Latest commit

 

History

61 Commits

Folders and files

Repository files navigation

Downshift examples

Runnable React examples for Downshift 9.5.0. Start with the hook that matches the interaction you want.

I want to… Start here Guide
Type to filter suggestions Search books with useCombobox Combobox
Pick from a list using a button Choose a book with useSelect Select
Navigate and remove tags with the keyboard Manage tags with useTagGroup Tag group
Maintain a widget using the deprecated useMultipleSelection hook Select multiple books Multiple selection

Run an example

Use Node.js 24. From the repository root, run:

npm install
npm start

Open localhost:3000 and choose an example. Each demo has its own URL, such as the async book search. You can also open the repository in CodeSandbox. Run npm run build to compile the catalog and its demos.

Recipes

Task Example Try it
Work with object items Combobox · Select Search by author in the combobox or type the first letters of a title on the select. Both display the selected book's title.
Handle overlapping async searches Query-keyed cache Type p and quickly add r. The fast response shows Pride and Prejudice. Once the slower search finishes, Backspace shows both cached books. Try xyz for an empty result.
Skip disabled options Books on loan Press Arrow Down twice. The highlight skips War and Peace. Clicking the unavailable book also leaves the selection alone.
Preserve selection on outside dismissal Select in a popover Open Book filter, focus the select and press Arrow Down. Click outside to keep the previous selection. Repeat with Tab to accept the highlight. See the combobox reducer for a parent that unmounts its input.
Toggle several options in one listbox Combobox · Select Select an option twice. Its checkmark and aria-selected toggle together.
Add and remove selected tags Combobox with tags · Select with tags Add an item, focus its tag, then press Delete to remove it.
Attach props to a component-library input Material UI combobox Inspect the native input for the combobox role and its link to the listbox.
Navigate a virtualized list Combobox · Select Open the menu and hold Arrow Down to scroll through the options.

The async book search uses a simulated request and runs offline. Its Map stores results under the trimmed, lowercased query, including empty results. itemToKey compares books by ID across responses and itemToString supplies the text shown after selection. The Apollo and Algolia integrations use external services.

In v9, custom live-region announcements for useCombobox, useSelect and useMultipleSelection are opt-in through getA11yStatusMessage. For older apps using the render-prop component, see the Downshift examples and component guide.

About

Created with CodeSandbox

Resources

Stars

82 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages