Server Component · 0 KB client JS

Collapsible

A single disclosure that ships zero JavaScript. The open state is the browser's (<details>), toggling is the browser's, and the expanded / collapsed state is announced natively to assistive technology. It renders as a Server Component and works with JavaScript disabled.

What ships to the browser?
Nothing. This entire component renders to HTML on the server. The toggle you just used is the native details element.
Does it work with JavaScript disabled?
Yes: open, close, keyboard, and screen-reader state announcements are all platform behavior.

Import#

import { Collapsible } from "astralis-ui";

Exclusive groups (accordion, no JS)#

Collapsibles sharing a name form a native exclusive accordion: opening one closes its siblings via the <details name> attribute:

Only one of us stays open
Open my sibling and I close.
Try me
The grouping is the name attribute.
Or me
Still no JavaScript.

Uncontrolled by design#

There is no open/onOpenChange pair: a controlled variant would move the state into React and forfeit exactly the property this component exists for. Use defaultOpen for the initial state; if you need programmatic control, Accordion is the stateful sibling.

Accessibility#

  • The trigger stays a real <summary> with its native list-item display: only the marker is hidden. Restyling summary's display is the documented way to lose expanded/collapsed announcements in some screen readers, so the layout row is an inner span instead.
  • Find-in-page can auto-open a collapsed section in Chromium: content is searchable, not trapped.

Props#

PropTypeDefaultDescription
defaultOpenbooleanfalseOpen on first render. There is no controlled open prop: the state belongs to the browser.
namestringNoneCollapsibles sharing a name form a native exclusive group, where opening one closes the others.

Collapsible.Trigger#

PropTypeDefaultDescription
hideIndicatorbooleanfalseHides the built-in chevron, for when you draw your own.

Parts#

PropTypeDefaultDescription
Collapsible.Triggersummary propsNoneThe always-visible summary line that toggles the content.
Collapsible.Contentdiv propsNoneThe content shown while open. Adds spacing and typography only.

Keyboard#

The trigger is a native <summary>, so it is a tab stop that toggles with Enter or Space, with or without JavaScript.