# Alert

Inline notices with icons, actions and optional dismissal.

Access: free. Category: Feedback. Kind: primitive.

## When to use

- Use it when a product interface needs inline notices with icons, actions and optional dismissal.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose status-badge instead when animated labels for pending, success and error states is the actual interface need, rather than alert.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Alert

```sh
npx shadcn@latest add https://tidalui.com/r/alert.json
```

Stylesheets: `components/ui/tidal.css`, `components/ui/alert.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/alert.css";
import{TidalAlert}from"./components/ui/alert";
export default()=><div className="tidal-scope"><TidalAlert title={"Demo"}/></div>;
```

## Structured props

- `TidalAlert.title: ReactNode`: Required title value accepted by this exported component.
- `TidalAlert.action?: ReactNode`: Optional action value accepted by this exported component.
- `TidalAlert.announce?: "off" | "assertive" | "polite" | undefined` (default "off"): Static notices are silent. Opt into one live message for a meaningful update.
- `TidalAlert.dismissDisabled?: boolean | undefined` (default false): Optional dismiss disabled value accepted by this exported component.
- `TidalAlert.dismissLabel?: string | undefined` (default "Dismiss notice"): Optional dismiss label value accepted by this exported component.
- `TidalAlert.icon?: ReactNode`: Optional icon value accepted by this exported component.
- `TidalAlert.onDismiss?: MouseEventHandler<HTMLButtonElement> | undefined`: The consumer removes the notice and owns any necessary focus return.
- `TidalAlert.tone?: TidalAlertTone | undefined` (default "neutral"): Optional tone value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/alert.tsx) | [Manifest](https://tidalui.com/examples/alert.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { useEffect, useRef, useState } from "react";

import { Check, FileText, Image, Plus, RotateCcw, X } from "lucide-react";

import { TidalAlert, TidalAlertAction, type TidalAlertTone } from "./components/ui/alert";

import "./components/ui/alert.css";



const tidalExampleStyles = ".tidal-scope .alert-specimen{width:100%;max-width:610px;padding:28px;border:1px solid var(--t-border);border-radius:var(--t-radius-card);background:var(--t-subtle);color:var(--t-ink);box-shadow:0 20px 40px -30px #00000038}.tidal-scope .alert-demo-checks{padding:0 4px 20px}\n.tidal-scope .alert-demo-heading{display:flex;align-items:center;gap:9px;margin-bottom:14px;font-size:13px}.tidal-scope .alert-demo-heading strong{font-weight:600;letter-spacing:-.2px}.tidal-scope .alert-demo-heading>span{margin-inline-start:auto;color:var(--t-muted);font-size:11px;letter-spacing:1px}\n.tidal-scope .alert-demo-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 0;border-top:1px solid var(--t-border);font-size:12px}.tidal-scope .alert-demo-row>span:last-child{display:flex;align-items:center;gap:6px;color:var(--t-muted);font-size:11px}.tidal-scope .alert-demo-state-icon{position:relative;width:15px;height:15px}.tidal-scope .alert-demo-state-icon>svg{position:absolute;inset:0;opacity:0;transform:rotate(-20deg) scale(.7);transition:opacity 180ms,transform 340ms var(--t-ease-spring)}.tidal-scope .alert-demo-state-icon>svg[data-active=true]{opacity:1;transform:none}\n.tidal-scope .alert-demo-image-reveal{display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows 420ms var(--t-ease-out),opacity 260ms}.tidal-scope .alert-demo-image-reveal[data-open=true]{grid-template-rows:1fr;opacity:1}.tidal-scope .alert-demo-image-reveal>div{min-height:0;overflow:hidden}.tidal-scope .alert-demo-image{display:flex;align-items:center;gap:15px;padding:14px;border:1px solid var(--t-border);border-radius:11px;background:var(--t-surface);margin-top:8px}.tidal-scope .alert-demo-image>span{display:flex;align-items:center;gap:7px;font-size:11px;color:var(--t-muted)}\n.tidal-scope .alert-demo-image-art{position:relative;overflow:hidden;flex:none;width:70px;height:44px;border-radius:6px;background:var(--t-ink);color:var(--t-surface)}.tidal-scope .alert-demo-image-art>span{position:absolute;width:65px;height:65px;border:1px solid currentColor;border-radius:50%;left:14px;top:9px;opacity:.7;transform:translateY(16px);transition:transform 500ms var(--t-ease-out)}.tidal-scope .alert-demo-image-art>span:nth-child(2){left:28px;top:-6px;transition-delay:50ms}.tidal-scope .alert-demo-image-art>span:nth-child(3){left:43px;top:-20px;transition-delay:100ms}.tidal-scope .alert-demo-image-reveal[data-open=true] .alert-demo-image-art>span{transform:none}\n.tidal-scope .alert-demo-controls{display:flex;justify-content:space-between;gap:10px;margin-top:15px}.tidal-scope .alert-demo-controls>button{display:inline-flex;align-items:center;justify-content:center;gap:7px;min-width:44px;min-height:44px;padding:8px 12px;border:1px solid var(--t-border);border-radius:var(--t-radius-control);background:var(--t-surface);color:var(--t-ink);font:inherit;font-size:11px;cursor:pointer;transition:background 140ms,transform 140ms var(--t-ease-out)}.tidal-scope .alert-demo-controls>button:hover:not(:disabled){background:var(--t-wash)}.tidal-scope .alert-demo-controls>button:active:not(:disabled){transform:scale(.98)}.tidal-scope .alert-demo-controls>button:disabled{opacity:.5;cursor:not-allowed}.tidal-scope .alert-demo-note{font-size:11px;line-height:1.6;margin:17px 0 0;color:var(--t-muted)}.tidal-scope .alert-demo-dismissed{padding:24px;border:1px dashed var(--t-border);border-radius:16px;font-size:13px;color:var(--t-muted)}\n@keyframes tidal-alert-demo-message{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}\n@media(prefers-reduced-motion:no-preference){.tidal-scope .alert-demo-message{display:block;animation:tidal-alert-demo-message 300ms var(--t-ease-out)}}\n@media(max-width:480px){.tidal-scope .alert-specimen{padding:18px}.tidal-scope .alert-demo-heading{flex-wrap:wrap}.tidal-scope .alert-demo-heading>span{font-size:11px}.tidal-scope .alert-specimen .tidal-alert{padding:16px;gap:10px;grid-template-columns:32px minmax(0,1fr) 44px}.tidal-scope .alert-specimen .tidal-alert-icon{width:32px;height:32px;border-radius:9px}.tidal-scope .alert-specimen .tidal-alert-icon>svg{left:5px;top:5px}.tidal-scope .alert-specimen .tidal-alert-title{padding-inline-start:42px}}\n@media(prefers-reduced-motion:reduce){.tidal-scope .alert-demo-state-icon>svg,.tidal-scope .alert-demo-image-art>span,.tidal-scope .alert-demo-controls>button:active:not(:disabled){transform:none}}";

type Phase = "missing" | "preparing" | "error" | "ready";

const messages: Record<Phase, { title: string; description: string; tone: TidalAlertTone }> = {
  missing: { title: "Social preview is missing", description: "Add a sample image to complete this page’s preview.", tone: "warning" },
  preparing: { title: "Preparing sample image", description: "A short local simulation. No file is uploaded.", tone: "neutral" },
  error: { title: "Sample image could not be read", description: "Try again with the included sample image.", tone: "error" },
  ready: { title: "Sample preview is ready", description: "Both local checks are complete. Nothing is published.", tone: "success" },
};

export function AlertDemo() {
  const [phase, setPhase] = useState<Phase>("missing"),[visible, setVisible] = useState(true);
  const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined),restore = useRef<HTMLButtonElement>(null);
  useEffect(() => () => clearTimeout(timer.current), []);
  const message = messages[phase];
  function prepare() { clearTimeout(timer.current); setPhase("preparing"); timer.current = setTimeout(() => setPhase("ready"), 650); }
  function reset() { clearTimeout(timer.current); setPhase("missing"); setVisible(true); }
  return <div className="alert-specimen" data-phase={phase}>
    <div className="alert-demo-checks">
      <div className="alert-demo-heading"><FileText size={17} aria-hidden="true" /><strong>Northstar page</strong><span>LOCAL CHECKS</span></div>
      <div className="alert-demo-row"><span>Page metadata</span><span><Check size={15} aria-hidden="true" />Ready</span></div>
      <div className="alert-demo-row"><span>Social preview</span><span className="alert-demo-state"><span className="alert-demo-state-icon" aria-hidden="true"><Check size={15} data-active={phase === "ready"} /><X size={15} data-active={phase !== "ready"} /></span>{phase === "ready" ? "Ready" : phase === "preparing" ? "Preparing" : phase === "error" ? "Error" : "Missing"}</span></div>
      <div className="alert-demo-image-reveal" data-open={phase === "ready"} aria-hidden={phase !== "ready"}><div><div className="alert-demo-image"><div className="alert-demo-image-art" aria-hidden="true"><span /><span /><span /></div><span><Image size={15} aria-hidden="true" />Sample preview image</span></div></div></div>
    </div>
    {visible ? <TidalAlert title={message.title} tone={message.tone} announce="polite" onDismiss={() => { setVisible(false); restore.current?.focus({ preventScroll: true }); }} dismissLabel="Dismiss sample notice" action={<TidalAlertAction aria-disabled={phase === "preparing"} aria-busy={phase === "preparing"} onClick={() => { if (phase !== "preparing") phase === "ready" ? reset() : prepare(); }}>{phase === "ready" ? <RotateCcw size={15} aria-hidden="true" /> : <Plus size={15} aria-hidden="true" />}{phase === "ready" ? "Remove sample image" : phase === "preparing" ? "Preparing sample" : phase === "error" ? "Try sample again" : "Add sample image"}</TidalAlertAction>}><span key={phase} className="alert-demo-message">{message.description}</span></TidalAlert> : <div className="alert-demo-dismissed" role="status">Sample notice dismissed.</div>}
    <div className="alert-demo-controls"><button ref={restore} type="button" onClick={() => { if (!visible) setVisible(true); else { clearTimeout(timer.current); setPhase("error"); } }} disabled={phase === "preparing" && visible}>{visible ? "Show error" : "Show notice"}</button><button type="button" onClick={reset}><RotateCcw size={14} aria-hidden="true" />Reset</button></div>
    <p className="alert-demo-note">Sample checks and image. All changes stay in this preview.</p>
  </div>;
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <AlertDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

TidalAlert requires a visible title (ReactNode), with optional children for message content. tone: neutral(default), success, warning or error; icons, border treatment and text distinguish states without color. icon overrides the decorative default, or false removes it. action accepts caller-owned nodes. Use className='tidal-alert-action' on a native link to receive the supported44px action styling; arbitrary custom nodes remain caller-styled. TidalAlertAction forwards native button attributes/events/ref and defaults to type=button, with explicit type=submit for forms. Root forwards native div attributes/style/dir/className/ref. announce defaults off for static notices; polite adds role=status/aria-live=polite and assertive adds role=alert/aria-live=assertive to the message only, with aria-atomic=true. Actions and dismissal stay outside this live message. Use assertive only for urgent new feedback, and avoid competing live regions. Initial page-load messages are not guaranteed announcements. Nonempty visible title and meaningful description/action labels are consumer responsibilities. Optional onDismiss receives the native button click; dismissLabel defaults Dismiss notice and dismissDisabled disables that button. The consumer owns visibility, validation, action effects and focus return after removing a focused notice. The component never steals focus, disappears on a timer, stores data or performs a request. Native Action/Dismiss controls are44px, wrap long text, retain visible contrast-safe focus, and reflect disabled state. Scoped tidal.css/alert.css provide finite entry, coordinated icon/check transitions and reduced-motion handling. No hidden state or automatic dismissal.
