Your next page is taking shape...

Opening Your Next Page…

Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.

Made for Preact. Built to be yours.

Overlays & Actions

Popover

A modern popup that floats next to a trigger for lightweight actions, forms, and contextual content. Reveal the right amount of context without losing the user's place in the interface. Keep the trigger, content and dismissal behavior working as one interaction. Import it from @/components/kamod-ui/popover.

Source · Design reference · API reference · Theming · Styles


Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Installation

Import Popover, PopoverTrigger, PopoverContent and optional sub-components from @/components/kamod-ui/popover.

Install PackagesTerminal
pnpm add @kamod-ch/ui

Copy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.

Usage

Use PopoverTrigger with asChild when the trigger is a Button so you avoid nested buttons. Use popovers for secondary actions, inline forms, and contextual help; keep content focused and close on outside click.

Import SetupTypeScript
import { Popover } from "@kamod-ch/ui";

Choose a complete composition from the examples below; required child components and props vary by pattern.

Component Examples & Variants

Explore Popover in Different Contexts, from the starting pattern to the compositions below. Begin with Basic, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.

Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.

Basic

Reveal a Small Amount of Context Beside Its Trigger. Pair PopoverTrigger with content containing a title and short explanation. This creates an anchored detail surface that remains related to its trigger, suitable for a focused task that does not need a full dialog.

Keep the panel's purpose clear, preserve focus and dismissal behavior, and use a Dialog when the task needs a larger, more focused surface.

src/components/PopoverExample.tsx15 lines
import { Button, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger } from "@kamod-ch/ui";

export const Example = () => (
  <Popover>
    <PopoverTrigger asChild>
      <Button variant="outline">Open popover</Button>
    </PopoverTrigger>
    <PopoverContent align="start">
      <PopoverHeader>
        <PopoverTitle>Dimensions</PopoverTitle>
        <PopoverDescription>Set the dimensions for the layer.</PopoverDescription>
      </PopoverHeader>
    </PopoverContent>
  </Popover>
);

With Form

Keep Inline Configuration Narrowly Scoped. Place a small settings form inside the popover when several closely related values can be edited in context. The panel contains the fields, while the application still defines how their changes are stored or applied.

Decide whether edits apply immediately or on confirmation, and avoid silently discarding changes when the user dismisses the panel.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Placement

Choose a Preferred Edge that Supports the Workflow. Set side on PopoverContent to choose the preferred edge of the trigger for the popup. Compare placements with the real panel content, since a useful location depends on both the anchor and the available viewport space.

Test triggers near viewport boundaries and in scrolling containers; a placement that works in the center of a demo may need more care in a toolbar.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Align

Align the Panel with the Content It Belongs to. Use align on PopoverContent to line up the panel's edge or center with the trigger. This tunes its position along the cross axis without changing which physical side the popup is placed on.

Check long labels and narrow screens before adding offsets, and keep enough separation that the trigger remains recognizable while the panel is open.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

With Form (Compact)

Use Density Only for Genuinely Short Settings. Arrange labels and inputs in short horizontal rows inside a narrow settings popover. This saves vertical space for concise values, but the field names and editable areas still need enough room when content becomes longer.

Keep labels associated with inputs and allow the layout to adapt before narrowing the editable value or clipping helpful feedback.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

With Close Button

Provide a Visible Dismissal Affordance Where It Helps. Add PopoverClose inside the panel when an explicit Done or Close action makes completion clearer. This complements the anchored interaction and gives the reader a visible way to leave the temporary content.

Give it a clear name and preserve focus return; closing should not imply that unsaved form changes were submitted.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Default Open

Use Initial Visibility Deliberately. Use defaultOpen when the initial screen deliberately needs to expose the popover's content. This establishes only the initial state; use controlled state if other actions must determine its visibility afterward.

Distinguish defaultOpen from controlled state, and give users a clear dismissal route without immediately reopening the panel on the next render.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Settings Panel

Keep Related Preferences Together. Combine switches and fields inside a settings popover when the options belong to one local configuration task. Keep each control tied to the same application settings model so closing the panel does not obscure whether changes were applied.

Label each control, explain whether changes are immediate, and move the workflow to a larger surface if the panel grows into several independent sections.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width
API reference

Props and Data

Configure Popover using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.

Props, slots and variants for this component.

API reference
Your API, from source

Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.

Component Props

Read each option with its owning component. The
marker identifies required fields verified in that declaration. A ? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.
@kamod-ch/ui/popover30.5 KB min · 8.0 KB gzipSignals: direct@preact/signals

Popover

PopoverProps

Popover documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildPopoverProps

Configure children for Popover. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>PopoverProps

Configure class for Popover. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
defaultOpen
booleanPopoverProps

Configure defaultOpen for Popover. Compare its accepted type with the Usage Guidance before supplying a value.

Default
false
onOpenChange
((open: boolean) => void)PopoverProps

Configure onOpenChange for Popover. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
open
booleanPopoverProps

Configure open for Popover. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

PopoverClose

PopoverCloseProps

PopoverClose documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildPopoverCloseProps

Configure children for PopoverClose. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>PopoverCloseProps

Configure class for PopoverClose. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onClick
MouseEventHandler<HTMLButtonElement>PopoverCloseProps

Configure onClick for PopoverClose. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

PopoverContent

