···11+---
22+title: Alert
33+description: An Alert displays important information to users in a prominent way, typically used for notifications, warnings, or feedback.
44+---
55+66+import { PropDocs } from '../../../lib/PropDocs'
77+import { Example } from '../../../lib/Example'
88+import { Basic } from '../../../examples/alert/basic'
99+import { Variants } from '../../../examples/alert/variants'
1010+import { TitleOnly } from '../../../examples/alert/title-only'
1111+import { WithAction } from '../../../examples/alert/with-action'
1212+import { WithActionTitleOnly } from '../../../examples/alert/with-action-title-only'
1313+import { Dismissible } from '../../../examples/alert/dismissible'
1414+import { TitleOnlyDismissible } from '../../../examples/alert/title-only-dismissible'
1515+import { CustomIcon } from '../../../examples/alert/custom-icon'
1616+1717+<Example src={Basic} />
1818+1919+## Installation
2020+2121+Run the following command to add the alert component to your project.
2222+2323+```bash
2424+pnpm hip install alert
2525+```
2626+2727+## Props
2828+2929+<PropDocs components={["Alert"]} />
3030+3131+## Features
3232+3333+### Variants
3434+3535+Alerts can be one of the following variants:
3636+3737+- `info` (default) - For informational messages
3838+- `success` - For successful operations or positive feedback
3939+- `warning` - For warnings that need attention
4040+- `critical` - For errors or critical issues
4141+4242+Each variant has a distinct color scheme and default icon.
4343+4444+<Example src={Variants} />
4545+4646+### Title Only
4747+4848+Alerts can be displayed with just a title, without a description.
4949+5050+<Example src={TitleOnly} />
5151+5252+### With Actions
5353+5454+Alerts can include action elements such as buttons. On smaller screens, the action area moves to a separate row below the content.
5555+5656+<Example src={WithAction} />
5757+5858+Title-only alerts can also include actions.
5959+6060+<Example src={WithActionTitleOnly} />
6161+6262+### Dismissible
6363+6464+Alerts can be made dismissible by providing an `onDismiss` callback. When `onDismiss` is provided, a close button will automatically be displayed.
6565+6666+<Example src={Dismissible} />
6767+6868+Title-only alerts can also be dismissible.
6969+7070+<Example src={TitleOnlyDismissible} />
7171+7272+### Custom Icons
7373+7474+You can provide a custom icon to override the default icon for each variant.
7575+7676+<Example src={CustomIcon} />
7777+7878+## Related Components
7979+8080+- [Badge](/docs/components/badge) - For small status indicators
8181+- [Toast](/docs/components/status/toast) - For temporary notifications
8282+- [AlertDialog](/docs/components/alert-dialog) - For critical actions and confirmations
8383+
+10
apps/docs/src/examples/alert/basic.tsx
···11+import { Alert } from "@/components/alert";
22+33+export function Basic() {
44+ return (
55+ <Alert title="Alert Title">
66+ This is a basic alert with a title and description.
77+ </Alert>
88+ );
99+}
1010+
+15
apps/docs/src/examples/alert/custom-icon.tsx
···11+import { Lightbulb } from "lucide-react";
22+import { Alert } from "@/components/alert";
33+44+export function CustomIcon() {
55+ return (
66+ <Alert
77+ variant="info"
88+ title="Custom Icon"
99+ icon={<Lightbulb />}
1010+ >
1111+ This alert uses a custom icon instead of the default icon.
1212+ </Alert>
1313+ );
1414+}
1515+
+23
apps/docs/src/examples/alert/dismissible.tsx
···11+"use client";
22+33+import { useState } from "react";
44+import { Alert } from "@/components/alert";
55+66+export function Dismissible() {
77+ const [isVisible, setIsVisible] = useState(true);
88+99+ if (!isVisible) {
1010+ return null;
1111+ }
1212+1313+ return (
1414+ <Alert
1515+ variant="info"
1616+ title="Dismissible Alert"
1717+ onDismiss={() => setIsVisible(false)}
1818+ >
1919+ This alert can be dismissed by clicking the close button.
2020+ </Alert>
2121+ );
2222+}
2323+