Pallas UI
DocsComponents
Core Concepts
    • Introduction
    • Getting Started
    • Theming
    • Color Tokens
    • Spacing & Sizing
    • Layout Guide
    • AspectRatio
    • Box
    • Flex
    • Grid
    • Shapes
Previews
    • Accordion
    • Alert
    • Avatar
    • Badge
    • Breadcrumb
    • Button
    • Carousel
    • Checkbox
    • Combobox
    • Command
    • Date Picker
    • Form
    • Input
    • Input OTP
    • Label
    • MenuBar
    • Modal
    • Popover
    • Progress
    • Radio Group
    • Segmented
    • Select
    • Separator
    • Sheet
    • Sidebar
    • Skeleton
    • Slider
    • Spinner
    • Steps
    • Switch
    • Tabs
    • Textarea
    • Toast
    • Tooltip
    • Typography
  1. Components
  2. Popover

Popover

Displays rich content in a portal, triggered by a button.

Installation

Install the following dependencies

npm install @radix-ui/react-popover

Copy and paste the following code into your project

'use client'
 
import { type Assign, type WithFixedClassName, createStyleContext } from '@pallas-ui/style-context'
import * as PopoverPrimitive from '@radix-ui/react-popover'
import { popover } from '@styled-system/recipes'
import type { JsxStyleProps } from '@styled-system/types'
import * as React from 'react'
 
const { withProvider, withContext } = createStyleContext(popover)
 
export const Portal = PopoverPrimitive.Portal
 
export type RootProps = WithFixedClassName<PopoverPrimitive.PopoverProps>
export const Root = withProvider<
  React.ComponentRef<typeof PopoverPrimitive.Root>,
  Assign<RootProps, JsxStyleProps>
>(PopoverPrimitive.Root, 'root')
 
export const Trigger = withContext<
  React.ComponentRef<typeof PopoverPrimitive.Trigger>,
  PopoverPrimitive.PopoverTriggerProps
>(PopoverPrimitive.Trigger, 'trigger')
 
const Arrow = withContext<
  React.ComponentRef<typeof PopoverPrimitive.Arrow>,
  Assign<PopoverPrimitive.PopoverArrowProps, JsxStyleProps>
>(PopoverPrimitive.Arrow, 'arrow')
 
const CustomContent = React.forwardRef<
  React.ComponentRef<typeof PopoverPrimitive.Content>,
  PopoverPrimitive.PopoverContentProps
>(({ align = 'center', sideOffset = 4, children, ...props }, ref) => (
  <Portal>
    <PopoverPrimitive.Content ref={ref} align={align} sideOffset={sideOffset} {...props}>
      {children}
      <Arrow />
    </PopoverPrimitive.Content>
  </Portal>
))
CustomContent.displayName = PopoverPrimitive.Content.displayName
 
export const Content = withContext<
  React.ComponentRef<typeof PopoverPrimitive.Content>,
  Assign<PopoverPrimitive.PopoverContentProps, JsxStyleProps>
>(CustomContent, 'content')
 
export const Close = withContext<
  React.ComponentRef<typeof PopoverPrimitive.Close>,
  Assign<PopoverPrimitive.PopoverCloseProps, JsxStyleProps>
>(PopoverPrimitive.Close, 'close')
 
const Popover = {
  Root,
  Trigger,
  Content,
  Portal,
  Close,
}
 
export default Popover

Update the import paths to match your project setup

Usage

import Popover from '@/components/ui/popover'
<Popover.Root>
  <Popover.Trigger>Open</Popover.Trigger>
  <Popover.Content>Place content for the popover here.</Popover.Content>
</Popover.Root>

Examples

Simple

With Form controls

Built with ❤️ by the carbonteq team. The source code is available on GitHub.

© 2025 Pallas UI. All rights reserved.