charcell 0.1.0
mode

Accordion

sections stacked in one column, each opening and closing on its own.

usage

example

code

import { Accordion, AccordionItem } from 'charcell/react';

export function AccordionExample() {
  return (
    <Accordion>
      <AccordionItem title="the bait">
        first prize is the corley hardtail.
      </AccordionItem>
      <AccordionItem title="the collision">
        ben rams moe head-on and both cars explode.
      </AccordionItem>
      <AccordionItem title="the disguises">
        an unknown avenger and a doreen schmorley.
      </AccordionItem>
    </Accordion>
  );
}

as text

at rest
┌──────────────────────────────────────┐
│ ▾ the bait                           │
│                                      │
│ first prize is the corley hardtail.  │
│                                      │
├──────────────────────────────────────┤
│ ▸ the collision                      │
├──────────────────────────────────────┤
│ ▸ the disguises                      │
└──────────────────────────────────────┘
hover
┌──────────────────────────────────────┐
│ ▾ the bait                           │
│                                      │
│ first prize is the corley hardtail.  │
│                                      │
├──────────────────────────────────────┤
│ ▸ the collision                      │
├──────────────────────────────────────┤
│ ▸ the disguises                      │
└──────────────────────────────────────┘
focus
┌──────────────────────────────────────┐
│❯▾ the bait                           │
│                                      │
│ first prize is the corley hardtail.  │
│                                      │
├──────────────────────────────────────┤
│ ▸ the collision                      │
├──────────────────────────────────────┤
│ ▸ the disguises                      │
└──────────────────────────────────────┘

props

Accordion

variant'boxed' | 'dense'= 'boxed'
boxed rings the stack and rules between its items; dense is the bare stack.
spaciousboolean
Gives each header two rows, its title in the first: a 32px target, which meets WCAG 2.5.8 in the dense stack too.
border'none' | 'single' | 'rounded' | 'heavy' | 'double'
The style of every side of the boxed stack's ring: single, rounded, heavy, double or none.
borderX'none' | 'single' | 'rounded' | 'heavy' | 'double'
The style of the boxed stack's ring's start and end sides, over border.
borderY'none' | 'single' | 'rounded' | 'heavy' | 'double'
The style of the boxed stack's ring's top and bottom sides, over border.
borderTop'none' | 'single' | 'rounded' | 'heavy' | 'double'
The style of the boxed stack's ring's top side, over borderY and border.
borderEnd'none' | 'single' | 'rounded' | 'heavy' | 'double'
The style of the boxed stack's ring's end side, over borderX and border.
borderBottom'none' | 'single' | 'rounded' | 'heavy' | 'double'
The style of the boxed stack's ring's bottom side, over borderY and border.
borderStart'none' | 'single' | 'rounded' | 'heavy' | 'double'
The style of the boxed stack's ring's start side, over borderX and border.

it also takes any other attribute of its <div>.

AccordionItem

titlestring
The header row's text, after the ▾ / ▸ glyph.
defaultOpenboolean
The initial open state; the native disclosure owns it from there.
openboolean
The open state, held by the consumer; pair it with onOpenChange.
binds with v-model:open in vue, bind:open in svelte
onOpenChange(open: boolean) => void
Called with the new open state when the section opens or closes.
headingAs'h2' | 'h3' | 'h4' | 'h5' | 'h6'
The heading the title sits in, for a screen reader's list of headings.

it also takes any other attribute of its <details>.

slots

in react, the default slot is children and each named slot a prop of its name, a function where the slot hands values; in vue, a slot; in svelte, a snippet.

Accordion

default
The sections, an AccordionItem each.

AccordionItem

default
The section's content, under its header row.