Web · Components
Popover
A small panel opened from a button: quick settings, share options, a filter, an info card and so on.
7 exports
Live example
Preview
Dimensions
Code
Events
- Events appear here when you interact with the preview.
Preview
Code
Events
- Events appear here when you interact with the preview.
Icon button in a table row
- Invoice #1042
- Invoice #1043
- Invoice #1044
Import
A small panel opened from a button: quick settings, share options, a filter, an info card and so on. The trigger is given with trigger, the content with children.
- Native Popover API: opens in the top layer (no z-index), closes on an outside click and with Esc, and focus returns to the trigger on close. The trigger works even before JavaScript loads.
- Sits next to the trigger with CSS anchor positioning and flips to the other side if it doesn't fit on screen; no JavaScript position math on scroll.
- Mobile: On small screens it becomes a bottom sheet; it can be closed by pulling down and with the back button.
Examples
A small confirmation bubble attached to a button: "Delete? [Cancel] [Delete]". Lighter than the full-screen confirm window; for in-place confirmations like deleting a table row or removing from a list.
- The bubble opens next to the element (CSS anchor positioning) and flips to the other side if it doesn't fit on screen. Esc and an outside click cancel; focus returns to the element on close.
- If
onConfirmreturns a Promise, the confirm button shows loading and the bubble closes when done;falseor an error keeps it open. - With
tone="danger"the confirm button is red and focus starts on "Cancel". - Screen readers announce the bubble as an
alertdialogwith the question. - With
disabledasking is skipped (the element's ownonClickruns).
Examples
PopconfirmClassNames
interfaceClasses that can be passed to the inner parts of Popconfirm.
| Name | Type | Description |
|---|---|---|
title? | string | Title. |
description? | string | Description. |
actions? | string | Button row. |
PopconfirmProps
interfaceProps of the Popconfirm component.
| Name | Type | Default | Description |
|---|---|---|---|
children | ReactElement | Element asking for confirmation, usually a Button. On click the action doesn't run immediately; a question bubble opens next to it first. | |
title | ReactNode | The question (e.g. "Delete this record?"). | |
description? | ReactNode | Short description under the question (e.g. "This action cannot be undone."). | |
icon? | IconProp | false | Icon next to the title: a name or an element. If omitted, the status icon of tone; false removes the icon. | |
tone? | Tone | "primary" | Color of the confirm button. "danger" for irreversible actions such as deleting: in that case focus goes to the "Cancel" button when the bubble opens (so an accidental Enter doesn't delete). |
confirmLabel? | ReactNode | "Onayla"` (`messages.confirm`) | Text of the confirm button. |
cancelLabel? | ReactNode | "İptal"` (`messages.cancel`) | Text of the cancel button. |
showCancel? | boolean | true | Show the "Cancel" button? |
onConfirm? | () => unknown | Runs on confirm. If it returns a Promise, the confirm button shows loading and the bubble stays open until it settles; if it returns false or throws, the bubble stays open (the error goes to onError). | |
onCancel? | () => void | When cancelled (Cancel, Esc or an outside click). | |
onError? | (error: unknown) => void | Called when onConfirm throws. | |
disabled? | boolean | false | Skip asking: if true, the element works normally with its own onClick and the bubble doesn't open (e.g. when there are no unsaved changes). |
side? | Placement | "top" | Position of the bubble relative to the element. See Placement. |
open? | boolean | Whether it is open when controlled. | |
defaultOpen? | boolean | false | Is it initially open when uncontrolled? |
onOpenChange? | (open: boolean) => void | Called when it opens or closes. | |
mobileSheet? | boolean | false | Turn into a bottom sheet on small screens? Since the bubble is small, by default it opens next to the element on mobile too. |
className? | string | Classes added to the bubble (e.g. w-80 for width). | |
classNames? | PopconfirmClassNames | Classes added to the inner parts. |
PopoverRenderContext
interfaceValues received when the Popover content is given as a function.
| Name | Type | Description |
|---|---|---|
close | () => void | Closes the panel (e.g. on an "Apply" button). |
PopoverClassNames
interfaceClasses that can be passed to the inner parts of Popover.
| Name | Type | Description |
|---|---|---|
title? | string | Title. |
description? | string | Description. |
PopoverProps
interfaceProps of the Popover component.
| Name | Type | Default | Description |
|---|---|---|---|
trigger | ReactElement | Element that toggles the panel, usually a Button. | |
children? | ReactNode | ((context: PopoverRenderContext) => ReactNode) | Content of the panel. If a function is given it receives { close }, so the panel can be closed from the content. | |
title? | ReactNode | Title at the top of the panel; screen readers announce the panel with this name. | |
description? | ReactNode | Description under the title. | |
label? | string | Screen reader name; give it if there is no visible title. | |
side? | Placement | "auto" | Position relative to the trigger: side and alignment (e.g. "top-right", "bottom-left", "right"). See Placement. |
open? | boolean | Whether it is open when controlled. | |
defaultOpen? | boolean | false | Is it initially open when uncontrolled? |
onOpenChange? | (open: boolean) => void | Called with the new state when it opens or closes. | |
mobileSheet? | boolean | true | Turn into a bottom sheet on small screens (below 640 px)? |
closeOnBackButton? | boolean | true | Should the back button close the open panel? |
className? | string | Classes added to the panel (e.g. w-80 for width). | |
classNames? | PopoverClassNames | Classes added to the inner parts. | |
effect? | EffectProp | Effect or effects of the panel (e.g. "beam", ["border", "glow"]). If omitted, UIProvider appearance.defaults.popover.effect. See BuiltinEffect. |