Popup
Popup is an anchored overlay that appears relative to a trigger element.
import { RiCloseLine, RiShareLine } from '@remixicon/react';
import { Button } from '@/components/ui/wideset/button/Button';
import { IconButton } from '@/components/ui/wideset/button/IconButton';
import { Popup } from '@/components/ui/wideset/popup/Popup';
<Popup>
<Popup.Trigger asChild>
<Button variant="secondary" preset="border">
<Button.Icon icon={RiShareLine} />
Share
</Button>
</Popup.Trigger>
<Popup.Container>
<Popup.Header>
<div className="flex items-center justify-between gap-ws-5">
<Popup.Title>Share this report</Popup.Title>
<Popup.Close asChild>
<IconButton
aria-label="Close"
icon={RiCloseLine}
preset="border"
variant="secondary"
size="sm"
className="size-ws-forms-sm shrink-0 p-0"
/>
</Popup.Close>
</div>
</Popup.Header>
<Popup.Content>
<Popup.Description>Anyone with the link can view this report, but not edit it.</Popup.Description>
</Popup.Content>
<Popup.Footer>
<Popup.Close asChild>
<Button variant="secondary" preset="border" size="sm">Cancel</Button>
</Popup.Close>
<Popup.Close asChild>
<Button size="sm">Copy link</Button>
</Popup.Close>
</Popup.Footer>
</Popup.Container>
</Popup>Installation
pnpm dlx wideset add popup
Copies the component and any Wideset components it uses into your project.
Examples
Sections
Header, content and footer are each optional. Add the footer when the popup asks for a decision, and drop it when the popup only shows information or applies changes as the user makes them. The title is not linked to the popup for screen readers: point aria-labelledby on the container at it, or give the container an aria-label.
import { Button } from '@/components/ui/wideset/button/Button';
import { Popup } from '@/components/ui/wideset/popup/Popup';
const frame =
'flex w-[24rem] max-w-full flex-col rounded-ws-container-lg bg-ws-static-overlay shadow-ws-high';
export default function PopupSections() {
return (
<Popup>
<div className="gap-ws-9 flex flex-wrap items-start justify-center">
<div className={frame}>
<Popup.Header>
<Popup.Title>Share this report</Popup.Title>
</Popup.Header>
<Popup.Content>
<Popup.Description>
Anyone with the link can view this report, but not edit it.
</Popup.Description>
</Popup.Content>
<Popup.Footer>
<Button variant="secondary" preset="border" size="sm">
Cancel
</Button>
<Button size="sm">Copy link</Button>
</Popup.Footer>
</div>
<div className={frame}>
<Popup.Content>
<Popup.Description>
Last synced 5 minutes ago. Changes from other devices appear here automatically.
</Popup.Description>
</Popup.Content>
</div>
</div>
</Popup>
);
}Positions
side on Popup.Container picks the edge of the trigger the popup opens against, and sideOffset sets the gap (8px by default). When the chosen side has no room, the popup flips to the opposite one, so a popup near the bottom of the screen may still open upwards. Prefer bottom and keep one side for every popup of the same kind.
import { Button } from '@/components/ui/wideset/button/Button';
import { Popup } from '@/components/ui/wideset/popup/Popup';
const sides = [
{ side: 'top', label: 'Top' },
{ side: 'right', label: 'Right' },
{ side: 'bottom', label: 'Bottom' },
{ side: 'left', label: 'Left' },
] as const;
export default function PopupPositions() {
return (
<div className="gap-ws-6 flex flex-wrap justify-center">
{sides.map(({ side, label }) => (
<Popup key={side}>
<Popup.Trigger asChild>
<Button variant="secondary" preset="border">
{label}
</Button>
</Popup.Trigger>
<Popup.Container side={side} align="center" aria-label="Sync status">
<Popup.Content>
<Popup.Description>
Last synced 5 minutes ago. Changes from other devices appear here automatically.
</Popup.Description>
</Popup.Content>
</Popup.Container>
</Popup>
))}
</div>
);
}API reference
Popup
Radix Popover.Root is passed through to it. See Radix Popover.Root.Popup.Close
Radix Popover.Close is passed through to it. See Radix Popover.Close.Popup.Container
| Name | Description | Default |
|---|---|---|
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
persistent | Prevents closing the popup by clicking outside or pressing Escape. boolean | false |
portalContainer | DOM element to portal the popup content into. Defaults to `document.body`. Element | DocumentFragment | — |
Radix Popover.Content is passed through to it. See Radix Popover.Content.Popup.Content
| Name | Description | Default |
|---|---|---|
contentClassName | Additional className applied to the inner scroll content wrapper. string | — |
<div> is passed through to it. See MDN: <div>.Popup.Description
<p> is passed through to it. See MDN: <p>.Popup.Footer
<div> is passed through to it. See MDN: <div>.Popup.Header
<div> is passed through to it. See MDN: <div>.Popup.Title
<h2> is passed through to it. See MDN: <h2>.Popup.Trigger
Radix Popover.Trigger is passed through to it. See Radix Popover.Trigger.Accessibility
Popup.TitleandPopup.Descriptionare linked to the container automatically. Without a title, givePopup.Containeranaria-label.- There is no built-in close button: add
Popup.Closearound anIconButtonwith anaria-label, or a Cancel button. - Not modal by default: focus moves in on open and back to the trigger on close, but is not trapped.
| Part | Renders | Description |
|---|---|---|
| PopupRenders no element | Radix Popover.Root | Popup is an anchored overlay that appears relative to a trigger element. |
| Popup.CloseRenders no element | Radix Popover.Close | A control that closes the associated dialog. |
| Popup.ContainerRenders no element | Radix Popover.Content | The floating surface or stack containing feedback content. |
| Popup.ContentRenders no element | <div> | The content surface rendered within `Popup`. |
| Popup.DescriptionRenders no element | <p> | Supporting descriptive text. |
| Popup.FooterRenders no element | <div> | The action area beneath the main content. |
| Popup.HeaderRenders no element | <div> | The header area for a title and supporting content. |
| Popup.TitleRenders no element | <h2> | The primary title text. |
| Popup.TriggerRenders no element | Radix Popover.Trigger | The control that opens or toggles the associated content. |
import { RiCloseLine, RiShareLine } from '@remixicon/react';
import { Button } from '@/components/ui/wideset/button/Button';
import { IconButton } from '@/components/ui/wideset/button/IconButton';
import { Popup } from '@/components/ui/wideset/popup/Popup';
<Popup>
<Popup.Trigger asChild>
<Button variant="secondary" preset="border">
<Button.Icon icon={RiShareLine} />
Share
</Button>
</Popup.Trigger>
<Popup.Container>
<Popup.Header>
<div className="flex items-center justify-between gap-ws-5">
<Popup.Title>Share this report</Popup.Title>
<Popup.Close asChild>
<IconButton
aria-label="Close"
icon={RiCloseLine}
preset="border"
variant="secondary"
size="sm"
className="size-ws-forms-sm shrink-0 p-0"
/>
</Popup.Close>
</div>
</Popup.Header>
<Popup.Content>
<Popup.Description>Anyone with the link can view this report, but not edit it.</Popup.Description>
</Popup.Content>
<Popup.Footer>
<Popup.Close asChild>
<Button variant="secondary" preset="border" size="sm">Cancel</Button>
</Popup.Close>
<Popup.Close asChild>
<Button size="sm">Copy link</Button>
</Popup.Close>
</Popup.Footer>
</Popup.Container>
</Popup>