Tac UIv1.1.2

Alert

Displays a short, important message to attract the user's attention without interrupting their task.

Import

tsx
import { Alert, AlertTitle, AlertDescription } from '@tac-ui/web';

Playground

Interactively configure the Alert props below.

tsx
<Alert variant="default">
  <AlertTitle>Alert Title</AlertTitle>
  <AlertDescription>This is an alert with the default variant.</AlertDescription>
</Alert>

Default

The default alert uses neutral surface colors and is suitable for general informational messages.

tsx
<Alert>
  <AlertTitle>Heads up!</AlertTitle>
  <AlertDescription>You can add components to your app using the CLI.</AlertDescription>
</Alert>

Variants

Use semantic variants — success, error, warning, info — to communicate the nature of the message. Each variant applies a matching background tint and border color from the design token system.

tsx
<Alert variant="success">
  <AlertTitle>Success</AlertTitle>
  <AlertDescription>Your changes have been saved successfully.</AlertDescription>
</Alert>
<Alert variant="error">
  <AlertTitle>Error</AlertTitle>
  <AlertDescription>Something went wrong. Please try again.</AlertDescription>
</Alert>
<Alert variant="warning">
  <AlertTitle>Warning</AlertTitle>
  <AlertDescription>Your session is about to expire in 5 minutes.</AlertDescription>
</Alert>
<Alert variant="info">
  <AlertTitle>Info</AlertTitle>
  <AlertDescription>A new software update is available for download.</AlertDescription>
</Alert>

Glass

The glass variant applies a frosted-glass backdrop, suitable for alerts rendered over rich backgrounds or images.

tsx
<Alert variant="glass">
  <AlertTitle>Glassmorphism</AlertTitle>
  <AlertDescription>This alert blends into layered UI surfaces.</AlertDescription>
</Alert>

With Icon

Pass any React node to the <code>icon</code> prop to display a contextual icon on the left of the alert content. The icon color is automatically matched to the variant.

tsx
<Alert variant="success" icon={<CheckCircle />}>
  <AlertTitle>Payment confirmed</AlertTitle>
  <AlertDescription>Your payment of $49.00 was processed successfully.</AlertDescription>
</Alert>
<Alert variant="error" icon={<XCircle />}>
  <AlertTitle>Upload failed</AlertTitle>
  <AlertDescription>The file exceeds the 10 MB size limit.</AlertDescription>
</Alert>
<Alert variant="warning" icon={<AlertTriangle />}>
  <AlertTitle>Low storage</AlertTitle>
  <AlertDescription>You have less than 500 MB of storage remaining.</AlertDescription>
</Alert>
<Alert variant="info" icon={<Info />}>
  <AlertTitle>Maintenance window</AlertTitle>
  <AlertDescription>Scheduled maintenance on Sunday from 2–4 AM UTC.</AlertDescription>
</Alert>

Dismissible

Set <code>dismissible</code> to show a close button. When clicked, the alert animates out and the optional <code>onDismiss</code> callback is called, allowing you to sync dismissal state externally.

tsx
<Alert variant="info" icon={<Info />} dismissible onDismiss={() => console.log('dismissed')}>
  <AlertTitle>New feature available</AlertTitle>
  <AlertDescription>Try the new dashboard layout in your account settings.</AlertDescription>
</Alert>
<Alert variant="success" icon={<CheckCircle />} dismissible>
  <AlertTitle>Profile updated</AlertTitle>
  <AlertDescription>Your profile information has been saved.</AlertDescription>
</Alert>

API Reference

Alert props:

PropTypeDefaultDescription
variant"default" | "success" | "error" | "warning" | "info" | "glass""default"Visual style variant of the alert.
iconReact.ReactNode-Optional icon displayed to the left of the alert content. Icon color is matched to the variant.
dismissiblebooleanfalseWhen true, shows a close button that animates the alert out when clicked.
onDismiss() => void-Called when the dismiss button is clicked, after the animation starts.
classNamestring-Additional CSS class names.
childrenReact.ReactNode-Content of the alert. Compose with AlertTitle and AlertDescription.

AlertTitle and AlertDescription accept standard HTML heading/paragraph props and className.