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).
Preview
Section titled “Preview”<nana-details summary="What is Nana UI?" style="width: 100%">
A framework-agnostic web component library built with Lit.
</nana-details> When is rent due?
How is the deposit refunded?
Can I sublet?
<script lang="ts">
import { NanaDetails } from '$lib/components/ui/details';
</script>
<div class="flex w-full max-w-lg flex-col gap-3">
<NanaDetails summary="When is rent due?" name="faq" open>
On the first of each month. A reminder goes out three days before.
</NanaDetails>
<NanaDetails summary="How is the deposit refunded?" name="faq">
Within 30 days of the move-out inspection, less any agreed repairs.
</NanaDetails>
<NanaDetails summary="Can I sublet?" name="faq" variant="filled">
Only with written approval from the property manager.
</NanaDetails>
</div> Installation
Section titled “Installation”Install the package for a versioned dependency:
npm install @nana-tec/ui-componentsOr copy the source in and own it:
npx @nana-tec/ui add details --framework web-componentsnpx @nana-tec/ui add details --framework svelteLands in src/lib/components/ui/details/ as NanaDetails.svelte, styled with Tailwind
classes that resolve to the design tokens. Requires Tailwind v4.
Import
Section titled “Import”
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.
Basic usage
Section titled “Basic usage”<nana-details summary="What is Nana UI?" style="width:100%"> A framework-agnostic web component library built with Lit.</nana-details>Variants
Section titled “Variants”<nana-details variant="default" summary="Default" style="width: 100%">
Content.
</nana-details>
<nana-details variant="outlined" summary="Outlined" style="width: 100%">
Content.
</nana-details>
<nana-details variant="filled" summary="Filled" style="width: 100%">
Content.
</nana-details>
<nana-details variant="card" summary="Card" style="width: 100%">
Content.
</nana-details>
<nana-details variant="minimal" summary="Minimal" style="width: 100%">
Content.
</nana-details>
<nana-details variant="divider" summary="Divider" style="width: 100%">
Content.
</nana-details> Indicators
Section titled “Indicators”The indicator attribute sets the expand affordance — chevron, plus, or
none.
<nana-details indicator="chevron" summary="Chevron" style="width: 100%">
Content.
</nana-details>
<nana-details indicator="plus" summary="Plus" style="width: 100%">
Content.
</nana-details>
<nana-details indicator="none" summary="No indicator" style="width: 100%">
Content.
</nana-details> Accordion
Section titled “Accordion”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
<nana-details
name="faq"
variant="outlined"
summary="How do I install it?"
style="width: 100%"
>
<code>npm install @nana-tec/ui-components</code>
</nana-details>
<nana-details
name="faq"
variant="outlined"
summary="Does it need a framework?"
style="width: 100%"
>
No — they are standard custom elements.
</nana-details>
<nana-details
name="faq"
variant="outlined"
summary="Can I restyle it?"
style="width: 100%"
>
Yes, through the CSS parts and custom properties below.
</nana-details> | Key | Action |
|---|---|
| Enter / Space | Toggle the focused panel |
| ↓ / ↑ | Move to the next / previous summary, wrapping |
| Home / End | Move 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
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
description | description | string | '' | Secondary description shown under the title |
disabled | disabled | boolean | false | Disable the disclosure |
indicator | indicator | DetailsIndicator | 'chevron' | Expand indicator style |
indicatorPlacement | indicator-placement | 'start' | 'end' | 'end' | Place the indicator at the start of the summary instead of the end |
name | name | string | '' | Accordion group name — opening one closes others sharing the name |
open | open | boolean | false | Expanded state |
size | size | DetailsSize | 'md' | Size |
summary | summary | string | '' | Summary title text (ignored when the summary slot is used) |
variant | variant | DetailsVariant | 'default' | Visual style |
Methods
| Method | Description |
|---|---|
focus(options?: FocusOptions): void | Focus the summary |
hide(): void | Collapse the panel. |
show(): void | Expand the panel. |
toggle(): void | Toggle the panel. |
Events
| Event | Description |
|---|---|
nana-toggle | Fired whenever the open state changes (detail.open) |
nana-show | Fired when expanded |
nana-hide | Fired when collapsed |
Slots
| Slot | Description |
|---|---|
(default) | The collapsible content |
summary | Custom summary content (overrides summary / description) |
icon | Leading icon in the summary |
badge | Trailing badge / status before the indicator |
CSS parts
| Part | Description |
|---|---|
::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
| Property | Description |
|---|---|
--nana-details-radius | Corner radius |
--nana-details-padding | Summary / content padding |
--nana-details-duration | Expand / chevron animation duration |
--nana-details-bg | Background of the disclosure |
NanaDetails
| Prop | Type | Default |
|---|---|---|
summary | string | '' |
openbind: | boolean | false |
variant | DetailsVariant | 'default' |
disabled | boolean | false |
heading | Snippet | |
children | Snippet | |
onOpenChange | (open: boolean) => void |
Also accepts Omit<HTMLDetailsAttributes, 'class' | 'open'>.