Skip to content
Haze UI

Popover

Button that opens a floating panel next to it, built on the native popover attribute with no script.

pnpm dlx shadcn@latest add @haze/popover
Open preview in a new tab
Liveno JavaScript

When to use

  • Extra controls or details that should not take page space until asked for
  • Filter and display settings attached to a toolbar button
  • Content that may hold form controls, unlike a tooltip

When not to use

  • A plain list of links or actions; use dropdown-menu
  • A task that must block the page until finished; use dialog
  • A one-line hint on hover; use tooltip

Installation

Add the Haze registry to components.json once, then install Popover with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/popover
First 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

PropTypeDefaultDescription
id*string–Unique on the page. Links the trigger to the panel and names the CSS anchor.
labelstring"Open"Visible trigger text when the trigger slot is not used.
ariaLabelstring–Accessible name for an icon-only trigger.
variant"primary" | "secondary" | "outline" | "ghost""outline"Trigger button style.
size"sm" | "md" | "lg""md"Trigger button size.
align"start" | "end""start"Trigger edge the panel lines up with.
side"bottom" | "top""bottom"Preferred side; it flips when there is no room.
classstring–Panel classes, for example a width.
trigger slotslot–Custom trigger content, such as an icon and text.
default slot*slot–Panel content.

Keyboard interactions

EnterSpace
Open or close the panel from the trigger
Escape
Close the panel and return focus to the trigger
Tab
Move from the trigger into the open panel

Accessibility

  • The panel scales and fades in over 150 ms and out again; reduced-motion users get no animation.
  • The browser handles Escape, click-outside closing, the expanded state on the button and returning focus to it.
  • Focus stays on the trigger when the panel opens; the next Tab moves into the panel.
  • Before Firefox 147 and Safari 26 there is no CSS anchor positioning, so the panel opens centered over a dimmed backdrop instead.

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 "Popover" with `npx shadcn@latest add @haze/popover`. 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 Popover from "@/components/haze/ui/popover.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/popover.md

  • Customize with real content

    Adapt the Haze popover ui for our product. Replace the demo values of these props with our real content: id, label, ariaLabel, variant, size, align, side, class, trigger slot, default slot. Keep the layout, the heading level rules and these accessibility details: The panel scales and fades in over 150 ms and out again; reduced-motion users get no animation. The browser handles Escape, click-outside closing, the expanded state on the button and returning focus to it. Focus stays on the trigger when the panel opens; the next Tab moves into the panel. Before Firefox 147 and Safari 26 there is no CSS anchor positioning, so the panel opens centered over a dimmed backdrop instead. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using popover, check it fits: use it when extra controls or details that should not take page space until asked for; filter and display settings attached to a toolbar button; content that may hold form controls, unlike a tooltip. Avoid it when a plain list of links or actions; use dropdown-menu; a task that must block the page until finished; use dialog; a one-line hint on hover; use tooltip. Alternatives: @haze/dropdown-menu, @haze/dialog, @haze/tooltip.

Dependencies

  • @haze/button
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog