No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

Accordion

Accordions are commonly used to reduce the need to scroll when presenting multiple sections of content on a single page.

usage
import { Accordion, Item, Header, Content, AccordionContext, useAccordionContext } from "@sharegate/orbit-ui";
sources
Github

Guidelines

Accessibility

  • The accordion header that shows and hides the content must be an heading element.
  • The heading element should have a level that is appropriate for the information architecture of the page. You can choose the appropriate level by selecting one of Orbit heading accordingly.

Usage

We recommend specifying a unique key prop for every <Item>. If you choose to omit the key prop, a key matching the <Item> position will be generated. For example, "0" would be the generated key for the first <Item> of an <Accordion> component without keys.

Default

A default accordion.

Editable example

Icon

An accordion item can contain icons.

Editable example

Multiple

An accordion can allow multiple items to be expanded at once.

Editable example

Dynamic items

An accordion items can be rendered dynamically.

Editable example

Disabled

An accordion item can be disabled.

Editable example

Bordered

An accordion can be contained by borders.

Editable example

Accordion context

The expandedKeys can be retrieved from useAccordionContext.

Editable example

Controlled

The expandedKeys state can be handled in controlled mode.

Editable example

API

Accordion

usage
import { Accordion } from "@sharegate/orbit-ui";
NameDescriptionDefault
autoFocus
Whether or not the first focusable accordion item should autoFocus on render.
numberfalsetrue
-
children*
React children
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-
defaultExpandedKeys
The initial value of expandedKeys when uncontrolled.
string[]
-
expandedKeys
A controlled set of expanded item keys.
string[]
-
expansionMode
The type of expansion that is allowed.
"multiple""single"
"single"
onExpansionChange
Called when an accordion item is toggled.
(event: SyntheticEvent<Element, Event>, keys: string[]) => void
eventReact's original event.
keysThe keys of the expanded items.
-
variant
The accordion style to use.
"borderless""bordered"
"borderless"

Item

usage
import { Item } from "@sharegate/orbit-ui";
NameDescriptionDefault
children
React children.
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-
key
A unique key to identify the item.
string
-

Content

usage
import { Content } from "@sharegate/orbit-ui";
NameDescriptionDefault
children*
React children.
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-
slot
Slot to render into.
string
-

AccordionHeader

usage
import { AccordionHeader } from "@sharegate/orbit-ui";
slots
"icon", "text"
NameDescriptionDefault
children*
React children.
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-
disabled
Whether or not the tab is disabled.
falsetrue
-
header*
The header item props.
{ key: string; }
-
headingProps
Additional props to render on the heading wrapper element.
Partial<Omit<OmitInternalProps<InnerHeadingProps, never>, "ref"> & RefAttributes<any>>
-
headingType*
The heading component type.
string | ComponentClass<any, any> | FunctionComponent<any>
-

AccordionPanel

usage
import { AccordionPanel } from "@sharegate/orbit-ui";
NameDescriptionDefault
children*
React children.
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-
panel
The panel item props
{ key: string; }
-