Skip to content
Harness Design System Harness Design System Harness Design System

Drawer

beta

The Drawer component provides a way to display content in a panel that slides in from the edge of the screen. Supports multiple configuration options, including direction (left, right, top, bottom), size constraints, and nested drawers for building complex, multi-level interfaces.

It is composed of several subcomponents such as Drawer.Root, Drawer.Trigger, Drawer.Content, Drawer.Header, Drawer.Tagline, Drawer.Title, Drawer.Description, Drawer.Body, Drawer.Footer and Drawer.Close to offer a structured and customizable interface.

Usage

import { Drawer } from '@harnessio/ui/components'
//...
return (
<Drawer.Root
direction="left"
open={isDrawerOpen}
onOpenChange={setIsDrawerOpen}
>
<Drawer.Trigger asChild>
<Button>Open drawer</Button>
</Drawer.Trigger>
<Drawer.Content size="md" hideClose>
<Drawer.Header icon="info">
<Drawer.Tagline>Section</Drawer.Tagline>
<Drawer.Title>Title of the drawer</Drawer.Title>
<Drawer.Description>Description of the drawer</Drawer.Description>
</Drawer.Header>
<Drawer.Body className="">
Content of the drawer goes here
<Drawer.Root nested>
<Drawer.Trigger asChild>
<Button>Open Nested Drawer</Button>
</Drawer.Trigger>
<Drawer.Content>
<Drawer.Header>
<Drawer.Title>Title</Drawer.Title>
</Drawer.Header>
<Drawer.Body>
Content
</Drawer.Body>
<Drawer.Footer>
Footer
</Drawer.Footer>
</Drawer.Content>
</Drawer.Root>
</Drawer.Body>
<Drawer.Footer>
<ButtonGroup>
<Drawer.Close asChild>
<Button variant="outline">Cancel</Button>
</Drawer.Close>
<Button>Submit</Button>
</ButtonGroup>
</Drawer.Footer>
</Drawer.Content>
</Drawer.Root>
)

Anatomy

All parts of the Drawer component can be imported and composed as required.

<Drawer.Root>
<Drawer.Trigger />
<Drawer.Content>
<Drawer.Header>
<Drawer.Tagline />
<Drawer.Title />
<Drawer.Description />
</Drawer.Header>
<Drawer.Body />
<Drawer.Footer>
<Drawer.Close />
</Drawer.Footer>
</Drawer.Content>
</Drawer.Root>

Nested drawers

Nested drawers can be implemented by placing a Drawer.Root inside the parent Drawer.Content, and adding the nested prop to the nested root.

Drawer sizes

The Drawer.Content component accepts a size prop to control its width (or height, depending on direction). Supported values are: sm, md, and lg.

Drawer opening direction

The Drawer.Root component accepts a direction prop to control which side the drawer opens from. Supported values are: right, left, top, and bottom.

API Reference

Root

Contains Drawer.Trigger and Drawer.Content components.

PropRequiredDefaultType
defaultOpenfalseundefinedboolean
openfalseundefinedboolean
onOpenChangefalseundefined(open: boolean) => void
modalfalsetrueboolean
containerfalsedocument.bodyHTMLElement
directionfalseright'right' | 'left' | 'top' | 'bottom'
onAnimationEndfalseundefined(open: boolean) => void
dismissiblefalsetrueboolean
handleOnlyfalsefalseboolean
nestedfalsefalseboolean
repositionInputsfalsetrueboolean
childrentrueReactNode

Trigger

An optional button that opens the drawer.

PropRequiredDefaultType
asChildfalsefalseboolean

Close

An optional button that closes the drawer.

PropRequiredDefaultType
asChildfalsefalseboolean

Content

Contains Drawer.Header, Drawer.Body and Drawer.Footer components to be rendered in the open drawer.

PropRequiredDefaultType
sizefalsesm'sm' | 'md' | 'lg'
hideClosefalsefalseboolean
childrentrueReactNode

An optional container for the Drawer.Tagline, Drawer.Title and Drawer.Description components.

PropRequiredDefaultType
iconfalseundefinedstring
logofalseundefinedstring
childrentrueReactNode

Tagline

An optional tagline above the title.

PropRequiredDefaultType
childrentrueReactNode

Title

An optional accessible title to be announced when the drawer is opened.

PropRequiredDefaultType
asChildfalsefalseboolean

Description

An optional accessible description to be announced when the drawer is opened.

PropRequiredDefaultType
asChildfalsefalseboolean

Body

A scrollable wrapper for all content that doesn’t belong to the Drawer.Header or Drawer.Footer.

PropRequiredDefaultType
classNamefalseundefinedstring
childrentrueReactNode

An optional footer wrapper.