# Banner

One line across the top of the app or a panel for something that affects all of it: a runs limit, a paused agent, news. A bare icon or the agent, the lead in ink and the rest in grey, one action, a close only when it can go.

Tier: free. Type: component. Category: feedback. Tags: agent, billing, motion.

## Install

```bash
npx shadcn@latest add https://pixilui.com/r/banner.json
```

One-time setup: add the registry to `components.json`:

```json
{
  "registries": {
    "@pixilui": "https://pixilui.com/r/{name}.json"
  }
}
```

Files: `components/pixilui/banner.tsx`.

## Preview

Live preview: https://pixilui.com/components/banner

Knobs:

- `banner`: `a limit`, `the agent paused`, `news you can close`

Signature: The paused agent's banner turns in place as Stripe reconnects: the agent avatar plays from stopped to done while the line blurs to Stripe is back.

Styles: `lively` (default), `quiet`, set with `data-style` on <html>. The item reads the style through the foundation; it needs no prop. Standalone files: lively https://pixilui.com/r/standalone/banner.tsx, quiet https://pixilui.com/r/standalone/banner.quiet.tsx.

## Code

`components/pixilui/banner.tsx`

```tsx
"use client";

/*
  Banner (B13, locked 2 Dec 2026 with the notice): one line across the top of the app or a panel, for something that affects
  all of it (a limit, a paused agent, news). It takes its container's corners; a bare icon in the tone (18) or the locked
  agent avatar; the lead in ink at medium, the rest of the line in grey with an ellipsis; one action; a close only when it can
  go. A failed banner is an alert. The motion is the notice's (notice.tsx, NoticeFrame): the space opens, the content arrives
  in pieces, it turns in place, it leaves quieter and faster.
*/

import { forwardRef, type ComponentPropsWithoutRef, type ReactNode } from "react";
import type { AgentAvatarState } from "./agent-avatar";
import { NoticeFrame, type NoticeAction, type NoticeTone } from "./notice";

/** One action: go is the locked primary, secondary and soft the others. */
export type BannerAction = NoticeAction;
/** The locked status colors (a failed banner is an alert). */
export type BannerTone = NoticeTone;
export type BannerProps = Omit<ComponentPropsWithoutRef<"div">, "title" | "children"> & {
  /** The status color: neutral (default), done, warn, fail (an alert), wait or run; the glyph takes its hue. */
  tone?: BannerTone;
  /** A bare glyph in the tone's hue (18). */
  icon?: ReactNode;
  /** Or the agent as the subject: the locked agent avatar in this state (it plays its own change when the state changes). */
  agent?: AgentAvatarState;
  /** The agent's name, for screen readers. */
  agentName?: string;
  /** The lead of the line, in ink at medium. */
  title: ReactNode;
  /** The rest of the line, in grey, with an ellipsis when it runs out of room. */
  sub?: ReactNode;
  /** Working: the lead shimmers, aria-busy. */
  working?: boolean;
  /** At most one action, from the locked buttons (sm). */
  actions?: BannerAction[];
  /** A close, only when it can go. */
  closable?: boolean;
  /** Shown (default) or not: closing plays the leave, then folds the space shut. */
  open?: boolean;
  /** The close was pressed (set open to false, or remove it). */
  onClose?: () => void;
  /** After it has folded shut. */
  onClosed?: () => void;
  /** Changes when the icon changes, so a new glyph swaps in (default: the tone). */
  iconKey?: string;
  /** The close's accessible name (Dismiss). */
  closeLabel?: string;
  /** The close's glyph (the lock's: the static Hugeicons cancel). */
  closeIcon?: ReactNode;
};

/** One line across the top of what it covers: the lead (title) in ink, the rest (sub) in grey, one action, a close when it can go. */
export const Banner = forwardRef<HTMLDivElement, BannerProps>(function Banner(props, ref) {
  return <NoticeFrame ref={ref} kind="banner" {...props} />;
});
```

## Usage

When to use:

- Something that affects everything under it: a plan limit (3 of 50 runs left), an agent paused because a tool disconnected, an outage.
- News worth one line that someone can close (closable).
- An action that resolves in place: Add runs, then working, then 550 runs left.

When not to use:

- Something about one setting or card: use a notice beside it.
- News that passes on its own: use a toast.
- More than one line of explanation: use a notice.

