Banner
FreeOne 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.
npx shadcn@latest add https://pixilui.com/r/banner.jsonPreview
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>
);
}When to use
Use it when
- 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.
Use something else when
- 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.
Installation
npx shadcn@latest add https://pixilui.com/r/banner.jsonAdds banner.tsx with button.tsx, agent-avatar.tsx and notice.tsx, and installs clsx and tailwind-merge. The URL works in any app with a components.json, with no registry to add first.
"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} />;
});
It uses Button, Agent avatar and Notice: add them the same way. Then npm i clsx tailwind-merge, and add the foundation once per app, as in Installation.
Usage
import { Banner } from "@/components/pixilui/banner";
<Banner
title={title}
onClose={onClose}
onClosed={onClosed}
/>Spans its container at 52 tall (48 in quiet) and takes its corners; the line keeps one line with an ellipsis.
API reference
titleRequiredReactNode–The lead of the line, in ink at medium.toneBannerTone–The status color: neutral (default), done, warn, fail (an alert), wait or run; the glyph takes its hue.iconReactNode–A bare glyph in the tone's hue (18).agentAgentAvatarState–Or the agent as the subject: the locked agent avatar in this state (it plays its own change when the state changes).agentNamestring–The agent's name, for screen readers.subReactNode–The rest of the line, in grey, with an ellipsis when it runs out of room.workingboolean–Working: the lead shimmers, aria-busy.actionsBannerAction[]–At most one action, from the locked buttons (sm).closableboolean–A close, only when it can go.openboolean–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.iconKeystring–Changes when the icon changes, so a new glyph swaps in (default: the tone).closeLabelstring–The close's accessible name (Dismiss).closeIconReactNode–The close's glyph (the lock's: the static Hugeicons cancel).Also takes every native <div> attribute except title, and a ref.
Keyboard
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.