Alert

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/cli@latest add Alert

Examples

Basic

import Alert from '@/components/ui/alert';

export default function BasicDemo() {
  return (

Types

import Alert from '@/components/ui/alert';

const alerts = [
  {

Icons

import Alert from '@/components/ui/alert';

export default function IconDemo() {
  return (

Custom Icon

import { PiSparkle } from 'react-icons/pi'
import Alert from '@/components/ui/alert';

export default function CustomIconDemo() {

Title

import Alert from '@/components/ui/alert';

export default function TitleDemo() {
  return (

Closable

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'>;