Skip to main content

Starwind UI v3.0 is now available! Migration guide

Installation

Usage

multiple

Use type="multiple" to allow multiple accordion items to be open at the same time.

defaultValue

Use the defaultValue prop to set the default open item. If the prop is not provided, no items will be open by default.

API Reference

Styled Component API

These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.

Accordion

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
defaultValue string | string[]
Description
Sets the initial value when the component is uncontrolled.
Classification
Primitive override
Primitive prop
accordion.Root.defaultValue

Accordion Item

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
value Required string
Description
Controls or identifies the component value.
Classification
Wrapper prop

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Accordion.

Primitive API

Runtime API

Accordion primitive
createAccordion from @starwind-ui/runtime/accordion

Changelog

v2.0.3

  • Named the generated aggregate default export so React and Astro tooling can identify the installed component cleanly.

v2.0.2

  • Applied divider borders only to non-last Accordion items in the generated Astro and React components.

v2.0.1

  • Single accordions now default to collapsible.

v2.0.0

  • Rebuilt Accordion on Starwind Runtime for disclosure state and keyboard behavior;
  • See the Accordion Primitive for the underlying unstyled anatomy and behavior API.

v1.3.5

  • Refactor tailwind variants functions into separate variants.ts file

v1.3.3

  • Add starwind:init event listener to enable initialization of additional Accordions loaded after an initial page load, such as when using server islands
  • Update the opening animation so that it does not play on initial accordion load

v1.3.2

  • add named slot “icon” to AccordionTrigger to enable easy icon swapping

v1.3.1

  • simplified default styling to enable easier custom styling

v1.3.0

  • style and focus state updates

v1.2.0

  • Add a data-slot attribute to all components to enable global styling updates

v1.1.0

  • tailwind-variants now implemented. This uses tailwind-merge under the hood to merge Tailwind classes without style conflicts, allowing you to override any existing classes using the class prop.