Socket
Socket
Sign inDemoInstall

@radix-ui/react-popover

Package Overview
Dependencies
45
Maintainers
6
Versions
221
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @radix-ui/react-popover


Version published
Weekly downloads
1.2M
decreased by-20.72%
Maintainers
6
Install size
1.64 MB
Created
Weekly downloads
 

Package description

What is @radix-ui/react-popover?

The @radix-ui/react-popover package is a part of the Radix UI component library, which provides unstyled, accessible components for building high-quality design systems and web applications. The react-popover component is specifically designed to create a floating, popover dialog that appears next to a target element. It is highly customizable and can be used for various UI patterns like tooltips, dropdowns, and more.

What are @radix-ui/react-popover's main functionalities?

Basic Popover

This code demonstrates how to create a basic popover component. A button is used as the trigger, and when clicked, the popover content is displayed.

{"import { Popover, PopoverTrigger, PopoverContent } from '@radix-ui/react-popover';\n\nfunction Example() {\n  return (\n    <Popover>\n      <PopoverTrigger asChild>\n        <button>Open</button>\n      </PopoverTrigger>\n      <PopoverContent>\n        This is the content of the popover.\n      </PopoverContent>\n    </Popover>\n  );\n}"}

Positioning

This example shows how to position the popover above the trigger button and align it in the center. The `side` and `align` props are used for positioning.

{"import { Popover, PopoverTrigger, PopoverContent } from '@radix-ui/react-popover';\n\nfunction Example() {\n  return (\n    <Popover>\n      <PopoverTrigger asChild>\n        <button>Open</button>\n      </PopoverTrigger>\n      <PopoverContent side='top' align='center'>\n        This popover appears above the button.\n      </PopoverContent>\n    </Popover>\n  );\n}"}

Customization

This code snippet demonstrates how to customize the appearance of the popover content using CSS-in-JS (in this case, with Stitches). A custom styled component `StyledPopoverContent` is created and used instead of the default `PopoverContent`.

{"import { Popover, PopoverTrigger, PopoverContent } from '@radix-ui/react-popover';\nimport { styled } from '@stitches/react';\n\nconst StyledPopoverContent = styled(PopoverContent, {\n  backgroundColor: 'white',\n  borderRadius: '4px',\n  boxShadow: '0 2px 10px rgba(0,0,0,0.1)'\n});\n\nfunction Example() {\n  return (\n    <Popover>\n      <PopoverTrigger asChild>\n        <button>Open</button>\n      </PopoverTrigger>\n      <StyledPopoverContent>\n        This popover has custom styles.\n      </StyledPopoverContent>\n    </Popover>\n  );\n}"}

Other packages similar to @radix-ui/react-popover

Readme

Source

react-popover

Installation

$ yarn add @radix-ui/react-popover
# or
$ npm install @radix-ui/react-popover

Usage

View docs here.

FAQs

Last updated on 25 Sep 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc