{
  "schemaVersion": 1,
  "target": "react",
  "name": "alert",
  "version": "0.1.0",
  "category": "feedback",
  "title": "Alert",
  "description": "An inline callout with neutral, info, success, warning, and danger tones, a status glyph, a title, a description, and optional actions and dismiss.",
  "tags": [
    "callout",
    "banner",
    "notice",
    "status",
    "message",
    "error",
    "warning"
  ],
  "requires": {
    "projectTypes": [
      "next",
      "vite-react"
    ],
    "styling": "tailwind-v4"
  },
  "npmDependencies": {},
  "registryDependencies": [],
  "docsPath": "/components/alert",
  "props": [
    {
      "name": "tone",
      "type": "\"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\"",
      "default": "\"neutral\"",
      "description": "Status hue of the full hairline border, the soft tint, and the glyph. Neutral has no tint."
    },
    {
      "name": "icon",
      "type": "ReactNode",
      "description": "Replaces the tone's glyph. Pass null to hide the icon."
    },
    {
      "name": "live",
      "type": "\"off\" | \"polite\" | \"assertive\"",
      "default": "\"off\"",
      "description": "off is a static callout read in page order; polite renders role=\"status\"; assertive renders role=\"alert\". Use the live modes only for alerts that appear in response to an action."
    },
    {
      "name": "onDismiss",
      "type": "() => void",
      "description": "Shows a dismiss button in the top right corner that calls this. Remove the alert in your handler."
    },
    {
      "name": "dismissLabel",
      "type": "string",
      "default": "\"Dismiss\"",
      "description": "Accessible name of the dismiss button."
    },
    {
      "name": "AlertAction variant",
      "type": "\"secondary\" | \"ghost\"",
      "default": "\"secondary\"",
      "description": "A 28px hairline button or a quieter text button for actions inside AlertActions."
    }
  ],
  "accessibility": [
    "Static by default: no live role, so callouts on page load are read in order instead of interrupting.",
    "live=\"polite\" renders role=\"status\" and live=\"assertive\" renders role=\"alert\" for alerts that appear after an action.",
    "The tone is spoken as a visually hidden prefix (Warning:, Error:, Success:, Info:), so the meaning does not depend on color or the glyph, which is aria-hidden.",
    "The tone also reads in shape: a triangle for warning, a check, an x, and an i in a circle.",
    "The dismiss button is a native button with an accessible name and a visible focus ring; actions are native buttons with focus rings.",
    "Light-mode text stays zinc-950 and zinc-600 on the 6 to 7 percent tints, which keeps body text above WCAG AA."
  ],
  "states": [
    "neutral",
    "info",
    "success",
    "warning",
    "danger",
    "dismissible",
    "with actions"
  ],
  "files": [
    {
      "path": "ui/alert.tsx",
      "content": "import type { ComponentProps, ReactNode } from \"react\";\n\nfunction cx(...classes: (string | false | null | undefined)[]) {\n  return classes.filter(Boolean).join(\" \");\n}\n\nexport type AlertTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\";\n\n// A full hairline in the status hue and a soft tint of the same hue. No side stripe:\n// the tone reads from the glyph shape and the title first, color second.\nconst tones: Record<AlertTone, { box: string; glyph: string; label: string }> = {\n  neutral: {\n    box: \"border-zinc-950/10 bg-white dark:border-white/12 dark:bg-black\",\n    glyph: \"text-zinc-500 dark:text-zinc-400\",\n    label: \"Note\",\n  },\n  info: {\n    box: \"border-sky-500/30 bg-sky-500/[0.06] dark:border-sky-400/25 dark:bg-sky-400/[0.06]\",\n    glyph: \"text-sky-600 dark:text-sky-400\",\n    label: \"Info\",\n  },\n  success: {\n    box: \"border-emerald-500/30 bg-emerald-500/[0.06] dark:border-emerald-400/25 dark:bg-emerald-400/[0.06]\",\n    glyph: \"text-emerald-600 dark:text-emerald-400\",\n    label: \"Success\",\n  },\n  warning: {\n    box: \"border-amber-500/35 bg-amber-500/[0.07] dark:border-amber-400/25 dark:bg-amber-400/[0.06]\",\n    glyph: \"text-amber-600 dark:text-amber-400\",\n    label: \"Warning\",\n  },\n  danger: {\n    box: \"border-red-500/30 bg-red-500/[0.06] dark:border-red-400/25 dark:bg-red-400/[0.06]\",\n    glyph: \"text-red-600 dark:text-red-400\",\n    label: \"Error\",\n  },\n};\n\nexport interface AlertProps extends Omit<ComponentProps<\"div\">, \"title\"> {\n  /** Status hue of the border, tint, and glyph. Neutral has no tint. */\n  tone?: AlertTone;\n  /** Replaces the tone's glyph. Pass `null` to show no icon. */\n  icon?: ReactNode;\n  /**\n   * How a screen reader hears it. `off` (default) is a static callout read in page order;\n   * `polite` makes it a status region; `assertive` makes it an alert that interrupts.\n   * Use the live modes only for alerts that appear in response to something.\n   */\n  live?: \"off\" | \"polite\" | \"assertive\";\n  /** Shows a dismiss button that calls this. Remove the alert in your handler. */\n  onDismiss?: () => void;\n  /** Accessible name of the dismiss button. */\n  dismissLabel?: string;\n}\n\n/**\n * An inline callout. Compose it with `AlertTitle`, `AlertDescription`, and `AlertActions`.\n *\n * ```tsx\n * <Alert tone=\"warning\">\n *   <AlertTitle>Your API key expires in 3 days</AlertTitle>\n *   <AlertDescription>Rotate it to keep deployments running.</AlertDescription>\n * </Alert>\n * ```\n */\nexport function Alert({\n  tone = \"neutral\",\n  icon,\n  live = \"off\",\n  onDismiss,\n  dismissLabel = \"Dismiss\",\n  className,\n  children,\n  ...props\n}: AlertProps) {\n  const config = tones[tone];\n  const glyph = icon === undefined ? <AlertGlyph tone={tone} /> : icon;\n\n  return (\n    <div\n      role={live === \"assertive\" ? \"alert\" : live === \"polite\" ? \"status\" : undefined}\n      data-tone={tone}\n      className={cx(\n        \"relative flex w-full items-start gap-3 rounded-xl border px-4 py-3.5 text-sm leading-5 text-zinc-950 dark:text-white\",\n        \"transition-[background-color,border-color] duration-200 ease-out motion-reduce:transition-none\",\n        config.box,\n        onDismiss && \"pr-11\",\n        className,\n      )}\n      {...props}\n    >\n      {glyph ? (\n        <span\n          aria-hidden=\"true\"\n          className={cx(\"mt-0.5 flex size-4 shrink-0 items-center justify-center [&_svg]:size-4\", config.glyph)}\n        >\n          {glyph}\n        </span>\n      ) : null}\n      {/* The tone is also spoken, so the meaning does not depend on the color or glyph. */}\n      {tone !== \"neutral\" ? <span className=\"sr-only\">{config.label}: </span> : null}\n      <div className=\"grid min-w-0 flex-1 gap-1\">{children}</div>\n      {onDismiss ? (\n        <button\n          type=\"button\"\n          aria-label={dismissLabel}\n          onClick={onDismiss}\n          className={cx(\n            \"absolute top-2.5 right-2.5 inline-flex size-7 items-center justify-center rounded-md text-zinc-500\",\n            \"transition-colors duration-150 ease-out motion-reduce:transition-none\",\n            \"hover:bg-zinc-950/[0.05] hover:text-zinc-950 dark:text-zinc-400 dark:hover:bg-white/[0.08] dark:hover:text-white\",\n            \"focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-sky-500\",\n          )}\n        >\n          <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" className=\"size-3.5\">\n            <path d=\"M4.5 4.5l7 7M11.5 4.5l-7 7\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n          </svg>\n        </button>\n      ) : null}\n    </div>\n  );\n}\n\n/** The alert's one-line summary. Renders a `<p>`; it is not a heading, so it never breaks the page outline. */\nexport function AlertTitle({ className, ...props }: ComponentProps<\"p\">) {\n  return <p className={cx(\"font-medium text-pretty text-zinc-950 dark:text-white\", className)} {...props} />;\n}\n\n/** Supporting text under the title. Renders a `<div>` so it can hold paragraphs, lists, or links. */\nexport function AlertDescription({ className, ...props }: ComponentProps<\"div\">) {\n  return (\n    <div\n      className={cx(\n        \"text-pretty text-zinc-600 dark:text-zinc-400\",\n        \"[&_a]:font-medium [&_a]:text-zinc-950 [&_a]:underline [&_a]:decoration-zinc-950/25 [&_a]:underline-offset-[3px] [&_a:hover]:decoration-zinc-950/60\",\n        \"dark:[&_a]:text-white dark:[&_a]:decoration-white/30 dark:[&_a:hover]:decoration-white/70\",\n        \"[&_code]:font-mono [&_code]:text-[0.92em] [&_code]:text-zinc-950 dark:[&_code]:text-white\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\n/** A row of actions under the text. Holds `AlertAction` buttons or your own `Button`s. */\nexport function AlertActions({ className, ...props }: ComponentProps<\"div\">) {\n  return <div className={cx(\"mt-2 flex flex-wrap items-center gap-2\", className)} {...props} />;\n}\n\nexport interface AlertActionProps extends ComponentProps<\"button\"> {\n  /** `secondary` draws a hairline button; `ghost` is text only, for a quieter second action. */\n  variant?: \"secondary\" | \"ghost\";\n}\n\n/** A compact 28px action sized for the alert. `type` defaults to `button`. */\nexport function AlertAction({ variant = \"secondary\", type = \"button\", className, ...props }: AlertActionProps) {\n  return (\n    <button\n      type={type}\n      className={cx(\n        \"inline-flex h-7 items-center gap-1.5 rounded-lg px-2.5 text-xs font-medium whitespace-nowrap select-none\",\n        \"transition-[background-color,border-color,color,scale] duration-150 ease-out active:duration-100 motion-reduce:transition-none\",\n        \"motion-safe:active:scale-[0.97]\",\n        \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-500\",\n        \"disabled:pointer-events-none disabled:opacity-45\",\n        variant === \"secondary\"\n          ? cx(\n              \"border border-zinc-950/12 bg-white text-zinc-950 hover:border-zinc-950/20 hover:bg-zinc-50\",\n              \"dark:border-white/15 dark:bg-black dark:text-white dark:hover:border-white/25 dark:hover:bg-white/[0.06]\",\n            )\n          : \"text-zinc-600 hover:bg-zinc-950/[0.05] hover:text-zinc-950 dark:text-zinc-400 dark:hover:bg-white/[0.07] dark:hover:text-white\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\n/** The tone's default 16px glyph: the same circle shapes the toasts and status glyphs use. */\nexport function AlertGlyph({ tone }: { tone: AlertTone }) {\n  const stroke = { stroke: \"currentColor\", strokeWidth: 1.5, strokeLinecap: \"round\", strokeLinejoin: \"round\" } as const;\n  return (\n    <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\">\n      {tone === \"warning\" ? (\n        <>\n          <path d=\"M7.13 2.5a1 1 0 0 1 1.74 0l5.2 9.1a1 1 0 0 1-.87 1.5H2.8a1 1 0 0 1-.87-1.5Z\" {...stroke} />\n          <path d=\"M8 6.25v2.75\" {...stroke} />\n          <circle cx=\"8\" cy=\"11\" r=\"0.75\" fill=\"currentColor\" />\n        </>\n      ) : (\n        <>\n          <circle cx=\"8\" cy=\"8\" r=\"6.25\" {...stroke} />\n          {tone === \"success\" ? (\n            <path d=\"m5.5 8.25 1.75 1.75 3.25-3.75\" {...stroke} />\n          ) : tone === \"danger\" ? (\n            <path d=\"m6 6 4 4m0-4-4 4\" {...stroke} />\n          ) : (\n            <>\n              <path d=\"M8 7.5v3.25\" {...stroke} />\n              <circle cx=\"8\" cy=\"5.25\" r=\"0.75\" fill=\"currentColor\" />\n            </>\n          )}\n        </>\n      )}\n    </svg>\n  );\n}\n"
    }
  ],
  "example": {
    "content": "\"use client\";\n\nimport { useState } from \"react\";\nimport { Alert, AlertAction, AlertActions, AlertDescription, AlertTitle } from \"@/components/shaken/ui/alert\";\n\nexport default function AlertExample() {\n  const [showNotice, setShowNotice] = useState(true);\n\n  return (\n    <div className=\"grid w-full max-w-lg gap-3\">\n      <Alert tone=\"warning\">\n        <AlertTitle>Your API key expires in 3 days</AlertTitle>\n        <AlertDescription>\n          Deployments that use <code>sk_live_4f2a</code> will stop on November 17. Rotate the key and update your\n          environment variables.\n        </AlertDescription>\n        <AlertActions>\n          <AlertAction>Rotate key</AlertAction>\n          <AlertAction variant=\"ghost\">Remind me tomorrow</AlertAction>\n        </AlertActions>\n      </Alert>\n\n      <Alert tone=\"danger\">\n        <AlertTitle>Payment failed</AlertTitle>\n        <AlertDescription>\n          The card ending in 4242 was declined. <a href=\"#billing\">Update your billing details</a> to keep the Team plan.\n        </AlertDescription>\n      </Alert>\n\n      <Alert tone=\"success\">\n        <AlertTitle>Domain verified</AlertTitle>\n        <AlertDescription>docs.acme.dev now serves traffic over HTTPS.</AlertDescription>\n      </Alert>\n\n      {showNotice ? (\n        <Alert tone=\"info\" onDismiss={() => setShowNotice(false)} dismissLabel=\"Dismiss maintenance notice\">\n          <AlertTitle>Scheduled maintenance on Sunday, 02:00 to 03:00 UTC</AlertTitle>\n          <AlertDescription>Builds queue during the window and start automatically afterwards.</AlertDescription>\n        </Alert>\n      ) : (\n        <button\n          type=\"button\"\n          onClick={() => setShowNotice(true)}\n          className=\"justify-self-start rounded-md text-xs text-zinc-500 underline underline-offset-[3px] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-500\"\n        >\n          Show the maintenance notice again\n        </button>\n      )}\n\n      <Alert>\n        <AlertTitle>Preview deployments are public by default</AlertTitle>\n        <AlertDescription>Turn on password protection in project settings to restrict them.</AlertDescription>\n      </Alert>\n    </div>\n  );\n}\n"
  }
}
