Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Popover examples · Standard

Popover with Form for React

A Settings popover with a text input and a Save button.

Framework
UI library

A Settings button that opens a title, one text input and a full-width Save button. Use it for a single quick setting; anything longer belongs in a Dialog. In React, Base UI handles opening, dismissing and focus.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

What is in the settings panel?

PopoverTitle reads Settings. The field is an Input with type="text", aria-label="Value", and placeholder="Enter value". Save is a Button with className="w-full". The input leaves value and onChange unset, so it is uncontrolled.

How do I close this panel from code?

Save closes the panel and leaves the input's text unread. Here the panel is controlled: open and onOpenChange on Popover, and the button's handler sets the state to false. The callback gets the next open state first.

How does the Settings button become the trigger?

The trigger is a Button with variant="outline" and the label Settings. Activating it opens the panel beside the button. Pass the button to render on PopoverTrigger, and use PopoverContent as the panel.

When does this belong in a dialog?

This panel is one Input and a Save button, and focus moves into it when it opens. A task with more fields belongs in a Dialog. Escape or a click outside still closes this panel.

How is the input labeled?

The Input has aria-label="Value" and placeholder="Enter value". PopoverTitle says Settings above it. This file uses that aria-label as the field name.

How does this panel dismiss?

Escape closes the panel and returns focus to the trigger. A click outside closes it too. The panel sits beside the button, and the rest of the page stays usable.