Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Shadcn Popover for React and Tailwind

Overlay with extra info or options on trigger.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/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,
  PopoverBody,
  PopoverContent,
  PopoverHeader,
  PopoverTrigger,
} from "@/components/ui/popover";
<Popover>
  <PopoverTrigger asChild>
    <Button variant="outline">Open</Button>
  </PopoverTrigger>

  <PopoverContent className="w-80">
    <PopoverHeader
      description="Set the dimensions for the layer."
      title="Dimensions"
    />
    <PopoverBody>
      <FieldGroup className="gap-2">
        <Field className="grid grid-cols-3 items-center gap-4">
          <FieldLabel>Width</FieldLabel>
          <Input className="col-span-2" defaultValue="100%" />
        </Field>

        <Field className="grid grid-cols-3 items-center gap-4">
          <FieldLabel>Max. width</FieldLabel>
          <Input className="col-span-2" defaultValue="300px" />
        </Field>

        <Field className="grid grid-cols-3 items-center gap-4">
          <FieldLabel>Height</FieldLabel>
          <Input className="col-span-2" defaultValue="25px" />
        </Field>

        <Field className="grid grid-cols-3 items-center gap-4">
          <FieldLabel>Max. height</FieldLabel>
          <Input className="col-span-2" defaultValue="none" />
        </Field>
      </FieldGroup>
    </PopoverBody>
  </PopoverContent>
</Popover>

Accessibility

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

Demos

Anchor

Close Behavior

Close Button

Controlled

Custom Spacing

Nested

Non Modal

Positioning

Scroll Area

With Dialog

API Reference

Popover

PropType
AttributeType

PopoverArrow

div

PropType
AttributeType
CSS variableType

PopoverArrowTip

div

PropType
AttributeType
CSS variableType

PopoverAnchor

div

PropType
AttributeType

PopoverTrigger

button

PropType
AttributeType

PopoverPositioner

div

PropType
AttributeType

PopoverContent

div

PropType
AttributeType
CSS variableType

PopoverTitle

div

PropType
AttributeType

PopoverDescription

div

PropType
AttributeType

PopoverClose

button

PropType
AttributeType

PopoverHeader

div

PropType
AttributeType
CSS variableType

PopoverBody

div

PropType
AttributeType
CSS variableType

PopoverFooter

div

PropType
AttributeType
CSS variableType

usePopover

PropType