Accordion
Expandable sections, one or many open at a time.
Example
Mon–Fri at 06:00. Weekends stay quiet unless you add them.
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@porcelana/ui";
export default function Example() {
return (
<Accordion type="single" collapsible defaultValue="repeat">
<AccordionItem value="repeat">
<AccordionTrigger>Repeat on weekdays</AccordionTrigger>
<AccordionContent>Mon–Fri at 06:00. Weekends stay quiet unless you add them.</AccordionContent>
</AccordionItem>
<AccordionItem value="sound">
<AccordionTrigger>Sound</AccordionTrigger>
<AccordionContent>Morning chime, rising volume over 30 seconds.</AccordionContent>
</AccordionItem>
</Accordion>
);
}Import
import { Accordion, AccordionTrigger } from "@porcelana/ui";
import "@porcelana/ui/styles.css"; // once, at your app rootProps
Generated from the TypeScript types. Standard HTML attributes are passed through and not listed.
Accordion
| Prop | Type | Default | Description |
|---|---|---|---|
typerequired | "single" | "multiple" | – | Button type (defaults to "button"). |
aria-label | string | – | Defines a string value that labels the current element. @see aria-labelledby. |
asChild | boolean | – | Render the single child element instead, merging props and behaviour onto it. |
collapsible | boolean | false | Whether an accordion item can be collapsed after it has been opened. |
defaultValue | string | string[] | – | The value of the item whose content is expanded when the accordion is initially rendered. Use `defaultValue` if you do not need to control the state of an accordion. The value of the items whose contents are expanded when the accordion is initially rendered. Use `defaultValue` if you do not need to control the state of an accordion. |
dir | Direction | – | The language read direction. |
disabled | boolean | – | Whether or not an accordion is disabled from user interaction. @defaultValue false |
id | string | – | Element id. Generated automatically when omitted. |
onValueChange | ((value: string) => void) | ((value: string[]) => void) | – | The callback that fires when the state of the accordion changes. |
orientation | Orientation | vertical | The layout in which the Accordion operates. |
value | string | string[] | – | The controlled stateful value of the accordion item whose content is expanded. The controlled stateful value of the accordion items whose contents are expanded. |
AccordionTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | – | Defines a string value that labels the current element. @see aria-labelledby. |
asChild | boolean | – | Render the single child element instead, merging props and behaviour onto it. |
disabled | boolean | – | Prevents interaction and dims the control. |
id | string | – | Element id. Generated automatically when omitted. |
level | 2 | 3 | 4 | 5 | 6 | 3 | Heading level of the wrapping header element. Defaults to 3. |
type | "button" | "submit" | "reset" | – | Button type (defaults to "button"). |
Accessibility
- Each trigger sits in a heading (level prop) and exposes aria-expanded; panels are labelled regions.
- Enter and Space toggle; arrows move between triggers.
Mobile
- 56px trigger rows.