Accordion
Sections that open and close.
One section stays open at a time unless multiple is set. Each trigger sits in an
AccordionHeader, so the sections keep a heading structure; the panels animate their height.
Dependencies
What it's built from and what's built from it in Base, read from the imports in its source.
| Uses | Textprimitive |
|---|---|
| Used by | Nothing yet. |
| Packages | @ui-sdk/core@0.1.0-beta.20@ui-sdk/react@0.1.0-beta.20lucide-react@1.73.0 |
Installation
Set the project up for Base once first, as Getting started shows. Then add it with the CLI, or by hand.
With the CLI
Manually
Install its packages:
Add the components it uses first, listed under Dependencies.
Then copy the source:
API reference
Generated from Base's types. Props marked ours are added here; the rest come from the ui-sdk part it wraps. Every part also accepts its element's native attributes.
Accordion
Sections that open and close; one stays open at a time unless multiple is set.
- className
Type string | ((state: AccordionState<string>) => string)
- collapsible
Type boolean
- controller
Type { getValue: () => string[]; setValue: (value: string[], options?: AccordionChangeOptions) => boolean; isOpen: (value: string) => boolean; open: (value: string, options?: AccordionChangeOptions) => boolean; ... 4 more ...; focus: (value?: string | undefined) => void; } | undefined
- debug
Logs every state change with its reason to the console, in development builds.
Type boolean
- defaultValue
Type string[]
- hiddenUntilFound
Type boolean
- keepMounted
Type boolean
- onValueChange
Type ((value: string[], details: { reason: "imperative"; event?: undefined; source: ChangeSource; cancel: () => void; readonly canceled: boolean; } | { reason: "trigger-press"; event?: MouseEvent | KeyboardEvent | TouchEvent; source: ChangeSource; cancel: () => void; readonly canceled: boolean; } | { ...; }) => void) | u...
- render
Type RenderProp<AccordionState<string>>
- style
Type CSSProperties | ((state: AccordionState<string>) => CSSProperties)
- value
Type string[]
AccordionItem
One section: an AccordionHeader holding an AccordionTrigger, and an AccordionPanel.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: NoInfer<AccordionItemState>) => ReactNode)
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: NoInfer<AccordionItemState>) => string)
- disabled
Stops the item from opening or closing. Its trigger stays focusable.
Type boolean · Default false
- onOpenChange
Runs before the item opens or closes, before the accordion's
onValueChange.details.cancel()stops it.Type (open: boolean, details: ChangeDetails<AccordionValueChangeReason>) => void
- onOpenChangeComplete
Runs once the item's panel has finished opening or closing, after any animation.
Type (open: boolean) => void
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<NoInfer<AccordionItemState>>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: NoInfer<AccordionItemState>) => CSSProperties)
- value
Identifies the item. The accordion's value lists the open items' values. Defaults to a generated id.
Type string
AccordionPanel
The section's content. Its height animates as it opens and closes.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: NoInfer<AccordionItemState>) => ReactNode)
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: NoInfer<AccordionItemState>) => string)
- hiddenUntilFound
Whether the panel stays findable with
hidden="until-found"while closed. Overrides the accordion's.Type boolean
- keepMounted
Whether the panel stays in the page, hidden, while closed. Overrides the accordion's.
Type boolean
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<NoInfer<AccordionItemState>>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: NoInfer<AccordionItemState>) => CSSProperties)
- value
@internal The value of the item the panel belongs to. Parts read it from the item.
Type string
AccordionTrigger
Opens and closes its section, with its chevron built in.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: NoInfer<AccordionItemState>) => ReactNode)
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: NoInfer<AccordionItemState>) => string)
- disabled
Stops this trigger from opening or closing the item. It stays focusable.
Type boolean · Default false
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<NoInfer<AccordionItemState>>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: NoInfer<AccordionItemState>) => CSSProperties)
- value
@internal The value of the item the trigger belongs to. Parts read it from the item.
Type string