Native Solid 2 fork. Original documentation and designs © WorkOS; historical posts retain their original context.
Popover
Displays rich content in a portal, triggered by a button.
Features
Can be controlled or uncontrolled.
Customize side, alignment, offsets, collision handling.
Optionally render a pointing arrow.
Focus is fully managed and customizable.
Supports modal and non-modal modes.
Dismissing and layering behavior is highly customizable.
Anatomy
Import all parts and piece them together.
API Reference
Root
Contains all the parts of a popover.
Trigger
The button that toggles the popover. By default, the Popover.Content will position itself against the trigger.
Anchor
An optional element to position the Popover.Content against. If this part is not used, the content will position alongside the Popover.Trigger.
Portal
When used, portals the content part into the body.
Content
The component that pops out when the popover is open.
Like Dialog.Content, Popover.Content sets aria-labelledby and aria-describedby to the Popover.Title and Popover.Description parts, using IDs that Popover.Root allocates up front. If a popover has no Title, name Content with a nonblank aria-label (or your own aria-labelledby). If it has no Description, pass aria-describedby={undefined}. Passing either relationship to Content replaces the default, and passing it as undefined removes it. A Title or Description with its own id must be linked from Content with the same ID.
Breaking in 0.1.0-rc.2: Content no longer collects part IDs or appends them to the relationships you pass.
Title
An optional accessible title for the popover. Popover.Content is labelled by it. Without it, give Content a nonblank aria-label. A custom id replaces the Root ID, so link it with aria-labelledby on Popover.Content.
Description
An optional accessible description for the popover. Popover.Content is described by it. Without it, pass aria-describedby={undefined} to Popover.Content. A custom id replaces the Root ID, so link it with aria-describedby on Popover.Content.
Arrow
An optional arrow element to render alongside the popover. This can be used to help visually link the anchor with the Popover.Content. Must be rendered inside Popover.Content.
Close
The button that closes an open popover.
Examples
Constrain the content size
You may want to constrain the width of the content so that it matches the trigger width. You may also want to constrain its height to not exceed the viewport.
We expose several CSS custom properties such as --radix-popover-trigger-width and --radix-popover-content-available-height to support this. Use them to constrain the content dimensions.
Origin-aware animations
We expose a CSS custom property --radix-popover-content-transform-origin. Use it to animate the content from its computed origin based on side, sideOffset, align, alignOffset and any collisions.
Collision-aware animations
We expose data-side and data-align attributes. Their values will change at runtime to reflect collisions. Use them to create collision and direction-aware animations.
With custom anchor
You can anchor the content to another element if you do not want to use the trigger as the anchor.
Accessibility
Adheres to the Dialog WAI-ARIA design pattern.
Keyboard Interactions
Custom APIs
Create your own API by abstracting the primitive parts into your own component.
Abstract the arrow and set default configuration
This example abstracts the Popover.Arrow part and sets a default sideOffset configuration.