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.

PropTypeDefault
openbooleanfalse
namestring—

Public classes

ClassPurpose
.ore-accordionNative details root
.ore-accordion-titleSummary label
.ore-accordion-contentCollapsible content

CSS variables

VariablePurpose
--ore-accordion-unitBase size unit
--ore-accordion-borderTrigger and content border color
--ore-accordion-backgroundExpanded content background color
--ore-accordion-foregroundTrigger text and icon color
--ore-accordion-content-foregroundExpanded content text color
--ore-accordion-trigger-backgroundIdle summary background
--ore-accordion-trigger-highlightIdle summary highlight
--ore-accordion-trigger-shadowIdle summary shadow
--ore-accordion-trigger-cornerIdle summary corner
--ore-accordion-trigger-background-hoverHover summary background
--ore-accordion-trigger-highlight-hoverHover summary highlight
--ore-accordion-trigger-corner-hoverHover summary corner
--ore-accordion-trigger-background-pressedPressed summary background
--ore-accordion-trigger-highlight-pressedPressed summary highlight
--ore-accordion-trigger-shadow-pressedPressed summary shadow
--ore-accordion-trigger-corner-pressedPressed 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.

On this page