Hone UI
Components

Alert

A short message about something important.

Alert shows a message with a severity icon. It can carry a title, an action or a close button.

import Alert from '@hone-ui/react/Alert';
import AlertTitle from '@hone-ui/react/AlertTitle';

Examples

<Alert severity="success">Saved.</Alert>
<Alert severity="info" variant="outlined">A new version is out.</Alert>
<Alert severity="error" variant="filled">The upload failed.</Alert>
<Alert severity="warning">
  <AlertTitle>Warning</AlertTitle>
  Your session ends in 5 minutes.
</Alert>

Alert props

PropTypeDefaultDescription
severity'success', 'info', 'warning', 'error''success'Picks the icon and the default color.
variant'standard', 'filled', 'outlined''standard'A tint, a solid fill or a border.
colora severity or any palette keyseverityThe color.
iconReactNode, falseReplaces the icon. false hides it.
iconMapping{ success?, info?, warning?, error? }Icons per severity.
onClose(event) => voidShows a close button.
closeTextstring'Close'The close button's label.
actionReactNodeContent at the end. Replaces the close button.
rolestring'alert'The ARIA role.
slotProps.closeButton, slotProps.closeIconobjectProps for the close button and its icon.
sx, className, style, ref, childrenStandard.

AlertTitle takes children, sx, className, style and ref. It is a Server Component.

Notes

  • Filled alerts use the color's main shade with its contrast text in light and dark mode.
  • In the Material look, light filled warning and info keep the default palette's 3:1 contrast.
  • components, componentsProps and slots are not supported.

Accessibility

role="alert" makes screen readers announce the message when it appears. Use role="status" for messages that can wait.

On this page