🎨
UI Component10M+/wkMIT

@radix-ui/react-slot

Radix UI is a collection of unstyled, accessible React component primitives for building high-quality design systems and web applications. Each component (Dialo

Installation

npm
npm install @radix-ui/react-dialog
yarn
yarn add @radix-ui/react-dialog
pnpm
pnpm add @radix-ui/react-dialog

Import

ESM
import * as Dialog from '@radix-ui/react-dialog';

Quick Example

usage
import * as Dialog from '@radix-ui/react-dialog';

function MyDialog() {
  return (
    <Dialog.Root>
      <Dialog.Trigger>Open</Dialog.Trigger>
      <Dialog.Portal>
        <Dialog.Overlay className="fixed inset-0 bg-black/50" />
        <Dialog.Content className="fixed bg-white rounded-lg p-6">
          <Dialog.Title>Title</Dialog.Title>
          <Dialog.Close>Close</Dialog.Close>
        </Dialog.Content>
      </Dialog.Portal>
    </Dialog.Root>
  );
}

About @radix-ui/react-slot

Radix UI is a collection of unstyled, accessible React component primitives for building high-quality design systems and web applications. Each component (Dialog, Dropdown Menu, Popover, Tabs, Accordion, Toggle, Select, Tooltip, etc.) implements complex interaction patterns, keyboard navigation, focus management, and ARIA attributes correctly while providing zero visual styling. This separation of behavior from appearance gives developers complete control over the look and feel through their preferred styling approach — Tailwind CSS, CSS Modules, styled-components, or vanilla CSS. Each Radix primitive is published as a separate package (@radix-ui/react-dialog, @radix-ui/react-dropdown-menu, etc.) for tree-shaking and minimal bundle impact. Components support controlled and uncontrolled modes, composition through slots and asChild prop for custom element rendering, and animation-friendly APIs with data attributes for entry/exit states. Radix UI is the foundation for shadcn/ui, the most popular React component collection, which adds Tailwind CSS styling on top of Radix primitives. Radix's focus on accessibility means components handle screen reader announcements, keyboard shortcuts, focus trapping in modals, and ARIA attributes automatically, significantly reducing the accessibility effort in application development.

Quick Facts

Package@radix-ui/react-slot
CategoryUI Component
Weekly Downloads10M+
LicenseMIT
Installnpm install @radix-ui/react-dialog

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.