• EnglishEspañol日本語한국어Português
  • Log inStart now

CollapsibleLayoutItem

Child element of the <Layout> component used only for left or right side areas, with the ability to collapse them. Can be used as a "controlled" component (i.e. by passing the collapsed boolean prop), or by default it will manage its own (un)collapsed state. It takes a triggerType prop, allowing you to choose the inbuilt triggers – the side area will include a button which allows the user to collapse the area and then expand it again – or custom, meaning you are using your own UI element elsewhere to control the (un)collapsed state.

See the <Layout> docs for example usage.

The <Layout> component only supports one child of each type, shared between <CollapsibleLayoutItem> and <LayoutItem>.

Usage

import { CollapsibleLayoutItem } from 'nr1'

Props

children

REQUIRED
node

Content to display inside the child item.

className

string

Appends class names to the component.

collapsed

boolean

Set this prop to control the collapsed state of the split from your own external control.

defaultCollapsed

boolean

Not actually a "default" – this only sets the initial collapsed state of the split. Defaults to false.

onChangeCollapsed

function

This function will be called whenever the user clicks the default trigger button to collapse or expand the split. If you are controlling the state of the component, use this to set the value of the collapsed prop.

function (
event: React.MouseEvent,
collapsed: boolean
)

sizeType

enum

Determines the width of the layout item. We recommend you use the small size for navigation purposes (ex. sidebars) and the medium size for showing contextualized information (ex. activity stream).Size type only works on SPLIT_LEFT and SPLIT_RIGHT items.

<One of

CollapsibleLayoutItem.SIZE_TYPE.MEDIUM, CollapsibleLayoutItem.SIZE_TYPE.SMALL,

>

style

object

Inline style for custom styling.

testId

string

Adds a data-test-id attribute. Use it to target the component in unit and E2E tests.For a test id to be valid, prefix it with your nerdpack id, followed up by a dot.For example, my-nerdpack.some-element.

Note: You might not see data-test-id attributes as they are removed from the DOM, to debug them pass a e2e-test query parameter to the URL.

triggerType

REQUIRED
enum

Choose whether to use the inbuilt trigger buttons to allow collapsing/expanding the split, or your own custom ones (e.g. a switch outside the layout or a custom button inside the layout). It is strongly recommended not to mix these patterns, i.e. do not choose CollapsibleLayoutItem.TRIGGER_TYPE.INBUILT and also provide your own custom triggers.

<One of

CollapsibleLayoutItem.TRIGGER_TYPE.CUSTOM, CollapsibleLayoutItem.TRIGGER_TYPE.INBUILT,

>

type

REQUIRED
enum

Type can be: Split left — Render as a fixed area on the left of the layout. Split right — Render as a fixed area on the right of the layout.

<One of

CollapsibleLayoutItem.TYPE.SPLIT_LEFT, CollapsibleLayoutItem.TYPE.SPLIT_RIGHT,

>
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.