Navigation@knitui/components
Accordion
Accordion shows collapsible content panels. Compose Accordion.Item → Accordion.Control + Accordion.Panel. Single-open by default; pass multiple for several open at once. variant styles the container, chevronPosition/chevron control the indicator, and order promotes each control to a real heading level.
import { Accordion } from "@knitui/components";Usage
Compose Accordion.Item with an Accordion.Control and an Accordion.Panel. The
item's value is its identity — that is what value / defaultValue refer to.
import { Accordion } from "@knitui/components";
<Accordion defaultValue="shipping">
<Accordion.Item value="shipping">
<Accordion.Control>Shipping</Accordion.Control>
<Accordion.Panel>Ships in 2–3 days.</Accordion.Panel>
</Accordion.Item>
<Accordion.Item value="returns">
<Accordion.Control>Returns</Accordion.Control>
<Accordion.Panel>30 days, no questions.</Accordion.Panel>
</Accordion.Item>
</Accordion>;multiple lets several sections be open at once — and changes the shape of
value from a string to an array, which TypeScript enforces for you.
chevronPosition="left" moves the indicator, chevron replaces it, and
disableChevronRotation keeps it still if your own glyph shouldn't spin.
Panels stay mounted by default (keepMounted), so form state inside a closed
section survives. Set keepMounted={false} when a panel is expensive.
When to use something else
- Views that replace each other rather than stacking →
Tabs - A single show-more/show-less region →
CollapseorSpoiler
Examples
Variants
Each container variant.
Loading example…
Shadows
Elevation via the shared shadow ladder — inherited from Box, so every component accepts it; no shadow unless set.
Loading example…
Multiple
Multiple panels open at once.
Loading example…
Chevron Left
Chevron pinned to the left of the label.
Loading example…
Custom Chevron
A custom chevron glyph replaces the default.
Loading example…
With Icons
An icon to the left of each label.
Loading example…
Disabled Control
A disabled control cannot be toggled.
Loading example…
Heading Order
order promotes each control to a real heading level for screen readers.
Loading example…
Controlled
Controlled — the open item is owned by the parent.
Loading example…
Sizes
Representative size keys — controls scale the header height and label font.
Loading example…
Styles
Per-slot styles targets individual parts — here the control, label, and panel.
Loading example…
Props
| Prop | Type | Default | Description |
|---|---|---|---|
chevron | ReactNode | — | Custom chevron icon. |
chevronIconSize | string | number | undefined | — | Size of the default chevron glyph; ignored when a custom `chevron` is set. When unset the glyph keeps the kit's default size (14px) — a deliberate divergence from Mantine's 16 so a plain `<Accordion>` is pixel-identical. |
chevronPosition | AccordionChevronPosition | undefinedleft · right | 'right' | Position of the chevron. |
chevronSize | string | number | undefined | 'auto' | Size of the chevron container — gives every chevron a fixed centered slot. |
children | ReactNode | — | `Accordion.Item` children. |
defaultValue | AccordionValue<Multiple> | undefined | — | Uncontrolled initial value. |
disableChevronRotation | boolean | undefined | false | Disable the default chevron rotation animation. |
disabled system | boolean | undefined | — | — |
keepMounted | boolean | undefined | true | Keep inactive panels mounted (hidden). |
multiple | Multiple | undefined | false | Allow multiple items open simultaneously. |
onChange | ((value: AccordionValue<Multiple>) => void) | undefined | — | Called when value changes. |
order | AccordionHeadingOrder | undefined | undefined | Heading level at which `Accordion.Control` is announced — renders the control inside `role="heading"` + `aria-level={order}`. When unset, the control has no heading semantics (a plain pressable). |
radius system | string | number | undefined | 'md' | Corner rounding. |
shadow system | "xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined | — | — |
size system | "xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined | 'md' | Control size — scales the header `paddingHorizontal`/`minHeight`, the label font, and the default chevron glyph off the shared `controlMetrics` row. |
styles system | SlotStyles<AccordionStyles> | undefined | — | Uniform per-slot style passthrough — sugar over the composable parts. Slots: `root` / `item` / `control` / `label` / `chevron` / `panel`. Distributed through context so it reaches every nested part. Explicit inline props on a composed part always win. |
theme system | ThemeName | null | undefined | — | Applies a theme to this element |
transitionDuration | number | undefined | 200 | Panel expand/collapse transition duration in ms. |
transitionTimingFunction | string | undefined | 'ease' | Panel expand/collapse transition timing function. |
value | AccordionValue<Multiple> | undefined | — | Controlled value. |
variant system | AccordionVariant | undefineddefault · contained · filled · separated | 'default' | Visual style. |
Style slots
Every part of Accordion can be styled through the styles prop. Explicit props on the component always win over slot styles.
| Slot | Targets |
|---|---|
chevron | Props for the chevron container wrapping the glyph (.Chevron). |
control | Props for each Accordion.Control header (.Control). |
item | Props for each Accordion.Item (.Item) — its stylable frame surface. variant is context-driven; value/children are the part's own (identity + content), so the sugar targets the frame like the sibling slots do. |
label | Props for the label text inside each control (.Label). |
panel | Props for each Accordion.Panel (.Panel). |
root | Props for the Accordion root (.Root). |
Plus 496 inherited style props from Box — the full Tamagui/React Native style surface, including token shorthands like p, mx, bg and c. See Tokens for the scales they accept, or the full list.
Accessibility
Each control is a role="button" with aria-expanded reflecting its state, and
each panel is a role="region", which is the ARIA disclosure pattern.
Controls are made focusable and operable through the shared
useKeyboardActions hook, since the control
frame is a styled Box rather than a native <button>.
| Key | Action |
|---|---|
| Tab | Move to the next accordion control |
| Space / Enter | Toggle the focused section |
Set order when the accordion is part of the page's document outline. It wraps
each control in role="heading" with a matching aria-level, which is what lets
screen-reader users jump between sections with heading navigation instead of tabbing
through every control. Without it the controls are buttons with no heading
semantics — fine for a compact widget, a real loss for an FAQ page. Pick the level
that fits the surrounding headings:
<Accordion order={3}>{/* controls become level-3 headings */}</Accordion>Arrow keys deliberately do not move between controls: ARIA lists that as optional for accordions, and Tab already reaches every control in order.