Collapse

Collapse props

NameTypeDescription
activePanelKeystring | string[] | nullActive panel/panels keys
childrenReact.ReactNodeCollapsible items
isAccordionbooleanOnly one panel can be open in the uncontrolled mode if enabled
onSelect
CustomEventHandler<SelectEvent> === interface SelectEvent { component: { value: string | string[] | null, }, }
Panel select handler
themePartialGlobalDefaultTheme[ typeof COMPONENTS_NAMESPACES.collapse ]...

Collapse.Heading props

NameTypeDescription
childrenReact.ReactNodeChildren
iconRenderCustomRender<HeadingProps, { }, IconProps>Heading icon customizator
onClickReact.MouseEventHandler<HTMLDivElement>Click handler
wrapperRenderCustomRender<HeadingProps, { }, HeadingWrapperProps>Wrapper element customizator
_[className]
[x: string]: unknown
E.g.: _w-48 adds a css class w-48 to the component's outer wrapper.

Collapse.Body props

NameTypeDescription
childrenReact.ReactNodeChildren
isLoadingbooleanLoading state
onCloseCustomEventHandler<BodyClickCustomEvent>Panel close handler
onCloseByClickCustomEventHandler<BodyClickCustomEvent>Panel close handler triggered by a click
onOpenCustomEventHandler<BodyClickCustomEvent>Panel open handler
transitionstring

CSS transition format.

height 250ms cubic-bezier(.4, 0, .2, 1) by default

wrapperRenderCustomRender<HeadingProps, { }, HeadingWrapperProps>Wrapper element customizator
_[className]
[x: string]: unknown
E.g.: _w-48 adds a css class w-48 to the component's outer wrapper.

Collapse.Panel props

NameTypeDescription
childrenReact.ReactNodeChildren
isDisabledbooleanIn case you want to disable the panel
namestring...
panelKeystringA key to put into Collapse activePanelKey prop
wrapperRenderCustomRender<PanelProps, { isClicked: boolean }, PanelWrapperProps>Wrapper element customizator
_[className]
[x: string]: unknown
E.g.: _w-48 adds a css class w-48 to the component's outer wrapper.

() => {
  const [activeKey, setActiveKey] = React.useState(['2']);

  return (
    <L.Collapse
      activePanelKey={activeKey}
      onSelect={(event) => setActiveKey(event.component.value)}
    >
      <L.Collapse.Panel panelKey="1">
        <L.Collapse.Heading><b>First panel heading</b></L.Collapse.Heading>
        <L.Collapse.Body>
          <L.Div _p-4>
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh
            <br />
            euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
          </L.Div>
        </L.Collapse.Body>
      </L.Collapse.Panel>

      <L.Collapse.Panel
        panelKey="2"
      >
        <L.Collapse.Heading><b>Second panel heading</b></L.Collapse.Heading>
        <L.Collapse.Body>
          <L.Div _p-4>
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh
            <br />
            euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
          </L.Div>
        </L.Collapse.Body>
      </L.Collapse.Panel>
    </L.Collapse>
  );
}