HapplyUI

Components

Popover

A popover component with arrow indicator, close button, and directional slide animations.

This component is not a standalone one but is used to support other components.


Installation

bunx @happlyui/cli@latest add popover

Dependencies

npm packages

  • @radix-ui/react-popover
  • @radix-ui/react-slot

Registry dependencies

These are automatically installed when you add this component.

  • happly-ui-utils

Usage

import * as Popover from "@/components/ui/popover"

<Popover.Root>
  <Popover.Trigger>Open</Popover.Trigger>
  <Popover.Content>
    <Popover.Close />
    Content here
  </Popover.Content>
</Popover.Root>

Examples

Demo

Popover with icon, description, close button, and footer actions.

<Popover.Root>
  <Popover.Trigger asChild>
    <Button.Root>Open Popover</Button.Root>
  </Popover.Trigger>
  <Popover.Content className="w-80">
    <Popover.Close asChild>
      <CompactButton.Root size="large" variant="ghost">
        <CompactButton.Icon as={RiCloseLine} />
      </CompactButton.Root>
    </Popover.Close>
    Content here
  </Popover.Content>
</Popover.Root>

Position

Popovers positioned on top, left, and right sides.

<Popover.Content side="top">...</Popover.Content>
<Popover.Content side="left">...</Popover.Content>
<Popover.Content side="right">...</Popover.Content>

API Reference

Popover.Root

The root popover container. Passes through Radix Popover.Root props.

PropTypeDefaultDescription

Popover.Trigger

The element that triggers the popover.

PropTypeDefaultDescription
asChildbooleanfalseRender as child element using Radix Slot

Popover.Content

The popover content panel with arrow indicator.

PropTypeDefaultDescription
side'top' | 'right' | 'bottom' | 'left''bottom'The preferred side to position the popover
align'start' | 'center' | 'end''center'The alignment relative to the trigger
sideOffsetnumber12Distance in pixels from the trigger
showArrowbooleantrueShow the arrow indicator pointing to the trigger
unstyledbooleanfalseRemove default styling (background, padding, ring)

Popover.Close

Close button positioned absolutely in the top-right corner.

PropTypeDefaultDescription
asChildbooleanfalseRender as child element using Radix Slot
unstyledbooleanfalseRemove default absolute positioning

Popover.Anchor

An optional anchor element for custom positioning.

PropTypeDefaultDescription

Previous
Modal