Skip to content
Nana UI

Layout & Containers

Details

A disclosure / expandable panel. A clickable summary toggles a smoothly animated content region. Compose the body from any markup via the default slot, and add a leading icon or trailing badge. Group several together with a shared name for accordion behaviour (one open at a time).

View .md Download
A framework-agnostic web component library built with Lit.
When is rent due?
On the first of each month. A reminder goes out three days before.
How is the deposit refunded?
Within 30 days of the move-out inspection, less any agreed repairs.
Can I sublet?
Only with written approval from the property manager.

Install the package for a versioned dependency:

npm install @nana-tec/ui-components

Or copy the source in and own it:

npx @nana-tec/ui add details --framework web-components
npx @nana-tec/ui add details --framework svelte

Lands in src/lib/components/ui/details/ as NanaDetails.svelte, styled with Tailwind classes that resolve to the design tokens. Requires Tailwind v4.

Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and each component downloads only the first time a page uses it:

import "@nana-tec/ui-components/autoloader";
import "@nana-tec/ui-components/theme";

The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.

Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:

import "@nana-tec/ui-components/details";

Copied in with npx @nana-tec/ui add details? Import your project's own @/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.

<script lang="ts">
import { NanaDetails } from '$lib/components/ui/details';
let open = $state(false);
</script>
<NanaDetails summary="Deposit terms" bind:open>Refunded within 30 days.</NanaDetails>

A native <details>, so it opens without script and the browser finds text inside it. Give several the same name and only one stays open.

<nana-details summary="What is Nana UI?" style="width:100%">
A framework-agnostic web component library built with Lit.
</nana-details>
Content. Content. Content. Content. Content. Content.

The indicator attribute sets the expand affordance — chevron, plus, or none.

Content. Content. Content.

Give several panels the same name and only one stays open: opening one closes its siblings. The arrow keys also move between summaries, so a long group can be walked without tabbing through the content of every panel on the way.

npm install @nana-tec/ui-components No — they are standard custom elements. Yes, through the CSS parts and custom properties below.
KeyAction
Enter / SpaceToggle the focused panel
↓ / ↑Move to the next / previous summary, wrapping
Home / EndMove to the first / last summary

Disabled panels are skipped. A panel with no name is on its own — it neither closes others nor takes part in the arrow navigation.

Properties

PropertyAttributeTypeDefaultDescription
descriptiondescriptionstring''Secondary description shown under the title
disableddisabledbooleanfalseDisable the disclosure
indicatorindicatorDetailsIndicator'chevron'Expand indicator style
indicatorPlacementindicator-placement'start' | 'end''end'Place the indicator at the start of the summary instead of the end
namenamestring''Accordion group name — opening one closes others sharing the name
openopenbooleanfalseExpanded state
sizesizeDetailsSize'md'Size
summarysummarystring''Summary title text (ignored when the summary slot is used)
variantvariantDetailsVariant'default'Visual style

Methods

MethodDescription
focus(options?: FocusOptions): voidFocus the summary
hide(): voidCollapse the panel.
show(): voidExpand the panel.
toggle(): voidToggle the panel.

Events

EventDescription
nana-toggleFired whenever the open state changes (detail.open)
nana-showFired when expanded
nana-hideFired when collapsed

Slots

SlotDescription
(default)The collapsible content
summaryCustom summary content (overrides summary / description)
iconLeading icon in the summary
badgeTrailing badge / status before the indicator

CSS parts

PartDescription
::part(base)The outer container
::part(summary)The clickable trigger
::part(content)The content region
::part(icon)The icon
::part(text)The text
::part(title)The title
::part(description)The description
::part(badge)The badge
::part(content-wrap)The content wrap
::part(content-inner)The content inner

CSS custom properties

PropertyDescription
--nana-details-radiusCorner radius
--nana-details-paddingSummary / content padding
--nana-details-durationExpand / chevron animation duration
--nana-details-bgBackground of the disclosure

NanaDetails

PropTypeDefault
summarystring''
openbind:booleanfalse
variantDetailsVariant'default'
disabledbooleanfalse
headingSnippet
childrenSnippet
onOpenChange(open: boolean) => void

Also accepts Omit<HTMLDetailsAttributes, 'class' | 'open'>.