# Alert

Alert box with success/error/warning/info variants



<ComponentPreview base="ink" name="alert-demo" />

Installation [#installation]

<CodeTabs>
  <TabsList>
    <TabsTrigger value="cli">
      Command
    </TabsTrigger>

    <TabsTrigger value="manual">
      Manual
    </TabsTrigger>
  </TabsList>

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add @termcn/alert
    ```
  </TabsContent>

  <TabsContent value="manual">
    <Steps>
      <Step>
        Copy and paste the following code into your project.
      </Step>

      <ComponentSource base="ink" name="alert" title="components/ui/alert.tsx" />

      <Step>
        Update the import paths to match your project setup.
      </Step>
    </Steps>
  </TabsContent>
</CodeTabs>

Usage [#usage]

```tsx
import { Alert } from "@/components/ui/alert";
```

```tsx
<Alert variant="success" title="Build complete">
  Everything is ready to ship.
</Alert>
```

Examples [#examples]

Error [#error]

Use `variant="error"` to display an error alert.

<ComponentPreview base="ink" name="alert-error" />

Warning [#warning]

Use `variant="warning"` to display a warning alert.

<ComponentPreview base="ink" name="alert-warning" />

Without Border [#without-border]

Set `bordered={false}` to remove the border.

<ComponentPreview base="ink" name="alert-no-border" />

Custom Icon and Color [#custom-icon-and-color]

Override the icon and color with `icon` and `color` props.

<ComponentPreview base="ink" name="alert-custom" />

API Reference [#api-reference]

Alert [#alert]

| Prop          | Type                                                                                         | Default  |
| ------------- | -------------------------------------------------------------------------------------------- | -------- |
| `variant`     | `"success" \| "error" \| "warning" \| "info"`                                                | `"info"` |
| `title`       | `string`                                                                                     | -        |
| `children`    | `ReactNode`                                                                                  | -        |
| `icon`        | `string`                                                                                     | -        |
| `bordered`    | `boolean`                                                                                    | `true`   |
| `borderStyle` | `"single" \| "double" \| "round" \| "bold" \| "singleDouble" \| "doubleSingle" \| "classic"` | -        |
| `color`       | `string`                                                                                     | -        |
| `paddingX`    | `number`                                                                                     | `1`      |
| `paddingY`    | `number`                                                                                     | `0`      |
