Properties
These properties can send along with the Accordion.Provider
or Accordion.Group
. It will affect every nested Accordion
.
Property | Type | Description |
---|---|---|
id | string | (optional) A unique id that will be used on the button element. If you use remember_state , an id is required. |
title | string | (optional) A title as a string or React element. It will be used as the button text. |
expanded | boolean | (optional) If set to true the accordion will be expanded as its initial state. |
expanded_ssr | boolean | (optional) If set to true the accordion will be expanded during SSR. Can be potentially useful for SEO, although it will disturb client hydration, where React expects the same state. But that's mainly a technical aspect to consider. |
remember_state | boolean | (optional) If set to true , it will remember a changed state initiated by the user. It requires a unique id . It will store the state in the local storage. |
flush_remembered_state | boolean | (optional) If set to true , the saved (remembered) state will be removed and the initial component state will be used and set. |
no_animation | boolean | (optional) If set to true , the open and close animation will be omitted. |
variant | outlined filled plain | (optional) Defines the used styling. Outlined , filled , or plain (no styling). Defaults to outlined . |
icon | React.ReactNode | (optional) Will replace the chevron icon. The icon will still rotate (by CSS). You can use an object to use two different icons, one for the closed state and one for the expanded state { closed, expanded } . |
icon_position | string | (optional) Will set the placement of the icon. Defaults to left . |
icon_size | string | (optional) Define a different icon size. Defaults to medium (1.5rem). |
left_component | React.ReactNode | (optional) Will add a React element on the left side of the title , inside AccordionHeaderContainer . |
prerender | boolean | (optional) If set to true the content will be present, even the accordion is not expanded. Can be useful for assistive technology or SEO. |
prevent_rerender | boolean | (optional) If set to true the accordion component will not re-render its content – can be useful for components you don't have control of storing the temporary state during an interaction. |
prevent_rerender_conditional | boolean | (optional) Use this prop together with prevent_rerender – and if it is set to true , the accordion component will re-render if the children are a new React element and do not match the previous one anymore. |
single_container | boolean | (optional) If set to true , a group of accordions will be wrapped to a sidebar looking menu for medium and larger screens. |
element | React.ReactNode | (optional) Gives you the option to replace the used button element. Provide a React element, including a string (HTML element). Defaults to a div with all the needed accessibility features included. |
heading | boolean | (optional) If set to true , level 2 (h2) will be used. You can provide your own HTML heading (h3 ), or provide a heading_level property. |
heading_level | boolean | (optional) If heading is set to true , you can provide a numeric value to define a different heading level. Defaults to 2 . |
disabled | boolean | (optional) If set to true , the accordion button will be disabled (dimmed). |
skeleton | boolean | (optional) If set to true , an overlaying skeleton with animation will be shown. |
contentRef | function | (optional) Send along a custom React Ref for .dnb-accordion__content . |
collapseAllHandleRef | React.MutableRefObject<() => void> | (optional) Ref handle to collapse all expanded accordions. Send in a ref and use .current() to collapse all accordions. Default: undefined . |
space | string object | (optional) Spacing properties like top or bottom are supported. |
Accordion.Provider and Accordion.Group Properties
Property | Type | Description |
---|---|---|
group | string | (optional) Define a unique id, it will be used to 'group' several accordions into one. |
allow_close_all | boolean | (optional) If set to true , the group of accordions will allow all to close. |
expandBehaviour | single multiple | (deprecated) Use expandBehavior instead. |
expandBehavior | single multiple | (optional) Determines how many accordions can be expanded at once. Defaults to single . |
expanded_id | string | (optional) Define an id of a nested accordion that will get expanded. |
space | string object | (optional) Spacing properties like top or bottom are supported. |