# Annunciator

A panel of alarm lamps from a control room. A new alarm flashes until someone acknowledges it, then stays lit while its condition lasts; one that clears unseen keeps flashing, so nothing passes unnoticed. For agent, build and system alerts.

- Category: Instruments
- Docs: https://bevel-ui.vercel.app/components/annunciator
- Import from: `@/components/ui/annunciator`

## Install

```bash
npx shadcn@latest add @bevel/annunciator
```

npm dependencies (installed by the CLI): `@base-ui/react`, `cn`.

## Anatomy

```tsx
<Annunciator aria-label="Agent alerts">
  <AnnunciatorPanel>
    <AnnunciatorTile id="budget" active={overBudget} tone="red">Over budget</AnnunciatorTile>
    <AnnunciatorTile id="tests" active={failing}>Tests failing</AnnunciatorTile>
  </AnnunciatorPanel>
  <AnnunciatorAcknowledge />
</Annunciator>
```

## Parts

| Part | Renders | Description |
| --- | --- | --- |
| `Annunciator` | div (group) | Latches alarms and announces each one as it comes in and clears. Give it an aria-label. |
| `AnnunciatorPanel` | div | The grid of lamp windows. |
| `AnnunciatorTile` | button | id, active, tone red, amber, green or white. Named with its state (“Over budget: new alarm”); pressing it acknowledges it. With reduced motion, a dot marks it new instead of flashing. |
| `AnnunciatorAcknowledge` | Button | “Acknowledge 2”: acknowledges every unseen alarm. Disabled, but focusable, when there are none. |

## Example: An agent's alert panel

Conditions come and go on their own. Acknowledge them one by one, or all at once.

```tsx
"use client"

import * as React from "react"
import {
  Annunciator,
  AnnunciatorAcknowledge,
  AnnunciatorPanel,
  AnnunciatorTile,
} from "@/components/ui/annunciator"

const conditions = [
  { id: "budget", label: "Over budget", tone: "red" },
  { id: "tests", label: "Tests failing", tone: "amber" },
  { id: "rate", label: "Rate limited", tone: "amber" },
  { id: "context", label: "Context full", tone: "amber" },
  { id: "approval", label: "Needs approval", tone: "white" },
  { id: "deploy", label: "Deploy live", tone: "green" },
] as const

/** An agent's alert panel. Conditions come and go; each new one flashes until you acknowledge it. */
export function AnnunciatorAgent() {
  const [active, setActive] = React.useState<Record<string, boolean>>({ tests: true })

  React.useEffect(() => {
    const timer = setInterval(() => {
      const c = conditions[Math.floor(Math.random() * conditions.length)]!
      setActive((a) => ({ ...a, [c.id]: !a[c.id] }))
    }, 2600)
    return () => clearInterval(timer)
  }, [])

  return (
    <Annunciator aria-label="Agent alerts">
      <AnnunciatorPanel>
        {conditions.map((c) => (
          <AnnunciatorTile key={c.id} id={c.id} tone={c.tone} active={!!active[c.id]}>
            {c.label}
          </AnnunciatorTile>
        ))}
      </AnnunciatorPanel>
      <AnnunciatorAcknowledge />
    </Annunciator>
  )
}
```
