# Accordion A vertically stacked set of collapsible content sections. Uses native HTML `
` and `` elements for accessibility and zero-JavaScript functionality. ## Installation ```bash deno run -A jsr:@lockness/ui add accordion ``` ## Usage ```tsx import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from '@lockness/ui/components' Is it accessible? Yes. It adheres to the WAI-ARIA design pattern. Is it styled? Yes. It comes with default styles using CSS variables. ``` ## Components ### Accordion The root container component. | Prop | Type | Default | Description | | ---------- | --------- | ------- | -------------------------- | | `class` | `string` | - | Additional CSS class names | | `children` | `unknown` | - | Accordion items | ### AccordionItem Individual collapsible section using the native `
` element. | Prop | Type | Default | Description | | ---------- | --------- | ------------ | ----------------------------------------- | | `value` | `string` | **required** | Unique identifier for this accordion item | | `class` | `string` | - | Additional CSS class names | | `children` | `unknown` | - | Item content (trigger and content) | ### AccordionTrigger The clickable header using the native `` element. Includes a chevron icon that rotates when expanded. | Prop | Type | Default | Description | | ---------- | --------- | ------- | -------------------------- | | `class` | `string` | - | Additional CSS class names | | `children` | `unknown` | - | Trigger label content | ### AccordionContent The collapsible content panel. | Prop | Type | Default | Description | | ---------- | --------- | ------- | -------------------------------- | | `class` | `string` | - | Additional CSS class names | | `children` | `unknown` | - | Content to display when expanded | ## Theming The Accordion component can be customized using CSS variables. This allows you to change the appearance of accordion items, triggers, and content globally or override specific instances. ### Available CSS Variables | Variable | Default | Description | | -------------------------------------- | --------------- | ------------------------------------------ | | `--accordion-item-padding` | `1rem` | Padding for each accordion item | | `--accordion-trigger-font-size` | `1rem` | Font size for accordion trigger text | | `--accordion-trigger-font-weight` | `500` | Font weight for accordion trigger text | | `--accordion-content-padding-bottom` | `1rem` | Bottom padding for accordion content | | `--accordion-content-padding-top` | `0` | Top padding for accordion content | | `--accordion-content-font-size` | `0.875rem` | Font size for accordion content | | `--accordion-icon-transition-duration` | `200ms` | Duration of the chevron rotation animation | | `--accordion-border-color` | `var(--border)` | Border color between accordion items | ### Theming Examples #### Global Customization Customize all accordions by setting CSS variables in your theme: ```css /* app/view/assets/app.css */ @theme { --accordion-item-padding: 1.5rem; --accordion-trigger-font-size: 1.125rem; --accordion-trigger-font-weight: 600; --accordion-content-font-size: 1rem; --accordion-icon-transition-duration: 300ms; } ``` #### Local Overrides Override CSS variables for specific accordion instances: ```tsx
Larger padding and bolder text This accordion has custom padding and trigger font weight.
``` #### Component-Specific Theming Create themed sections with different accordion styles: ```tsx
Compact Style This accordion uses a more compact styling.
``` ## Features - **Zero JavaScript** - Uses native HTML details/summary elements - **Accessible** - Adheres to WAI-ARIA design patterns - **Animated** - Chevron rotates on expand/collapse - **Themeable** - Uses CSS variables for styling