Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Popover for React

Overlay with extra info or options on trigger.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/radix/popover.json

Anatomy

PopoverArrow
└── PopoverArrowTip
PopoverAnchor
PopoverTrigger
PopoverIndicator
PopoverPositioner
PopoverContent
PopoverTitle
PopoverDescription
PopoverClose

Usage

import { Button } from "@/components/ui/button";
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import {
  Popover,
  PopoverContent,
  PopoverDescription,
  PopoverHeader,
  PopoverTitle,
  PopoverTrigger,
} from "@/components/ui/popover";
<Popover>
  <PopoverTrigger asChild>
    <Button variant="outline">Open popover</Button>
  </PopoverTrigger>
  <PopoverContent className="w-64 max-w-full">
    <PopoverHeader>
      <PopoverTitle>Dimensions</PopoverTitle>
      <PopoverDescription>
        Set the dimensions for the layer.
      </PopoverDescription>
    </PopoverHeader>
    <FieldGroup className="min-w-0 gap-3">
      <Field className="min-w-0" orientation="horizontal">
        <FieldLabel className="w-1/2">Width</FieldLabel>
        <Input className="min-w-0" defaultValue="100%" />
      </Field>
      <Field className="min-w-0" orientation="horizontal">
        <FieldLabel className="w-1/2">Height</FieldLabel>
        <Input className="min-w-0" defaultValue="25px" />
      </Field>
    </FieldGroup>
  </PopoverContent>
</Popover>

Accessibility

KeyDescription
Enter
Activate the focused control.
Space
Activate the focused control.

Demos

Basic

A simple popover with a header, title, and description.

Alignments

Use placement on the popover to control alignment.

Form

A popover with form fields inside.

Rtl

Right-to-left popover. See the RTL configuration guide for document direction.

API Reference

Popover

PropType
open?boolean
defaultOpen?boolean
children?React.ReactNode
modal?boolean
AttributeType

PopoverAnchor

div

PropType
open?boolean
defaultOpen?boolean
children?React.ReactNode
modal?boolean
AttributeType

PopoverTrigger

button

PropType
open?boolean
defaultOpen?boolean
children?React.ReactNode
modal?boolean
AttributeType

PopoverContent

div

PropType
open?boolean
defaultOpen?boolean
children?React.ReactNode
modal?boolean
AttributeType
CSS variableType
--radix-popover-content-transform-originstring

PopoverHeader

PropType
open?boolean
defaultOpen?boolean
children?React.ReactNode
modal?boolean
AttributeType

PopoverTitle

PropType
open?boolean
defaultOpen?boolean
children?React.ReactNode
modal?boolean
AttributeType

PopoverDescription

PropType
open?boolean
defaultOpen?boolean
children?React.ReactNode
modal?boolean
AttributeType