Skip to content
Klarhimmel UI

Popover

npx shadcn add @klarhimmel/popover @klarhimmel/button

Examples

  • 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

popover.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { Button } from '@/components/klarhimmel/ui/button';
import { Popover, PopoverTrigger, PopoverContent } from '@/components/klarhimmel/ui/popover';

export default function Example() {
  return (
    <Theme theme="brand">
      <Popover>
        <PopoverTrigger asChild><Button variant="secondary">Details</Button></PopoverTrigger>
        <PopoverContent label="Cancellation policy">Free until 48 hours before arrival.</PopoverContent>
      </Popover>
    </Theme>
  );
}

Import

Import

import { Popover, PopoverTrigger, PopoverContent, PopoverClose } from '@/components/klarhimmel/ui/popover';
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.

Popover
├─ PopoverTrigger (asChild)
└─ PopoverContent
   └─ PopoverClose (asChild, optional)
  • 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

PropTypeDefaultDescription
childrenReactNoderequired
labelstringrequired
align'start' | 'center' | 'end''end'
classNamestring-Extra classes, merged after the component's own.
onOpenAutoFocus(event: Event) => void-

Accessibility

KeyDoes
Enter / SpaceOpens from the trigger
TabMoves through the panel
EscapeCloses and returns focus to the trigger

A click or tap outside the panel also closes it.

Accessibility