Accordion

Component to show and hide related content from the main page.

An <Accordion> is a component that allows you to organizing content into collapsible sections. Accordions are commonly used in website and application designs to present information in a compact and organized way, allowing users to focus on the specific information they are interested in without being overwhelmed by excessive content.

Anatomy

Anatomy of accordion

Appearance

The appearance of a component can be customized using the variant and size props. These props adjust the visual style and dimensions of the component, available values are based on the active theme.

Variant
Size
The selected theme does not has any options for "size".

Some Informations

PropertyTypeDescription
variantdefault | cardThe available variants of this component.
size-The available sizes of this component.

Usage

An <Accordion> is a UI component that allows users to expand and collapse sections of content. It helps in organizing information efficiently, improving navigation, and reducing visual clutter. Common use cases include FAQs, structured data presentation, and collapsible navigation menus.

While accordions are a great tool for managing content, they are not always the best solution. In cases where users need frequent access to key information, hiding it behind an interaction can create unnecessary friction. Similarly, for long or complex content, expanding a section may lead to overwhelming amounts of text rather than improving readability. Navigation menus with only a few items may not benefit from collapsible sections, as this adds clicks rather than streamlining access. Finally, for processes requiring users to follow a specific sequence, a step-by-step layout is often more effective than collapsible sections.

Content Organization

Accordions help structure content by breaking it into collapsible sections, making navigation easier while preventing cognitive overload. They are particularly useful when dealing with large amounts of information that do not need to be viewed all at once.

Using Forms

For complex forms, accordions can group related fields into sections, reducing visual clutter and making the completion process more intuitive. This is particularly beneficial for multi-step or conditional forms where not all fields need to be shown at once.

Multiple Expanded

With the multiple expanded mode, you can collapse and hide items as needed while keeping several sections open at the same time. You can also set one or more defaultExpandedKeys. Use a multiple expanded accordion when users need to view several sections simultaneously, such as comparing information or accessing related FAQs. It works best when the content is concise and users benefit from having multiple sections open at once without losing context.

Available parking passes
Amount in euros

Controlled Accordion

A controlled Accordion can be expanded and collapsed using expandedKeys and onExpandedChange. The expandedKeys must match the id on the Accordion.Item component(s) that you wish to expand.

You have expanded: personal

Props

Accordion

allowsMultipleExpanded?
boolean;
Whether multiple items can be expanded at the same time.
children?
ReactNode |
  ((values: DisclosureGroupRenderProps & { defaultChildren: ReactNode }) =>
    ReactNode);
The children of the component. A function may be provided to alter the children based on component state.
className?
string |
  ((values: DisclosureGroupRenderProps & { defaultClassName: string }) => string);
The CSS className for the element. A function may be provided to compute the class based on component state.
defaultExpandedKeys?
Iterable<Key>;
The initial expanded keys in the group (uncontrolled).
disabled?
boolean;
Whether all items are disabled.
expandedKeys?
Iterable<Key>;
The currently expanded keys in the group (controlled).
id?
string;
The element's unique identifier. See MDN.
onExpandedChange?
(keys: Set<Key>) => any;
Handler that is called when items are expanded or collapsed.

Accordion.Item

children?
ReactNode |
  ((values: DisclosureRenderProps & { defaultChildren: ReactNode }) => ReactNode);
The children of the component. A function may be provided to alter the children based on component state.
className?
string | ((values: DisclosureRenderProps & { defaultClassName: string }) => string);
The CSS className for the element. A function may be provided to compute the class based on component state.
defaultExpanded?
boolean;
Whether the disclosure is expanded by default (uncontrolled).
disabled?
boolean;
Whether the item is disabled.
expanded?
boolean;
Whether the item is expanded (controlled).
id?
Key;
An id for the disclosure when used within a DisclosureGroup, matching the id used in expandedKeys.
onExpandedChange?
(isExpanded: boolean) => void;
Handler that is called when the disclosure's expanded state changes.
slot?
string | null;
A slot name for the component. Slots allow the component to receive props from a parent component. An explicit null value indicates that the local props completely override all props received from a parent.
Last update: 2 months ago