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/aria/popover.jsonnpx shadcn@latest add https://kit.dev/r/aria/popover.jsonpnpm dlx shadcn@latest add https://kit.dev/r/aria/popover.jsonyarn shadcn@latest add https://kit.dev/r/aria/popover.jsonThis component depends on Button. Install it first if you haven't already.
Install the following dependencies:
bun add react-aria-componentsnpm install react-aria-componentspnpm add react-aria-componentsyarn add react-aria-componentsCopy and paste the following code into your project.
"use client";
import type React from "react";
import {
DialogTrigger,
type DialogTriggerProps,
Heading,
Popover as PopoverPrimitive,
type PopoverProps as PopoverPrimitiveProps,
} from "react-aria-components";
import { cn } from "@/lib/utils";
export const PopoverTrigger = (props: DialogTriggerProps) => {
const { children, ...rest } = props;
return (
<DialogTrigger data-slot="popover-trigger" {...rest}>
{children}Update the import paths to match your project setup.
Anatomy
PopoverArrow
└── PopoverArrowTip
PopoverAnchor
PopoverTrigger
PopoverIndicator
PopoverPositioner
PopoverContent
PopoverTitle
PopoverDescription
PopoverCloseUsage
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
| Key | Description |
|---|---|
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
AttributeType
CSS variableType
--trigger-anchor-pointstringPopoverTrigger
PropType
AttributeType
PopoverHeader
PropType
AttributeType
PopoverTitle
PropType
AttributeType
PopoverDescription
PropType
AttributeType