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

Alert

beta

The Alert component provides a flexible UI element for displaying alert messages. It is composed of several subcomponents such as Alert.Root, Alert.Title, Alert.Description, and Alert.Link to offer a structured and customizable interface.

Usage

import { Alert } from '@harnessio/ui/components'
//...
return (
<Alert.Root
theme="info"
expandable
dismissible
>
<Alert.Title>My Alert</Alert.Title>
<Alert.Description>This is the description of the alert</Alert.Description>
<Alert.Link to="/someplace">
Learn more
</Alert.Link>
</Alert.Root>
)

Anatomy

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

<Alert.Root>
<Alert.Title />
<Alert.Description />
<Alert.Link />
</Alert.Root>

API Reference

Root

The Root component serves as the main container for all alert elements.

PropRequiredDefaultType
childrentrueReactNode
classNamefalsestring
themefalse'info' | 'warning' | 'danger'
dismissiblefalseboolean
expandablefalseboolean
onDismissfalse() => void

Title

The Title component displays the title of the alert.

<Alert.Title>Alert Title</Alert.Title>
PropRequiredDefaultType
childrentrueReactNode
classNamefalsestring

Description

The Description component displays the description of the alert.

<Alert.Description>This is the alert description.</Alert.Description>
PropRequiredDefaultType
childrentrueReactNode
classNamefalsestring

The Link component is used to create a link within the alert.

<Alert.Link to="/path">Learn more</Alert.Link>
PropRequiredDefaultType
totruestring
childrentrueReactNode
classNamefalsestring
externalfalsefalseboolean
asChildfalsefalseboolean