Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Latest commit

 

History

History
62 lines (43 loc) · 1.23 KB

use-expandable-section.md

File metadata and controls

62 lines (43 loc) · 1.23 KB

useExpandableSection

useExpandableSection is a React hook for managing ExpandableSection's state.

Table of Contents

Props

defaultExpanded

Type: boolean optional (default: undefined)

The default value of ExpandableSection's expanded prop

State

expanded

ExpandableSection's expanded prop

handleChange

ExpandableSection's onChange prop

setExpanded

Type: (expanded: boolean) => void

The setExpanded utility function lets you set expanded directly.

Examples

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>
  );
}