The expansion panel renders a header element (that is just a button) and dynamically shows content once expanded.
The header for a panel that controls the expansion state. This is really just a simple button that displays the children before an expander icon.
Reminder: Since this is a <button>
, only inline
elements should be
rendered within (so use <span>
instead of <div>
for children).
This hook is used to control the expansion of a list of panels along with providing some of the required props for each panel. This hook will provide an ordered list of:
id
, key
, expanded
, and
onExpandChange
.This hook is usually used to control a list of expansion panels, but can also control a single panel if desired.
Examples:
Single panel:
const [panels] = usePanels({ count: 1, idPrefix: "my-panel" });
// since the count is one, it'll just be a list of only one panel props
const [panelProps] = panels;
return (
<ExpansionPanel {...panelProps}>
Content within the panel...
</ExpansionPanel>
);
Multiple Panels:
const [panels, onKeyDown] = usePanels({ count: 3, idPrefix: "panel-list" });
const [panel1Props, panel2Props, panel3Props] = panels;
return (
<ExpansionList onKeyDown={onKeyDown}>
<ExpansionPanel {...panel1Props}>
Panel 1 Content...
</ExpansionPanel>
<ExpansionPanel {...panel2Props}>
Panel 2 Content...
</ExpansionPanel>
<ExpansionPanel {...panel3Props}>
Panel 3 Content...
</ExpansionPanel>
</ExpansionList>
);
Generated using TypeDoc
This component is honestly not very helpful since it does not apply any styles. It is a simple wrapper for a
<div>
that updates the props to require thechildren
andonKeyDown
props.