```tsx
import { useState } from "react";
import { IconTimeout } from "@/components/pixilui/icons/timeout";
import { IconVoiceMode } from "@/components/pixilui/icons/voice-mode";
import { Banner, type BannerProps } from "@/components/pixilui/banner";

// The first option of each knob is the demo's default; the docs preview starts there.
export const knobs = {
  banner: ["a limit", "the agent paused", "news you can close"],
} as const;

const wait = (ms: number) => new Promise((r) => setTimeout(r, ms));

/** The locked page's banners across the top of a panel; an action turns the banner in place, and the close folds it away. */
export default function BannerDemo({ banner = "a limit" }: KnobValues<typeof knobs>) {
  const [state, setState] = useState<"start" | "working" | "after">("start");
  const [open, setOpen] = useState(true);
  const [key, setKey] = useState(banner);
  if (key !== banner) { setKey(banner); setState("start"); setOpen(true); }
  const go = async () => { setState("working"); await wait(1400); setState("after"); };
  const B: Record<(typeof knobs.banner)[number], BannerProps[]> = {
    "a limit": [
      { tone: "warn", icon: <IconTimeout />, title: "3 of 50 runs left this month.", sub: "The agent pauses at 50.", actions: [{ label: "Add runs", kind: "go", onClick: go }] },
      { tone: "neutral", icon: <IconTimeout />, iconKey: "timeout", title: "Adding 500 runs.", sub: "Charging the card on file.", working: true },
      { tone: "done", icon: <IconTimeout />, iconKey: "timeout", title: "550 runs left this month.", sub: "500 added to your plan.", closable: true },
    ],
    "the agent paused": [
      { tone: "fail", agent: "stopped", agentName: "Support agent", title: "The support agent is paused.", sub: "Stripe disconnected at 9:41 AM.", actions: [{ label: "Reconnect", kind: "go", onClick: go }] },
      { tone: "neutral", agent: "running", agentName: "Support agent", title: "Reconnecting Stripe.", sub: "The agent waits for it.", working: true },
      { tone: "done", agent: "done", agentName: "Support agent", title: "Stripe is back.", sub: "The agent picked up 4 waiting refunds.", closable: true },
    ],
    "news you can close": [{ tone: "neutral", icon: <IconVoiceMode />, title: "Voice agents are here.", sub: "Answer calls with the same agent.", actions: [{ label: "Try it", kind: "secondary" }], closable: true }],
  };
  const list = B[banner];
  const now = list[state === "start" ? 0 : state === "working" ? 1 : 2] ?? list[0]!;
  return (
    <div className="w-full max-w-2xl overflow-hidden rounded-panel bg-surface elevation-raised">
      <Banner key={banner} {...now} open={open} onClose={() => setOpen(false)} />
      <div className="grid gap-2 p-6">
        <span className="type-label text-foreground">Runs today</span>
        <span className="type-caption text-muted">47 runs, 2 waiting on approval</span>
      </div>
    </div>
  );
}
```

## Examples

None.

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `tone` | `BannerTone` |  | The status color: neutral (default), done, warn, fail (an alert), wait or run; the glyph takes its hue. |
| `icon` | `ReactNode` |  | A bare glyph in the tone's hue (18). |
| `agent` | `AgentAvatarState` |  | Or the agent as the subject: the locked agent avatar in this state (it plays its own change when the state changes). |
| `agentName` | `string` |  | The agent's name, for screen readers. |
| `title` (required) | `ReactNode` |  | The lead of the line, in ink at medium. |
| `sub` | `ReactNode` |  | The rest of the line, in grey, with an ellipsis when it runs out of room. |
| `working` | `boolean` |  | Working: the lead shimmers, aria-busy. |
| `actions` | `BannerAction[]` |  | At most one action, from the locked buttons (sm). |
| `closable` | `boolean` |  | A close, only when it can go. |
| `open` | `boolean` |  | Shown (default) or not: closing plays the leave, then folds the space shut. |
| `onClose` | `() => void` |  | The close was pressed (set open to false, or remove it). |
| `onClosed` | `() => void` |  | After it has folded shut. |
| `iconKey` | `string` |  | Changes when the icon changes, so a new glyph swaps in (default: the tone). |
| `closeLabel` | `string` |  | The close's accessible name (Dismiss). |
| `closeIcon` | `ReactNode` |  | The close's glyph (the lock's: the static Hugeicons cancel). |

Also accepts every native `<div>` attribute except `title`, and a ref to it.

## Keyboard

- `Tab`: Reaches the action and the close.
- `Enter` + `Space`: Runs the focused action or closes it.

## Accessibility

- role status, or alert when it says something failed (tone fail); aria-busy while it works.
- The glyph is decorative and the line carries the meaning; the agent's avatar is named (agentName).
- The line ends in an ellipsis when it runs out of room; the full words stay in the text for assistive technology.

## Motion

- The notice's motion: the space folds open, then the icon, the line and the action arrive in pieces; a turn leaves and arrives in place; closing is quieter and faster, then the space folds shut.
- Reduced motion: it appears, turns and goes at once.

## Responsive

- Spans its container at 52 tall (48 in quiet) and takes its corners; the line keeps one line with an ellipsis.

## Performance

- The same few Web Animations as the notice; nothing runs while it rests.

## Notes for AI

- <Banner tone="warn" icon={<IconTimeout />} title="3 of 50 runs left this month." sub="The agent pauses at 50." actions={[{ label: "Add runs", kind: "go", onClick }]} /> as the first child of the panel it covers.
- title is the lead (ink, medium), sub the rest of the same line (grey). One action; closable only when it can go.
- agent="stopped" with agentName puts the agent avatar in place of the icon; change it to "done" and the avatar plays its own change.
- It shares Notice's frame (NoticeFrame) and props; open={false} folds it away and onClosed fires after.

## Related

- [Notice](https://pixilui.com/components/notice/markdown): A tinted panel in the content about the thing beside it: a bare icon in the tone or the agent as the subject, the title and its line, one action, and a close only when it can go, lit with a still glim at the mark.
- [Toast](https://pixilui.com/components/toast/markdown): Brief news at the corner on the locked float: a delete that waits while its red rim runs out, the agent asking one question, a run that stopped, money moved, and the everyday note, done, info, warning, error and save, in a stack that fans out.
- [Usage meter](https://pixilui.com/components/usage-meter/markdown): How much of a usage window is spent and when it resets, in the viewer's own time, turning orange with "Out by 2:40 pm" when the pace would run out before the reset.
