Skip to main content

Starwind UI v3.0 is now available! Migration guide

Installation

Usage

---
import { Button } from "@/components/starwind/button";
import { Input } from "@/components/starwind/input";
import { Label } from "@/components/starwind/label";
import {
Popover,
PopoverContent,
PopoverDescription,
PopoverHeader,
PopoverTitle,
PopoverTrigger,
} from "@/components/starwind/popover";
---
<Popover>
<PopoverTrigger asChild>
<Button variant="outline">Open popover</Button>
</PopoverTrigger>
<PopoverContent class="w-80">
<PopoverHeader>
<PopoverTitle>Dimensions</PopoverTitle>
<PopoverDescription>
Set the dimensions for the layer.
</PopoverDescription>
</PopoverHeader>
<div class="grid gap-2 px-0.5">
<div class="grid grid-cols-3 items-center gap-3">
<Label for="popover-width">Width</Label>
<Input id="popover-width" value="100%" class="col-span-2 h-8" />
</div>
<div class="grid grid-cols-3 items-center gap-3">
<Label for="popover-max-width">Max. width</Label>
<Input id="popover-max-width" value="300px" class="col-span-2 h-8" />
</div>
<div class="grid grid-cols-3 items-center gap-3">
<Label for="popover-height">Height</Label>
<Input id="popover-height" value="25px" class="col-span-2 h-8" />
</div>
<div class="grid grid-cols-3 items-center gap-3">
<Label for="popover-max-height">Max. height</Label>
<Input id="popover-max-height" value="none" class="col-span-2 h-8" />
</div>
</div>
</PopoverContent>
</Popover>

Composition

Use a trigger and content inside the root. Header, title, and description are optional content helpers.

Popover
├── PopoverTrigger
└── PopoverContent
└── PopoverHeader
├── PopoverTitle
└── PopoverDescription

When to Use

Use Popover for contextual content, settings, or quick actions that stay near their trigger.

Hover Open

Enable hover behavior with openOnHover. Use closeDelay to control how long the popover stays open after the pointer leaves.

Nested Popovers

Nested popovers work without immediately closing the parent popover while you interact with child content.

Alignment

Use the align prop on PopoverContent to control horizontal alignment relative to the trigger.

Side and Offset

Position content with side and add spacing from the trigger with sideOffset.

API Reference

Styled Component API

These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.

Popover Trigger

Inherits button attributes.

Contains the following additional props:

Prop Type Default Toggle details
asChild boolean false
Description
Merges the component behavior and props into its child element.
Classification
Primitive override
Primitive prop
popover.Trigger.asChild

Popover Content

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
disablePortal boolean false
Description
Keeps the public Portal wrapper inline instead of moving it to a target.
Classification
Wrapper prop
exitMotion "popover" | "fade" "popover"
Description
Selects the motion treatment used while floating content closes.
Classification
Styled variant
portalContainer string
Description
Sets the CSS selector for the public Portal wrapper target.
Classification
Wrapper prop

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Popover.

Primitive API

Runtime API

Popover primitive
createPopover from @starwind-ui/runtime/popover

Changelog

View version history v2.1.0 3 releases

v2.1.0

  • Added portalContainer and disablePortal to PopoverContent for custom portal targets and inline rendering.

v2.0.3

  • Named the generated aggregate default export so React and Astro tooling can identify the installed component cleanly.

v2.0.0

  • Rebuilt Popover on Starwind Runtime for open state, floating placement, dismissal, and nesting.
  • See the Popover Primitive for the underlying unstyled anatomy and behavior API.