Announcement pill
A small pill link with an optional leading tag and a trailing arrow, set above a hero headline to point at a release or news item.
pnpm dlx shadcn@latest add @haze/announcement-pill---
import { ArrowRight } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
import Tag from "./tag.astro";
interface Props {
/** Where the pill leads, for example a changelog entry. Optional with a demo default ("#changelog"); the whole pill is one link. */
href?: string;
/** The announcement text. It wraps on narrow screens instead of being cut off. */
text?: string;
/** Short leading tag such as "New". Pass an empty string to leave it out. */
tag?: string;
/** default: neutral pill. brand: emphasised muted pill, for the one announcement that should stand out. */
variant?: "default" | "brand";
/** Trailing arrow that nudges right on hover. Decorative. */
arrow?: boolean;
class?: string;
/** Any other anchor attribute, for example target, rel or aria-label. */
[key: string]: unknown;
}
const {
href = "#changelog",
text = "Ledgerline 4.2 adds bank rules",
tag = "New",
variant = "default",
arrow = true,
class: className,
...rest
} = Astro.props;
const variants = {
default: "border-frame bg-field text-foreground hover:border-frame-strong hover:bg-accent",
brand: "border-frame-strong bg-muted text-foreground hover:bg-accent",
};
---
<a
href={href}
class={cn(
"group inline-flex min-h-7 max-w-full min-w-0 items-center gap-2 rounded-full border py-1 text-[0.8125rem]/5 font-medium tracking-[-0.01em]",
"transition-[background-color,border-color,scale] duration-150 ease-snappy motion-reduce:transition-none active:scale-[0.97] active:duration-75 motion-reduce:active:scale-100",
"focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring",
tag ? "ps-1" : "ps-3",
arrow ? "pe-2.5" : "pe-3",
variants[variant],
className,
)}
{...rest}
>
{tag && <Tag size="sm" variant="default" appearance={variant === "brand" ? "solid" : "soft"} class="shrink-0">{tag}</Tag>}
<span class="min-w-0 text-pretty">{text}</span>
{
arrow && (
<ArrowRight
aria-hidden="true"
class="size-3.5 shrink-0 transition-[translate] duration-200 ease-snappy group-hover:translate-x-0.5 motion-reduce:transition-none motion-reduce:group-hover:translate-x-0"
/>
)
}
</a>When to use
- A hero headline needs one short pointer to a release, changelog entry or launch post above it.
- A feature or beta label should sit next to a one-line teaser that links onward.
- The pointer should stay inline with the page, not span the full width.
When not to use
- The message is a site-wide or dismissible notice across the top of the page; use banner.
- The label is only a status or count with no destination; use badge or tag.
- The action is the main call to action of the page; use button.
Installation
Add the Haze registry to components.json once, then install Announcement pill with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/announcement-pillnpx shadcn@latest add @haze/announcement-pillyarn dlx shadcn@latest add @haze/announcement-pillbunx --bun shadcn@latest add @haze/announcement-pillFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| href | string | "#changelog" | Destination of the whole pill. Always rendered as a real link. |
| text | string | "Ledgerline 4.2 adds bank rules" | Announcement text. It wraps onto a second line on narrow screens. |
| tag | string | "New" | Short leading tag. Pass an empty string to hide it. |
| variant | "default" | "brand" | "default" | Neutral pill or an emphasised muted pill with a solid tag. |
| arrow | boolean | true | Shows the trailing arrow, which nudges 2 px right on hover. |
| class | string | – | Extra classes, merged with tailwind-merge. |
| ...attributes | HTML anchor attributes | – | Passed to the <a>: target, rel, aria-label and so on. |
Keyboard interactions
- Enter
- Follow the link
Accessibility
- The whole pill is one anchor, so the tag, text and arrow read as a single link name such as "New Ledgerline 4.2 adds bank rules".
- The arrow is decorative and hidden from assistive technology; the tag text is part of the link name, so keep it meaningful.
- The pill is at least 28 px tall and has a visible focus ring. The muted fill keeps 4.5:1 text contrast.
- The arrow nudge and the press scale are switched off under prefers-reduced-motion.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI component "Announcement pill" with `npx shadcn@latest add @haze/announcement-pill`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import AnnouncementPill from "@/components/haze/ui/announcement-pill.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/announcement-pill.md
Customize with real content
Adapt the Haze announcement-pill ui for our product. Replace the demo values of these props with our real content: href, text, tag, variant, arrow, class, ...attributes. Keep the layout, the heading level rules and these accessibility details: The whole pill is one anchor, so the tag, text and arrow read as a single link name such as "New Ledgerline 4.2 adds bank rules". The arrow is decorative and hidden from assistive technology; the tag text is part of the link name, so keep it meaningful. The pill is at least 28 px tall and has a visible focus ring. The muted fill keeps 4.5:1 text contrast. The arrow nudge and the press scale are switched off under prefers-reduced-motion. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using announcement-pill, check it fits: use it when a hero headline needs one short pointer to a release, changelog entry or launch post above it.; a feature or beta label should sit next to a one-line teaser that links onward.; the pointer should stay inline with the page, not span the full width.. Avoid it when the message is a site-wide or dismissible notice across the top of the page; use banner.; the label is only a status or count with no destination; use badge or tag.; the action is the main call to action of the page; use button.. Alternatives: @haze/banner, @haze/badge, @haze/tag, @haze/button.
Dependencies
- npm: @lucide/astro
- @haze/tag
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.