Alert

free

Alert keeps important feedback visible near the workflow it affects.

Subscription updated
The new billing owner will receive future invoices and renewal notices.
import Alert from '@/components/ui/alert';

export default function UsageDemo() {
  return (

Installation

Add this component with the NateUI CLI.

npx nateui@latest add Alert

Examples

Basic

Review the details before continuing.
import Alert from '@/components/ui/alert';

export default function BasicDemo() {
  return (

Types

A new export is ready to download.
Your changes were saved successfully.
This plan is close to its seat limit.
This action cannot be undone.
import Alert from '@/components/ui/alert';

const alerts = [
  {

Icons

The alert can render without an icon.
Add `showIcon` to include the status icon.
import Alert from '@/components/ui/alert';

export default function IconDemo() {
  return (

Custom Icon

Automation complete
The workflow ran successfully with the custom status icon.
import { PiSparkle } from 'react-icons/pi'
import Alert from '@/components/ui/alert';

export default function CustomIconDemo() {

Title

Seats almost full
Upgrade the workspace or remove unused members before inviting more people.
import Alert from '@/components/ui/alert';

export default function TitleDemo() {
  return (

Closable

Invite sent. Close this alert when you are done reviewing it.
import Alert from '@/components/ui/alert';

export default function ClosableDemo() {
  return (

API

Alert accepts the props below plus motion-enabled props for the root div.

PropDescriptionTypeDefault
childrenMain alert message content.ReactNode-
classNameClass names applied to the root alert.string-
closableShows the close control and lets the alert fade when clicked.booleanfalse
customCloseReplaces the default close button content.ReactNode | string-
customIconReplaces the status icon when showIcon is enabled.ReactNode | string-
contentClassClass names applied to the inner content row.string-
durationDelay before the timeout helper calls onClose. Pass 0 to disable the scheduled callback.number3000
onCloseCalled when the close control is clicked, and by the timeout helper when enabled.AlertCloseHandler-
refRef forwarded to the root alert element.Ref<HTMLDivElement>-
showIconDisplays the status icon for the resolved variant.booleanfalse
titleOptional title rendered above the message.ReactNode | stringnull
triggerByToastToast integration flag accepted by the component prop type.boolean-
variantStatus palette used by the alert. Invalid values fall back to warning.AlertVariant'warning'
...motionDivPropsMotion-enabled props for the root alert element, excluding type and children.NativeAlertMotionProps-

Types

type AlertVariant = 'success' | 'warning' | 'destructive' | 'info';
type AlertCloseHandler = (event?: MouseEvent<HTMLDivElement>) => void;
type NativeAlertMotionProps = Omit<HTMLMotionProps<'div'>, 'type' | 'children'>;