Alert
Static inline messaging, extracted from the mockup’s .alert (warning tone) and .banner (info tone). The background carries the tone, the body text stays --ink, and the lead-in takes the tone colour.
Interactive Preview
Section titled “Interactive Preview”React Alertlive
Svelte Alertlive
Info Your changes take effect immediately.
Attention Two groups have no owner.
Saved Settings saved successfully.
Failed System update unavailable.
Solid Alertlive
InfoYour changes take effect immediately.
AttentionTwo groups have no owner.
SavedSettings saved successfully.
FailedSystem update unavailable.
import { Alert } from "@/components/ui/alert";
export function Notifications() { return ( <div className="flex flex-col gap-3"> <Alert variant="info" title="Info">Your changes take effect immediately.</Alert> <Alert variant="warning" title="Attention">Two groups have no owner.</Alert> <Alert variant="danger" title="Failed">System update unavailable.</Alert> </div> );}<script lang="ts"> import Alert from "@/components/ui/alert.svelte";</script>
<div class="flex flex-col gap-3"> <Alert variant="info" title="Info">Your changes take effect immediately.</Alert> <Alert variant="warning" title="Attention">Two groups have no owner.</Alert> <Alert variant="danger" title="Failed">System update unavailable.</Alert></div>import { Alert } from "@/components/ui/alert";
export function Notifications() { return ( <div class="flex flex-col gap-3"> <Alert variant="info" title="Info">Your changes take effect immediately.</Alert> <Alert variant="warning" title="Attention">Two groups have no owner.</Alert> <Alert variant="danger" title="Failed">System update unavailable.</Alert> </div> );}Installation
Section titled “Installation”npx @glaceon/cli add alert --framework react # or svelte, solidInstall class merging utilities:
bun add clsx tailwind-mergeCopy the component directly into your project:
import type { HTMLAttributes, ReactNode } from "react";import { cn } from "./cn";
export type AlertVariant = "info" | "warning" | "success" | "danger";
export interface AlertProps extends HTMLAttributes<HTMLDivElement> { variant?: AlertVariant; role?: "status" | "alert" | "none"; title?: string; children?: ReactNode;}
const base = "flex gap-2.5 rounded-md p-3 text-xs text-ink";
const variants: Record<AlertVariant, string> = { info: "bg-info-bg", warning: "bg-warning-bg", success: "bg-success-bg", danger: "bg-danger-bg",};
const titles: Record<AlertVariant, string> = { info: "text-info", warning: "text-warning", success: "text-success", danger: "text-danger",};
export function Alert({ variant = "info", role = "status", title, className, children, ...props }: AlertProps) { return ( <div {...props} role={role === "none" ? undefined : role} className={cn(base, variants[variant], className)}> {title ? <strong className={cn("font-extrabold", titles[variant])}>{title}</strong> : null} <span>{children}</span> </div> );}<script lang="ts"> import type { Snippet } from "svelte"; import { cn } from "./cn";
type Variant = "info" | "warning" | "success" | "danger";
interface Props { variant?: Variant; role?: "status" | "alert" | "none"; title?: string; class?: string; children?: Snippet; }
const { variant = "info", role = "status", title, class: className, children, ...rest }: Props = $props();
const base = "flex gap-2.5 rounded-md p-3 text-xs text-ink";
const variants: Record<Variant, string> = { info: "bg-info-bg", warning: "bg-warning-bg", success: "bg-success-bg", danger: "bg-danger-bg", };
const titles: Record<Variant, string> = { info: "text-info", warning: "text-warning", success: "text-success", danger: "text-danger", };</script>
<div {...rest} role={role === "none" ? undefined : role} class={cn(base, variants[variant], className)}> {#if title} <strong class={cn("font-extrabold", titles[variant])}>{title}</strong> {/if} <span>{@render children?.()}</span></div>import type { JSX } from "solid-js";import { splitProps } from "solid-js";import { cn } from "./cn";
export type AlertVariant = "info" | "warning" | "success" | "danger";
export interface AlertProps extends JSX.HTMLAttributes<HTMLDivElement> { variant?: AlertVariant; role?: "status" | "alert" | "none"; title?: string;}
const base = "flex gap-2.5 rounded-md p-3 text-xs text-ink";
const variants: Record<AlertVariant, string> = { info: "bg-info-bg", warning: "bg-warning-bg", success: "bg-success-bg", danger: "bg-danger-bg",};
const titles: Record<AlertVariant, string> = { info: "text-info", warning: "text-warning", success: "text-success", danger: "text-danger",};
export function Alert(props: AlertProps) { const [local, rest] = splitProps(props, ["variant", "role", "title", "class", "children"]); const variant = () => local.variant ?? "info";
return ( <div {...rest} role={local.role === "none" ? undefined : (local.role ?? "status")} class={cn(base, variants[variant()], local.class)} > {local.title ? <strong class={cn("font-extrabold", titles[variant()])}>{local.title}</strong> : null} <span>{local.children}</span> </div> );}Variants
Section titled “Variants”| Variant | Background | Lead-in | Source in the mockup |
|---|---|---|---|
info |
--info-bg |
--info |
.banner |
warning |
--warning-bg |
--warning |
.alert |
success |
--success-bg |
--success |
Added, same pattern |
danger |
--danger-bg |
--danger |
Added, same pattern |
API Reference (Props)
Section titled “API Reference (Props)”| Prop | Type | Default | Description |
|---|---|---|---|
variant |
"info" | "warning" | "success" | "danger" |
"info" |
Selects the tone. |
title |
string |
undefined |
Short lead-in, rendered as tone-coloured bold text. |
role |
"status" | "alert" | "none" |
"status" |
Accessible role for live region announcements. |
class / className |
string |
undefined |
Extra classes, appended last. |
Accessibility
Section titled “Accessibility”The body text is always --ink on a tinted background, never the tone colour on its own tone, so contrast does not depend on which variant is chosen. Only the lead-in uses the tone colour, and it is bold, which carries it past the 3:1 large-text threshold. Colour is never the only signal: the lead-in text states what happened.