Popover
npx shadcn add @klarhimmel/popover @klarhimmel/buttonCopy for AIExamples
Basic
Form
Align
DetailsAbout, usage, props and more
A small floating panel next to its trigger, for extra detail or a tiny form. Built on Radix Popover.
When to use
Use for
Detail or a one-field form that belongs to a control.
Not for
A decision the person must make. Use a Dialog.
Pairs with
Button as the trigger, Field, PopoverClose.
Preview
Import
Import
- Files
- popover.tsx, button.tsx, in components/klarhimmel/ui/. With it: editing, theme, utils. npm: radix-ui.
- Render in
- Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
- Limit
- Overlays render into the Theme root with position: fixed. A transform on an ancestor re-parents fixed (a dialog centres in the wrapper) and overflow: hidden clips menus. Render <Theme> at the app root, outside any transformed wrapper.
Anatomy
The parts and how they nest.
PopoverHolds the open state.PopoverTriggerWrap your Button with asChild; it gets aria-expanded.PopoverContentThe floating panel. Portals into the theme root so it keeps the tokens.PopoverCloseWrap a button inside the panel that should close it.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | required | |
label | string | required | |
align | 'start' | 'center' | 'end' | 'end' | |
className | string | - | Extra classes, merged after the component's own. |
onOpenAutoFocus | (event: Event) => void | - |
Accessibility
| Key | Does |
|---|---|
Enter / Space | Opens from the trigger |
Tab | Moves through the panel |
Escape | Closes and returns focus to the trigger |
A click or tap outside the panel also closes it.
Accessibility