Alert
interlace-ui/alertFreeComponent
A bordered in-page message with `role="alert"`, an optional leading icon, a title and a description, in two tones (default and destructive).
Install it
npx shadcn@latest add https://ds.interlace.tools/r/alert.jsonSource
1import * as React from 'react';23// @interlace/alert v1.1.0 — Interlace design system.4// Docs, props and live preview: https://ds.interlace.tools/c/alert5// What changed since: https://ds.interlace.tools/c/alert#history6// Generated banner — keep it, the upgrade diff reads this version.78/**9 * @interlace/ui — Alert10 *11 * A bordered in-page message with `role="alert"`, an optional leading icon, a12 * title and a description, in two tones (default and destructive).13 *14 * The icon column exists only when a direct `<svg>` child does — `has-[>svg]`15 * switches the grid from `[0_1fr]` to two columns — so a text-only alert has16 * no empty gutter.17 *18 * ## Anatomy19 *20 * Alert (div — role=alert, CSS grid)21 * ├─ <svg> (optional, any icon; sizing is imposed here)22 * ├─ AlertTitle (div — col-start-2)23 * └─ AlertDescription (div — col-start-2)24 *25 * The icon is styled by descendant selectors on the root (`[&>svg]:size-4`,26 * `translate-y-0.5`, `text-current`), so it must be a DIRECT child — an icon27 * wrapped in a span gets neither the sizing nor the grid column.28 *29 * ## Two things to know before reaching for it30 *31 * - `role="alert"` is unconditional. It is an assertive live region, so this32 * component is for a message that APPEARS in response to something. One33 * rendered with the page competes with the page's own announcement.34 * - `AlertTitle` is `line-clamp-1`. A title longer than one line is cut, not35 * wrapped; the sentence belongs in `AlertDescription`.36 *37 * | Rule | Concept | Where in this file |38 * | ---- | -------------------------------- | ----------------------------------------------------------- |39 * | R4 | Extends native el | `React.ComponentProps<'div'>` on all three parts |40 * | R6 | data-slot per part | alert / alert-title / alert-description |41 * | R7 | cva + cn + ...rest | `cn(alertVariants({ variant }), className)` + `{...props}` |42 * | R8 | Enum for tone | `variant = default | destructive` — no `isError` boolean |43 * | R19 | Tokens only | `bg-card`, `text-card-foreground`, `text-destructive` |44 * | R25 | Server component | No hooks → no `'use client'` |45// … truncated
More from interlace-ui
All 140 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| A11y Startera11y-starter | interlace-ui | Components | Free | no deps | |
| Accordionaccordion | interlace-ui | Components | Free | no deps | |
| Alert Dialogalert-dialog | interlace-ui | Components | Free | no deps | |
| Animated Gradient Textanimated-gradient-text | interlace-ui | Components | Free | no deps | |
| Animated Grid Patternanimated-grid-pattern | interlace-ui | Components | Free | no deps | |
| Animated Listanimated-list | interlace-ui | Components | Free | no deps | |
| Article Cardarticle-card | interlace-ui | Components | Free | no deps | |
| Article List Gridarticle-list-grid | interlace-ui | Components | Free | no deps |