PopoverContentProps

PopoverContent documented props
Prop / typeDescription
align
"start" | "center" | "end"PopoverContentProps

Configure align for PopoverContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"center"
children
ComponentChild[] | ComponentChildPopoverContentProps

Configure children for PopoverContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>PopoverContentProps

Configure class for PopoverContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
forceMount
booleanPopoverContentProps

Configure forceMount for PopoverContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
false
onKeyDown
KeyboardEventHandler<HTMLDivElement>PopoverContentProps

Configure onKeyDown for PopoverContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
side
"bottom" | "top" | "right" | "left"PopoverContentProps

Configure side for PopoverContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"bottom"
sideOffset
numberPopoverContentProps

Configure sideOffset for PopoverContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
4
style
string | CSSProperties | SignalLike<string | CSSProperties | undefined>PopoverContentProps

Configure style for PopoverContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

PopoverDescription

PopoverDescriptionProps

PopoverDescription documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildPopoverDescriptionProps

Configure children for PopoverDescription. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>PopoverDescriptionProps

Configure class for PopoverDescription. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

PopoverHeader

PopoverHeaderProps

PopoverHeader documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildPopoverHeaderProps

Configure children for PopoverHeader. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>PopoverHeaderProps

Configure class for PopoverHeader. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

PopoverTitle

PopoverTitleProps

PopoverTitle documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildPopoverTitleProps

Configure children for PopoverTitle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>PopoverTitleProps

Configure class for PopoverTitle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

PopoverTrigger

PopoverTriggerProps

PopoverTrigger documented props
Prop / typeDescription
asChild
booleanPopoverTriggerProps

Configure asChild for PopoverTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
false
children
ComponentChild[] | ComponentChildPopoverTriggerProps

Configure children for PopoverTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>PopoverTriggerProps

Configure class for PopoverTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onClick
MouseEventHandler<HTMLButtonElement>PopoverTriggerProps

Configure onClick for PopoverTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
ref
Ref<HTMLButtonElement>PopoverTriggerProps

Configure ref for PopoverTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

Data Type Reference

Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.

Popover Props

4 declared fields
PopoverProps
Exported Source Declaration from Popover.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of PopoverProps before adapting it.

PopoverClose Props

1 declared field
PopoverCloseProps
Exported Source Declaration from PopoverClose.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of PopoverCloseProps before adapting it.

PopoverContent Props

5 declared fields
PopoverContentProps
Exported Source Declaration from PopoverContent.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of PopoverContentProps before adapting it.

PopoverDescription Props

1 declared field
PopoverDescriptionProps
Exported Source Declaration from PopoverDescription.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of PopoverDescriptionProps before adapting it.

PopoverHeader Props

1 declared field
PopoverHeaderProps
Exported Source Declaration from PopoverHeader.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of PopoverHeaderProps before adapting it.

PopoverTitle Props

1 declared field
PopoverTitleProps
Exported Source Declaration from PopoverTitle.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of PopoverTitleProps before adapting it.

PopoverTrigger Props

2 declared fields
PopoverTriggerProps
Exported Source Declaration from PopoverTrigger.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of PopoverTriggerProps before adapting it.

Accessibility

Build the Complete Interaction, Including the Parts Outside Popover. The notes below distinguish the current implementation from the labels, content and behavior your application supplies. Start with the Live Preview, check the Props and Data Reference, and test the finished composition with real content rather than assuming that an unchanged visual example covers every use case.

Built-in Behavior and Defaults

PopoverTrigger exposes a dialog popup relationship, expanded state and the content ID. PopoverContent uses role="dialog" and is labeled by the trigger by default. Escape dismissal restores focus through the component's behavior.

Labels and Relationships

Choose trigger text that also makes sense as the panel's name, or provide a more appropriate explicit naming relationship. Label controls inside the panel individually. A vague trigger such as More may not identify a settings form adequately.

Keyboard and Focus

Check the actual focus order after opening rather than assuming all popovers behave like modal dialogs. Keep any close control reachable and return focus to the opener after dismissal. For a blocking task, consider Dialog instead.

States and Integration Details

Do not put essential instructions only in a dismissible popover. Avoid nesting interactive content inside a trigger button, and ensure outside clicks do not silently discard important edits without an understandable recovery path.

Verify the Complete Interaction

Check Behavior as Well as Markup. Work through these scenarios in the application where the component will be used. Automated checks can help find structural problems; also review the reading experience with a screen reader, keyboard focus and the actual feedback from your application.

  1. Open from the keyboard, reach each control, press Escape and confirm return focus.
  2. Inspect the dialog name and trigger expanded state before and after opening.
  3. Try nested overlays and long content at narrow widths without clipping focus or the close action.

Recheck the result after changing Theme Tokens, translations or class overrides. Include text enlargement, narrow layouts and reduced-motion settings where animation is present. Inspect the Component Source when a behavior differs from your expectation; a role or state attribute does not implement keyboard interaction by itself.

For background, read the WAI-ARIA Authoring Guidance and Keyboard Interface Guidance. These explain the patterns; verify browser and assistive-technology behavior for the implementation and audience you actually support.

Take the Next Useful Step

You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.

Connect the Foundation

Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.

Build the Surrounding Screen

Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.

Make the Result Hold Up

Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.

Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.