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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthInstallation
Import Popover, PopoverTrigger, PopoverContent and optional sub-components from @/components/kamod-ui/popover.
pnpm add @kamod-ch/uiCopy 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 { 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.
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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthPlacement
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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthAlign
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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthWith 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthWith 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthDefault 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthSettings 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthProps 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.
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
? 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.Popover
PopoverProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
defaultOpen | Configure
|
onOpenChange | Configure
|
open | Configure
|
PopoverClose
PopoverCloseProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
onClick | Configure
|
PopoverContent
PopoverContentProps
| Prop / type | Description |
|---|---|
align | Configure
|
children | Configure
|
class | Configure
|
forceMount | Configure
|
onKeyDown | Configure
|
side | Configure
|
sideOffset | Configure
|
style | Configure
|
PopoverDescription
PopoverDescriptionProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
PopoverHeader
PopoverHeaderProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
PopoverTitle
PopoverTitleProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
PopoverTrigger
PopoverTriggerProps
| Prop / type | Description |
|---|---|
asChild | Configure
|
children | Configure
|
class | Configure
|
onClick | Configure
|
ref | Configure
|
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 fieldsPopoverPropsPopover.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 fieldPopoverClosePropsPopoverClose.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 fieldsPopoverContentPropsPopoverContent.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 fieldPopoverDescriptionPropsPopoverDescription.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 fieldPopoverHeaderPropsPopoverHeader.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 fieldPopoverTitlePropsPopoverTitle.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 fieldsPopoverTriggerPropsPopoverTrigger.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.
- Open from the keyboard, reach each control, press Escape and confirm return focus.
- Inspect the dialog name and trigger expanded state before and after opening.
- 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.
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.