diff --git a/package-lock.json b/package-lock.json index 86c61d4a1..7afabfb63 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2402,6 +2402,7 @@ }, "node_modules/@clack/prompts/node_modules/is-unicode-supported": { "version": "1.3.0", + "extraneous": true, "inBundle": true, "license": "MIT", "engines": { diff --git a/packages/components/dropdown/src/Dropdown.doc.mdx b/packages/components/dropdown/src/Dropdown.doc.mdx index d799237bf..de901e842 100644 --- a/packages/components/dropdown/src/Dropdown.doc.mdx +++ b/packages/components/dropdown/src/Dropdown.doc.mdx @@ -79,23 +79,35 @@ import { Dropdown } from '@spark-ui/dropdown' -### Controlled value +### Controlled + +Use `value` and `onValueChange` props to control the value of the dropdown. ### Controlled open state +Use `open` and `onOpenChange` props to control when the dropdown is opened or closed. + ### Disabled +Use `disabled` on the root component to disable the dropdown entirely. + TODO ### Disabled Item +Use `disabled` on individual `Dropdown.Item` to disable them. + -### Grouped items +### Groups + +Similar to `optgroup` HTML tag, you can gather your items in groups. + +It is important to use `Dropdown.Label` inside each `Dropdown.Group` to give it an accessible name. @@ -105,24 +117,40 @@ TODO ### Trigger leading icon +Use `Dropdown.LeadingIcon` inside `Dropdown.Trigger` to prefix your trigger with an icon. + + + +### Read only + TODO -### Multiple selection +## Multiple selection - +When using `multiple` mode, the component manages an array of values and no longer a single value. -### Multiple selection (controlled) +It means you must adapt `value`, `onValueChange` and `defaultValue` accordingly. - +In `multiple` mode, the dropdown won't close when the user selects an item, and it is possible to unselect every item. -### Read only +### Default -TODO + + +### Controlled - multiple selection + +Use `value` and `onValueChange` props to control the value of the dropdown. + + ## Advanced usage ### Custom item +If your `Dropdown.Item` contains anything else than raw text, you may use any JSX markup to customize it. + +**If you do so, you MUST use `Dropdown.ItemText` inside of your item to give it a proper accessible name.** + ### With form field label diff --git a/packages/components/dropdown/src/Dropdown.stories.tsx b/packages/components/dropdown/src/Dropdown.stories.tsx index d6f01342d..8cad993bb 100644 --- a/packages/components/dropdown/src/Dropdown.stories.tsx +++ b/packages/components/dropdown/src/Dropdown.stories.tsx @@ -19,9 +19,6 @@ export const Default: StoryFn = _args => {