Popup

Popup is an anchored overlay that appears relative to a trigger element.

tsx
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.

tsx
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.

tsx
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

No props of its ownIt takes its content as children.
Every other prop of Radix Popover.Root is passed through to it. See Radix Popover.Root.

Popup.Close

No props of its ownIt takes its content as children.
Every other prop of Radix Popover.Close is passed through to it. See Radix Popover.Close.

Popup.Container

NameDescriptionDefault
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
—
Every other prop of Radix Popover.Content is passed through to it. See Radix Popover.Content.

Popup.Content

NameDescriptionDefault
contentClassName

Additional className applied to the inner scroll content wrapper.

string
—
Every other prop of <div> is passed through to it. See MDN: <div>.

Popup.Description

No props of its ownIt takes its content as children.
Every other prop of <p> is passed through to it. See MDN: <p>.

Popup.Footer

No props of its ownIt takes its content as children.
Every other prop of <div> is passed through to it. See MDN: <div>.

Popup.Header

No props of its ownIt takes its content as children.
Every other prop of <div> is passed through to it. See MDN: <div>.

Popup.Title

No props of its ownIt takes its content as children.
Every other prop of <h2> is passed through to it. See MDN: <h2>.

Popup.Trigger

No props of its ownIt takes its content as children.
Every other prop of Radix Popover.Trigger is passed through to it. See Radix Popover.Trigger.

Accessibility

  • Popup.Title and Popup.Description are linked to the container automatically. Without a title, give Popup.Container an aria-label.
  • There is no built-in close button: add Popup.Close around an IconButton with an aria-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.
PartRendersDescription
PopupRadix Popover.RootPopup is an anchored overlay that appears relative to a trigger element.
Popup.CloseRadix Popover.CloseA control that closes the associated dialog.
Popup.ContainerRadix Popover.ContentThe floating surface or stack containing feedback content.
Popup.Content<div>The content surface rendered within `Popup`.
Popup.Description<p>Supporting descriptive text.
Popup.Footer<div>The action area beneath the main content.
Popup.Header<div>The header area for a title and supporting content.
Popup.Title<h2>The primary title text.
Popup.TriggerRadix Popover.TriggerThe control that opens or toggles the associated content.
tsx
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>

Appearance

Side
Align

Content

Footer

Behavior

Persistent