Bedform UIMessages
Accordion
Show and hide a section of text.
Accordion
What is Realms?
Realms are private, cloud-hosted worlds where you can play with friends.
*
string
*
boolean
*
string
Usage
import { Accordion } from "@bedform/ui/accordion";
export function Realms() {
return (
<Accordion>
<summary>
<span className="ore-accordion-title">What is Realms?</span>
</summary>
<div className="ore-accordion-content">
Realms are private, cloud-hosted worlds where you can play with friends.
</div>
</Accordion>
);
}The summary and content have no components of their own; give them the public classes below.
Initial state
Use the native open attribute for an accordion that starts expanded.
<Accordion open>…</Accordion>Exclusive group
Give related accordions the same native name to keep only one item open.
<Accordion name="world-settings">…</Accordion>
<Accordion name="world-settings">…</Accordion>Events
The standard toggle event fires after the open state changes. Use onToggle and read the current state from event.currentTarget.open.
<Accordion onToggle={(event) => console.log(event.currentTarget.open)}>
…
</Accordion>API
Accordion renders a native details element, accepts all of its attributes, and forwards its ref to it.
| Prop | Type | Default |
|---|---|---|
open | boolean | false |
name | string | — |
Public classes
| Class | Purpose |
|---|---|
.ore-accordion | Native details root |
.ore-accordion-title | Summary label |
.ore-accordion-content | Collapsible content |
CSS variables
| Variable | Purpose |
|---|---|
--ore-accordion-unit | Base size unit |
--ore-accordion-border | Trigger and content border color |
--ore-accordion-background | Expanded content background color |
--ore-accordion-foreground | Trigger text and icon color |
--ore-accordion-content-foreground | Expanded content text color |
--ore-accordion-trigger-background | Idle summary background |
--ore-accordion-trigger-highlight | Idle summary highlight |
--ore-accordion-trigger-shadow | Idle summary shadow |
--ore-accordion-trigger-corner | Idle summary corner |
--ore-accordion-trigger-background-hover | Hover summary background |
--ore-accordion-trigger-highlight-hover | Hover summary highlight |
--ore-accordion-trigger-corner-hover | Hover summary corner |
--ore-accordion-trigger-background-pressed | Pressed summary background |
--ore-accordion-trigger-highlight-pressed | Pressed summary highlight |
--ore-accordion-trigger-shadow-pressed | Pressed summary shadow |
--ore-accordion-trigger-corner-pressed | Pressed summary corner |
Accessibility
The native details and summary elements provide disclosure semantics, keyboard activation, focus handling, and collapsed-content visibility without JavaScript. Do not place an interactive button inside summary.