@akhatmirzo/ui

Accordion

Collapsible sections for FAQs, settings and long forms.

Toshkent bo'ylab 1 kun, viloyatlarga 2–3 ish kuni.

Import

import { Accordion } from '@akhatmirzo/ui';

When to use

  • FAQs — users open only the question they care about, and the page stays short.
  • Settings and long forms — split them into sections instead of showing everything at once.
  • Don't hide essential content. Anything users must see should stay visible — most people never open collapsed text.
  • If only one section should be visible at a time and the sections are equally important, Tabs may fit better.

Anatomy

The simplest form is an Accordion.Item with a title: the header and the content are rendered for you, and children become the content.

<Accordion defaultValue="delivery">
  <Accordion.Item value="delivery" title="How long does delivery take?">
    One day within Tashkent, 2–3 business days to other regions.
  </Accordion.Item>
</Accordion>

To put your own content in the header (a badge, an icon), skip title and write Accordion.Trigger + Accordion.Content yourself (see "Composition" below).

Variants

VariantLooks like
separatedEach section is its own card, 8px apart (default)
borderedAll sections in one card, divided by lines
ghostNo background, just divider lines
separated

Toshkent bo'ylab 1 kun.

bordered

Toshkent bo'ylab 1 kun.

ghost

Toshkent bo'ylab 1 kun.

Several open at once

By default (type="single"), one section is open at a time — opening another closes the previous one. With type="multiple", several can be open together; value and defaultValue become arrays.

Toshkent bo'ylab 1 kun, viloyatlarga 2–3 ish kuni.

Click, Payme, Uzum va naqd pul.

Always one open

With type="single", clicking the open section closes it (collapsible defaults to true). With collapsible={false}, exactly one section always stays open — it behaves like picking one of several options.

Ertasi kuni eshigingizgacha. Narxi — 25 000 so'm.

Composition

Inside an Accordion.Item, use Accordion.Trigger and Accordion.Content to add a badge, an icon or a second line to the header. A single section can be turned off with disabled.

Controlled

With value + onValueChange, you decide which sections are open — for an "Expand all" button, syncing with the URL and so on.

Ism, telefon va tug'ilgan sana.

Props

Accordion

Also accepts <div> attributes.

PropTypeDefaultDescription
type'single' | 'multiple''single'Whether one or several sections can be open
valuestring · string[]—Open section(s) — an array with multiple
defaultValuestring · string[]—Initially open section(s)
onValueChange(value: string) => void · (value: string[]) => void—Called when sections open or close
collapsiblebooleantruesingle only: whether the open section can be closed again
variant'separated' | 'bordered' | 'ghost''separated'Visual style
disabledboolean—Disables every section
orientation'horizontal' | 'vertical'—Direction of keyboard navigation (vertical by default)
dir'ltr' | 'rtl'—Text direction

Accordion.Item

PropTypeDefaultDescription
valuerequiredstring—Section value
titleReactNode—If set, Trigger and Content are rendered for you; children become the content
disabledboolean—Disables the section

Accordion.Trigger, Accordion.Content

Accordion.Trigger takes <button> attributes and draws a chevron on the right. Accordion.Content takes <div> attributes and forceMount (to keep it in the DOM while closed).

Data attributes

AttributeOnValue
data-variantroot, itemseparated · bordered · ghost
data-stateitem, trigger, contentopen · closed
data-disableditem, triggerpresent when disabled
data-orientationall partsvertical · horizontal
data-accordion-chevronthe chevron icon—

Keyboard

KeyAction
Enter / SpaceOpens or closes the focused section
↓ / ↑Moves to the next / previous header
Home / EndFirst / last header
TabMoves to the next focusable element

Accessibility

  • Structure. Each header is a <button> inside an <h3>; the button gets aria-expanded and aria-controls, and the content is a role="region" labeled by its header through aria-labelledby. It is built on Radix Accordion.
  • The chevron is decorative (aria-hidden) and rotates 180° when open.
  • Animation. The height animates over 200ms; with prefers-reduced-motion, only a fade is used.
  • The focus ring only shows for keyboard focus.

On this page