useExpandableSection
is a React hook for managing ExpandableSection
's state.
Type: boolean
optional (default: undefined
)
The default value of ExpandableSection
's expanded
prop
ExpandableSection
's expanded
prop
ExpandableSection
's onChange
prop
Type: (expanded: boolean) => void
The setExpanded
utility function lets you set expanded
directly.
import ExpandableSection from '@awsui/components-react/expandable-section';
import { useExpandableSection } from 'use-awsui';
import { Header } from './components';
export default function MyExpandableSection() {
const [expanded, handleChange] = useExpandableSection({
defaultExpanded: false,
});
return (
<ExpandableSection
expanded={expanded}
header={<Header />}
onChange={handleChange}
variant="container"
>
my expandable section
</ExpandableSection>
);
}