antlitz
Menu

Disclosure

A section that expands and collapses. Renders a native details and summary, so the toggle, the keyboard handling and the open state all come from the platform — there is no JavaScript in this component at all.

import { Disclosure } from "antlitz";

API

PropTypeDefault
radius"none" | "sm" | "md" | "lg" | "full"none
size"sm" | "md" | "lg"md
summaryReactNode—
variant"outline" | "soft" | "plain"outline

summary is the always-visible trigger; children are revealed when it opens. Every remaining prop reaches the details element, including the native open attribute.

Usage

How long does shipping take?

Orders leave the warehouse within two working days.

export function Basic() {
  return (
    <Disclosure summary="How long does shipping take?">
      <Text size="sm" tone="muted">
        Orders leave the warehouse within two working days.
      </Text>
    </Disclosure>
  );
}

Accordion

How long does shipping take?

Orders leave the warehouse within two working days.

Can I return an item?

Anything unworn can go back within thirty days.

Do you ship internationally?

We ship to the EU and the UK.

export function Accordion() {
  return FAQ.map(({ question, answer }) => (
    <Disclosure key={question} name="faq" summary={question}>
      <Text size="sm" tone="muted">
        {answer}
      </Text>
    </Disclosure>
  ));
}

Disclosures sharing a name form an accordion: opening one closes the others. That is native to details, the way a shared name makes radios a group, so there is no separate Accordion here. Without a name they open independently, and one on its own is what other systems call a Collapsible.

Variants

Outline

The default.

Soft

A muted fill instead of a border.

Plain

No chrome at all.

export function Variants() {
  return (
    <>
      <Disclosure summary="Outline">
        <Text size="sm" tone="muted">
          The default.
        </Text>
      </Disclosure>
      <Disclosure variant="soft" summary="Soft">
        <Text size="sm" tone="muted">
          A muted fill instead of a border.
        </Text>
      </Disclosure>
      <Disclosure variant="plain" summary="Plain">
        <Text size="sm" tone="muted">
          No chrome at all.
        </Text>
      </Disclosure>
    </>
  );
}

There is no solid variant. A disclosure is chrome around content the reader has not asked for yet, and inverting it would give a collapsed panel more weight than the page around it.

Sizes

Small

Tighter padding.

Medium

The default.

Large

Roomier padding.

export function Sizes() {
  return (
    <>
      <Disclosure size="sm" summary="Small">
        <Text size="sm" tone="muted">
          Tighter padding.
        </Text>
      </Disclosure>
      <Disclosure size="md" summary="Medium">
        <Text size="sm" tone="muted">
          The default.
        </Text>
      </Disclosure>
      <Disclosure size="lg" summary="Large">
        <Text size="sm" tone="muted">
          Roomier padding.
        </Text>
      </Disclosure>
    </>
  );
}

Size changes padding only, never the text size, so a disclosure inherits the type scale of whatever surrounds it.

Radius

none

radius="none"

sm

radius="sm"

md

radius="md"

lg

radius="lg"

full

radius="full"

export function Radius() {
  return RADII.map((radius) => (
    <Disclosure key={radius} radius={radius} summary={radius}>
      <Text size="sm" tone="muted">
        radius=&quot;{radius}&quot;
      </Text>
    </Disclosure>
  ));
}

Initial state

Open on first render

The native `open` attribute decides the initial state, so the server renders it already expanded.

export function Open() {
  return (
    <Disclosure open summary="Open on first render">
      <Text size="sm" tone="muted">
        The native `open` attribute decides the initial state, so the server
        renders it already expanded.
      </Text>
    </Disclosure>
  );
}

open is a native attribute, so the expanded state is in the HTML rather than applied after hydration. Content inside a closed disclosure is still in the document — it is reachable by find-in-page and read by search engines.