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

ModalDialog

beta

The ModalDialog component provides an accessible and customizable dialog overlay for displaying important content or requesting user input. It supports different sizes, themes, and can include an icon or logo in the header.

Usage

import { ModalDialog } from "@harnessio/ui/components";
// ...
return (
<ModalDialog.Root>
<ModalDialog.Trigger asChild>
<Button>Open Dialog</Button>
</ModalDialog.Trigger>
<ModalDialog.Content size="md">
<ModalDialog.Header icon="circle-plus">
<ModalDialog.Title>Dialog Title</ModalDialog.Title>
<ModalDialog.Description>Optional description text</ModalDialog.Description>
</ModalDialog.Header>
<ModalDialog.Body>
Dialog content goes here
</ModalDialog.Body>
<ModalDialog.Footer>
<ModalDialog.Close>Cancel</ModalDialog.Close>
<Button variant="primary">Confirm</Button>
</ModalDialog.Footer>
</ModalDialog.Content>
</ModalDialog.Root>
)

Sizes

The ModalDialog component supports three sizes: sm, md, and lg:

Themes

Headers can have themes default, warning and danger with matching icons:

With Logo/Icon

Headers can display a logo or an icon:

Hidden Close Button

You can hide the close button in the top-right corner using the hideClose prop:

Scrollable Content

The Body component automatically handles scrolling for long content:

Anatomy

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

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

API Reference

Root

Controls the open/close behavior of the modal.

PropRequiredDefaultType
openfalseboolean
onOpenChangefalse(open: boolean) => void
childrentrueReactNode

Content

The main content container of the dialog.

PropRequiredDefaultType
sizefalse'sm''sm' | 'md' | 'lg'
hideClosefalsefalseboolean
classNamefalsestring
childrentrueReactNode

The header section of the dialog, containing the title and optional description.

PropRequiredDefaultType
iconfalsestring
logofalsestring
themefalse'default''default' | 'warning' | 'danger'
classNamefalsestring
childrentrueReactNode

Title

The title text component for the dialog header.

PropRequiredDefaultType
classNamefalsestring
childrentrueReactNode

Description

Optional description text below the title.

PropRequiredDefaultType
classNamefalsestring
childrentrueReactNode
PropRequiredDefaultType
classNamefalsestring
childrentrueReactNode

Body

Main scrollable content area of the dialog.

PropRequiredDefaultType
classNamefalsestring
childrentrueReactNode
PropRequiredDefaultType
classNamefalsestring
childrentrueReactNode

Footer section for actions (e.g., buttons).

PropRequiredDefaultType
classNamefalsestring
childrentrueReactNode
PropRequiredDefaultType
classNamefalsestring
childrentrueReactNode

Close

Can be used inside Footer or as a standalone button to close the modal.

PropRequiredDefaultType
classNamefalsestring
childrentrueReactNode