# Announcement pill

> "New: …" above your headline that opens into the news: the pill itself grows into a changelog card.

Every launch hero has a little "New" pill, and it’s usually a plain link. This one rewards curiosity. Point at it and the arrow nudges on while a second phrase folds open. Click it and the pill itself grows into a card with the details: its size and corners ease from pill to card while the line cross-fades into the content. Close it and it folds back into the pill. Without card content it’s simply a link.

## Install

```bash
npx shadcn@latest add https://hairlineui.com/r/announcement-pill.json
```

Needs React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

- npm: none
- Hairline UI components it needs (the CLI installs them too): none
- Docs and live preview: https://hairlineui.com/ui/announcement-pill
- Registry item (source): https://hairlineui.com/r/announcement-pill.json

## Usage

```tsx
import { AnnouncementPill } from "@/components/announcement-pill";

<AnnouncementPill more="Read the changelog" card={<Changelog />}>
  Agents can now hand off
</AnnouncementPill>
```

## In a hero

Put it above the headline; pass a card for the details, or an href to link out.

```tsx
import { AnnouncementPill } from "@/components/announcement-pill";

export function Hero({ latest }: { latest: { title: string; items: { date: string; title: string }[] } }) {
  return (
    <section className="flex flex-col items-center pt-24 text-center">
      <AnnouncementPill
        more="Read the changelog"
        card={
          <div className="p-5">
            <p className="text-xs text-muted-foreground">What’s new</p>
            <ol className="mt-3 space-y-3">
              {latest.items.map((item) => (
                <li key={item.title} className="text-sm">
                  <span className="mr-2 font-mono text-xs text-muted-foreground">{item.date}</span>
                  {item.title}
                </li>
              ))}
            </ol>
            <a href="/changelog" className="mt-4 inline-block text-sm underline underline-offset-4">See all updates</a>
          </div>
        }
      >
        {latest.title}
      </AnnouncementPill>
      <h1 className="mt-6 text-6xl font-medium tracking-tight">Ship the launch page tonight.</h1>
    </section>
  );
}
```

## Props

| Prop | Type | Default | 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. |

## States

- **rest**: A tinted badge and one line in a hairline 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.

## What it handles

The “New” pill above a hero is normally a link, so people leave the page to find out what is new. This one carries the news itself and opens in place.

- **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.

## Replaces

a popover, a news modal, hover hint code, open and close focus handling, a changelog link

## Where it fits

- **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.

## Notes

- 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.

License: MIT (https://hairlineui.com/license#components)
