Announcement pill
Announcement pill
"New: …" above your headline that opens into the news: the pill itself grows into a changelog card.
Dependencies
Interaction states
- rest — A tinted badge and one line in a thin line pill.
- hover — The arrow slides 2px on and "· Read the changelog" folds open from zero width (500ms); the edge darkens a touch.
- open — The pill grows into a 360px card (420ms), centred on where the pill was; the card’s first link takes focus.
- close — Escape, the close button or a click outside folds the card back into the pill and returns focus.
Installation
Add this component with your preferred package manager.
pnpm dlx shadcn@4.21.5 add @cavemio/announcement-pillFirst install? Configure @cavemio once
Run npx shadcn@4.21.5 init if shadcn is not set up, then merge this entry into the registries field in your existing components.json. Keep your other settings and registries.
{
"registries": {
"@cavemio": "https://registry.cavemio.dev/r/cavemio-{name}.json"
}
}Where it’s used
Launch heroes
A “New: …” badge above the headline that tells people what just shipped.
Changelog teasers
Open the details in place instead of sending people to another page.
Event and webinar notices
A “Live Thursday” pill that opens into the time and a sign-up link.
Docs and app headers
A small notice for a new feature, without a full-width banner.
What it handles
- It opens into a card — The pill itself grows into a card of up to 360px, never wider than the screen, then folds back.
- Or it is a link — Without card content it is simply a link to the href you give it.
- A hover hint — A second phrase folds open on hover and on keyboard focus, so nobody misses it.
- Closes any way you expect — Escape, the close button or a click outside closes it, and focus returns to the pill.
- Focus is handled — The pill is a button with aria-expanded, and the card’s first link takes focus when it opens.
- Calm with reduced motion — The card simply appears and disappears.
Usage
Interactive local fixture. Data and async results are simulated in the preview; the caller supplies application services.
import { AnnouncementPill } from "@/components/announcement-pill";
<AnnouncementPill more="Read the changelog" card={<Changelog />}>
Agents can now hand off
</AnnouncementPill>Props
| Prop | Type | Description |
|---|---|---|
| children | ReactNode | – · The announcement line. |
| badge | string | "New" · The tinted label at the start. |
| more | string | – · A second phrase that folds open on hover or keyboard focus. |
| card / cardWidth | ReactNode / number | — / 360 · What the pill opens into, and how wide (never wider than the screen). |
| href | string | – · Without a card, the pill links here. |
Accessibility & motion
- With a card, the pill is a button with aria-expanded; the card is a labelled dialog and its first link takes focus when it opens. - Escape, the close button or a click outside closes it, and focus returns to the pill. - The hover phrase also opens on keyboard focus, so nobody misses it. - With reduced motion the card simply appears and disappears.
pnpm dlx shadcn@4.21.5 add @cavemio/announcement-pill