Skip to content

Components / Popover

Popover

Interactive content anchored to a trigger. Edit a small set of values without leaving the page; square, monospaced surfaces follow the nearest live theme through a body portal.

Storybook runs locally or as a separately hosted build; no hosted Storybook is configured. Source and setup links match the install revision.

Usage playground

Activate Edit dimensions with Enter, Space or a pointer. Focus moves to Width; edit either local value, then press Escape to return. Nonmodal allows outside interaction; modal traps focus and makes the rest of the page unavailable while open.

React / TSX
'use client';

import { useId, useState } from 'react';
import { Button } from "@/components/ui/yads-button";
import { Input } from "@/components/ui/yads-input";
import { Field, FieldLabel, FieldDescription } from "@/components/ui/yads-field";

Installation

pnpm dlx [email protected] add biehlio/yet-another-design-system/popover#e7b31d0e0c9d8b24d53e97ca38b3b68d345e9f40

Popover samples include their layout styles. Install Button, Input and Field separately when imported by a sample.

Run this revision-pinned command in a project configured for shadcn. It installs yads-popover, Radix Popover 1.3.1, its scoped stylesheet and JetBrains Mono. Import { Popover } from @/components/ui/yads-popover (adjust the alias to your project). No global CSS, Tailwind utilities, reset or global theme provider is required.

Copy sample includes the complete consumer module and any recipe CSS, even when collapsed. Interactive examples include a client boundary for React Server Component apps. The dimension and controlled examples compose separately installed YADS Button, Input and Field. They include their layout styles and need no consumer Tailwind. Popover itself does not depend on other primitives.

Controlled editing

Pair open with onOpenChange and accept dismissal requests. Done, Cancel and Escape close this local editor; edits are retained, including on Cancel. Uncontrolled usage omits open; defaultOpen sets only the initial state. No network request or implicit save behavior is supplied.

Closed: Draft

React / TSX
'use client';

import { useId, useState } from 'react';
import { Button } from "@/components/ui/yads-button";
import { Input } from "@/components/ui/yads-input";
import { Field, FieldLabel, FieldDescription } from "@/components/ui/yads-field";

className customization

This complete border recipe preserves scoped colors, visible focus, viewport width and collision handling. Preferred side and alignment can change near an edge. The native trigger works without Button.

React / TSX
'use client';

import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/yads-popover";

export default function CustomPopover() {
  return (

Accessibility

  • Name the trigger and panel. Use visible trigger text. Radix connects aria-expanded, aria-controls and aria-haspopup="dialog". Content has role="dialog"; supply aria-label or aria-labelledby and connect a useful description with aria-describedby. Popover does not generate a title or label inputs for you.
  • Follow focus. Enter or Space opens from the trigger; focus moves to the first eligible focusable content element (Radix skips links during initial autofocus, falling back to the surface). Escape closes and returns focus to the trigger. Tab and Shift+Tab loop within the panel in both modes. Nonmodal permits outside focus or pointer interaction, which dismisses without pulling focus back; it is not a focus trap. Modal traps Tab and Shift+Tab inside until dismissed.
  • Keep dismissal available. Accept onOpenChange requests in controlled mode. For longer editing tasks provide a visible Done or Cancel button. Outside presses dismiss; in modal mode outside pointer interaction is blocked, not passed through. There is no automatic save, rollback or submit behavior.
  • Choose the right pattern. Unlike Tooltip, Popover may contain labeled fields, links and buttons. Use Dialog for larger tasks; do not turn this into a combobox, menu, date picker or confirmation dialog without the appropriate separate semantics and keyboard model.
  • Keep content usable. Width is capped to viewport and available space; tall content scrolls. Leave collision handling enabled. A disabled trigger cannot be focused or activated: explain unavailable actions in persistent text. Touch activation works, unlike hover-only descriptions.

Content follows the trigger’s nearest explicit data-theme="light|dark", .light or .dark ancestor, including live attribute changes and light islands. data-theme takes precedence on the same node. Standalone defaults to light; there is no global provider. The body-portaled surface carries the resolved theme for composed controls. Input, Field and Button use native CSS theme scopes so nested explicit themes remain local. Reduced motion disables the brief fade.

API reference

Import { Popover, PopoverTrigger, PopoverContent, type PopoverProps } from @/components/ui/yads-popover. Props follow Radix Popover 1.3.1. Trigger and Content forward refs and support asChild. Content always uses a body portal; there are no separate Anchor, Close, Portal, Title or Description exports. Positioning is relative to the trigger; controlled state can close programmatically.

On narrow screens, focus the table and scroll horizontally to read all columns.

Popover parts, props, types, defaults and behavior
PartPropTypeDefaultDescription
Popoveropen / defaultOpenbooleanfalse (uncontrolled)Controlled state or initial uncontrolled state. Do not combine or switch modes. Root renders no DOM.
PopoveronOpenChange(open: boolean) => voidNot setOpening and dismissal request. Update controlled open in response.
Popovermodalbooleanfalsetrue traps focus, hides outside content from assistive technology and disables outside pointer interaction while open. It does not add a backdrop.
PopoverTriggerasChildbooleanfalseUse a single child that spreads props and forwards its ref, such as YADS Button. Never nest buttons.
PopoverTriggerref / native propsRef<HTMLButtonElement> / native attributesNot setActual trigger ref, native events, disabled, aria-* and data-* pass through. Set type="button" inside forms.
PopoverContentside / aligntop | right | bottom | left / start | center | endbottom / centerPreferred placement; collisions may flip or shift it.
PopoverContentsideOffset / alignOffsetnumber (px)4 / 0Gap from trigger and alignment adjustment.
PopoverContentavoidCollisions / collisionPaddingboolean / number | partial side maptrue / 8Keep collision handling enabled for narrow screens.
PopoverContentcollisionBoundary / sticky / hideWhenDetachedElement | null | array / partial | always / boolean[] / partial / falseRadix positioning boundary, sticky behavior and detached-trigger visibility.
PopoverContentonOpenAutoFocus / onCloseAutoFocusRadix focus event handlersRadix autofocus / returnpreventDefault overrides focus management; restore an appropriate focus target yourself.
PopoverContentonEscapeKeyDown / onPointerDownOutside / onFocusOutside / onInteractOutsideRadix event handlersNot setDismissal/focus hooks. preventDefault cancels that default behavior. Do not trap users in an editor.
PopoverContentaria-label / aria-labelledby / aria-describedbystringNot setAuthor a meaningful dialog name and optional description; IDs and headings are not generated.
PopoverContentasChild / forceMountboolean / truefalse / not setasChild uses one element that spreads props and forwards ref. forceMount retains closed content; hide it accessibly and manage modal effects carefully.
PopoverContentclassName / style / refstring / CSSProperties / Ref<HTMLDivElement>Not setForwarded to the body-portaled surface with scoped styles retained.

Styling and composition

Trigger and Content expose data-state="open|closed". Content exposes resolved data-side and data-align plus --radix-popover-content-transform-origin, --radix-popover-trigger-width, --radix-popover-content-available-width and --radix-popover-content-available-height. CSS variables belong to Radix; no consumer Tailwind, reset, site variables or theme install is required. Custom portal containers and separate anchors are not supported by this wrapper.

Playground defaults and limits

Reset restores nonmodal bottom placement and initial width/height values, closing the panel. Side and mode are documentation controls, not extra props. Edits are local and uncontrolled in the dimensions example; remounting the content restores its initial values. The controlled example retains edits in React state even on Cancel. Copy sample includes a complete client module with layout CSS. Install Button, Input and Field separately for the composed examples; Popover itself has no dependency on them.