Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-dialog

Package Overview
Dependencies
Maintainers
6
Versions
241
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-dialog

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.2M
increased by13.69%
Maintainers
6
Weekly downloads
 
Created

What is @radix-ui/react-dialog?

The @radix-ui/react-dialog package is a React component library that provides accessible and customizable dialog components. It allows developers to create modal dialogs, which are UI overlays that can contain text, forms, or other interactive elements. These dialogs are often used to capture user input or present information without navigating away from the current page.

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

Basic Dialog

This feature allows you to create a basic modal dialog with a trigger button. When the button is clicked, the dialog opens, displaying the content within a portal overlay. The dialog can be closed with the close button.

{"import * as Dialog from '@radix-ui/react-dialog';\n\nfunction App() {\n  return (\n    <Dialog.Root>\n      <Dialog.Trigger>Open Dialog</Dialog.Trigger>\n      <Dialog.Portal>\n        <Dialog.Overlay />\n        <Dialog.Content>\n          <Dialog.Title>Dialog Title</Dialog.Title>\n          <Dialog.Description>This is a basic dialog example.</Dialog.Description>\n          <Dialog.Close>Close</Dialog.Close>\n        </Dialog.Content>\n      </Dialog.Portal>\n    </Dialog.Root>\n  );\n}"}

Non-modal Dialog

This feature allows you to create a non-modal dialog, which does not lock the user's interaction with the rest of the application. The dialog can be opened and closed similar to a modal, but the background content remains interactive.

{"import * as Dialog from '@radix-ui/react-dialog';\n\nfunction App() {\n  return (\n    <Dialog.Root modal={false}>\n      <Dialog.Trigger>Open Non-modal Dialog</Dialog.Trigger>\n      <Dialog.Content>\n        <Dialog.Title>Non-modal Dialog Title</Dialog.Title>\n        <Dialog.Description>This is a non-modal dialog example.</Dialog.Description>\n        <Dialog.Close>Close</Dialog.Close>\n      </Dialog.Content>\n    </Dialog.Root>\n  );\n}"}

Animated Dialog

This feature demonstrates how to add animations to the dialog's overlay and content when they are being shown. Custom animations are defined using keyframes and applied to the styled components.

{"import * as Dialog from '@radix-ui/react-dialog';\nimport { keyframes, styled } from '@stitches/react';\n\nconst overlayShow = keyframes({\n  '0%': { opacity: 0 },\n  '100%': { opacity: 1 },\n});\n\nconst contentShow = keyframes({\n  '0%': { opacity: 0, transform: 'translate(-50%, -48%) scale(.96)' },\n  '100%': { opacity: 1, transform: 'translate(-50%, -50%) scale(1)' },\n});\n\nconst StyledOverlay = styled(Dialog.Overlay, {\n  animation: `${overlayShow} 150ms cubic-bezier(0.16, 1, 0.3, 1) forwards`,\n});\n\nconst StyledContent = styled(Dialog.Content, {\n  animation: `${contentShow} 150ms cubic-bezier(0.16, 1, 0.3, 1) forwards`,\n});\n\nfunction App() {\n  return (\n    <Dialog.Root>\n      <Dialog.Trigger>Open Animated Dialog</Dialog.Trigger>\n      <Dialog.Portal>\n        <StyledOverlay />\n        <StyledContent>\n          <Dialog.Title>Animated Dialog Title</Dialog.Title>\n          <Dialog.Description>This is an animated dialog example.</Dialog.Description>\n          <Dialog.Close>Close</Dialog.Close>\n        </StyledContent>\n      </Dialog.Portal>\n    </Dialog.Root>\n  );\n}"}

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

FAQs

Package last updated on 13 Dec 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc