Collapsible

An avatar component with a fallback for initials.

import { Collapsible } from '@backstage/canon';

<Collapsible.Root>
  <Collapsible.Trigger render={(props, state) => (
    <Button {...props}>
      {state.open ? 'Close Panel' : 'Open Panel'}
    </Button>
  )} />
  <Collapsible.Panel>Your content</Collapsible.Panel>
</Collapsible.Root>

API reference

Collapsible.Root

Groups all parts of the collapsible. Renders a <div> element.

PropTypeDefaultResponsive
defaultOpen
boolean
falseNo
open
boolean
-No
onOpenChange
(open) => void
-No
render
React.ReactElement(props, state) => React.ReactElement
-No
className
string
-No
style
CSSProperties
-No

Collapsible.Trigger

The trigger by default render a simple unstyled button. Because menus can be rendered in different ways, we recommend using the render prop to render a custom trigger.

<Collapsible.Trigger render={props => <Button {...props} />} />
PropTypeDefaultResponsive
render
React.ReactElement(props, state) => React.ReactElement
-No
className
string
-No
style
CSSProperties
-No

Collapsible.Panel

A panel with the collapsible contents. Renders a <div> element.

PropTypeDefaultResponsive
hiddenUntilFound
boolean
falseNo
keepMounted
boolean
falseNo
render
React.ReactElement(props, state) => React.ReactElement
-No
className
string
-No
style
CSSProperties
-No

Examples

Open the panel by default by setting the defaultOpen prop to true.

It's the edge of the world and all of Western civilization

The sun may rise in the East, at least it settled in a final location

It's understood that Hollywood sells Californication

<Collapsible.Root defaultOpen>
  <Collapsible.Trigger render={(props, state) => (
    <Button {...props}>
      {state.open ? 'Close Panel' : 'Open Panel'}
    </Button>
  )} />
  <Collapsible.Panel>
    <Box>
      <Text>It's the edge of the world and all of Western civilization</Text>
      <Text>The sun may rise in the East, at least it settled in a final location</Text>
      <Text>It's understood that Hollywood sells Californication</Text>
    </Box>
  </Collapsible.Panel>
</Collapsible.Root>