- components
- βΊ
- accordion
- βΊ
- svelte
Accordion
Divide content into collapsible sections.
Inside your body are 206 bones. Each bone plays a very important role in making all the mechanics of your body function properly. If a bone is broken, all the bones around it canβt perform their duty properly.
The stapes, a bone in your inner ear, is the smallest of all your bones. This bone is also sometimes called the stirrup because of its Y shape. Together with the anvil and hammer bones, the stapes helps translate sounds you hear into waves your brain can understand.
The hyoid bone, which is in your throat, is the only bone that doesnβt connect to a joint. The hyoid is responsible for holding your tongue in place.
Controlled
Use value
and onValueChange
to control the value of the Accordion.
Content for item 1
Content for item 2
Content for item 3
Indicator
Add an indicator to the trigger with Accordion.ItemIndicator
.
Content for item 1
Content for item 2
Content for item 3
Collapsible
By default you canβt close open items. Adding collapsible
changes this behavior.
Content for item 1
Content for item 2
Content for item 3
Multiple
Adding multiple
allows items to open independently.
Content for item 1
Content for item 2
Content for item 3
Orientation
Use the orientation
prop to change the layout direction of the Accordion.
Content for item 1
Content for item 2
Content for item 3
Direction
Content for item 1
Content for item 2
Content for item 3
API Reference
Root
Property | Default | Type |
---|---|---|
ids | - | Partial<{ root: string; item: (value: string) => string; itemContent: (value: string) => string; itemTrigger: (value: string) => string; }> | undefinedThe ids of the elements in the accordion. Useful for composition. |
multiple | false | boolean | undefinedWhether multiple accordion items can be expanded at the same time. |
collapsible | false | boolean | undefinedWhether an accordion item can be closed after it has been expanded. |
value | - | string[] | undefinedThe controlled value of the expanded accordion items. |
defaultValue | - | string[] | undefinedThe initial value of the expanded accordion items. Use when you don't need to control the value of the accordion. |
disabled | - | boolean | undefinedWhether the accordion items are disabled |
onValueChange | - | ((details: ValueChangeDetails) => void) | undefinedThe callback fired when the state of expanded/collapsed accordion items changes. |
onFocusChange | - | ((details: FocusChangeDetails) => void) | undefinedThe callback fired when the focused accordion item changes. |
orientation | "vertical" | "horizontal" | "vertical" | undefinedThe orientation of the accordion items. |
dir | "ltr" | "ltr" | "rtl" | undefinedThe document's text/writing direction. |
getRootNode | - | (() => ShadowRoot | Node | Document) | undefinedA root node to correctly resolve document in custom environments. E.x.: Iframes, Electron. |
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |
RootProvider
Property | Default | Type |
---|---|---|
value | - | () => AccordionApi<PropTypes> |
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |
RootContext
Property | Default | Type |
---|---|---|
children | - | Snippet<[() => AccordionApi<PropTypes>]> |
Item
Property | Default | Type |
---|---|---|
value | - | stringThe value of the accordion item. |
disabled | - | boolean | undefinedWhether the accordion item is disabled. |
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |
ItemTrigger
Property | Default | Type |
---|---|---|
element | - | Snippet<[HTMLAttributes<"button">]> | undefinedRender the element yourself |
ItemIndicator
Property | Default | Type |
---|---|---|
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |
ItemContent
Property | Default | Type |
---|---|---|
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |