āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/ibelick/motion-primitives/dialog/page ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
export const metadata = { title: 'Dialog - Motion-Primitives', description: 'A window overlaid on either the primary window or another dialog window, rendering the content underneath inert. Customize the dialog with variants and transition. Built for React, Next.js, and Tailwind CSS.', };
import ComponentCodePreview from '@/components/website/component-code-preview'; import { DialogBasic } from './dialog-basic'; import { DialogControlled } from './dialog-controlled'; import { DialogCustomVariantsTransition } from './dialog-custom-variants-transtion'; import { DialogCustomExit } from './dialog-custom-exit'; import { DialogCustomBackdrop } from './dialog-custom-backdrop';
A window overlaid on either the primary window or another dialog window, rendering the content underneath inert. Customize the dialog with variants and transition.
<ComponentCodePreview component={<DialogBasic />} filePath='app/docs/dialog/dialog-basic.tsx' />
You can control the open state of the dialog using the open and onOpenChange props.
<ComponentCodePreview component={<DialogControlled />} filePath='app/docs/dialog/dialog-controlled.tsx' />
<ComponentCodePreview component={<DialogCustomVariantsTransition />} filePath='app/docs/dialog/dialog-custom-variants-transtion.tsx' />
You can customize the exit animation by providing a custom exit variant.
<ComponentCodePreview component={<DialogCustomExit />} filePath='app/docs/dialog/dialog-custom-exit.tsx' />
You can customize the backdrop using the backdrop: prefix on DialogContent, e.g., backdrop:bg-white/20.
<ComponentCodePreview component={<DialogCustomBackdrop />} filePath='app/docs/dialog/dialog-custom-backdrop.tsx' />
<Step>Copy and paste the following code into your project.</Step>
<CodeBlock filePath='components/core/dialog.tsx' /><Step>Update the import paths to match your project setup.</Step>
</Steps> </TabsContent> </Tabs>| Prop | Type | Default | Description |
| :----------- | :------------------------ | :------- | :------------------------------------------------------------------------------------------------------------ |
| children | ReactNode | required | Children to be rendered within the dialog. |
| variants | Variants | | Variants for controlling the animation states with specific properties for initial, animate, and exit states. |
| transition | Transition | | Transition settings from framer-motion for animation effects. |
| className | string | | Optional CSS class for styling the dialog container. |
| defaultOpen | boolean | false | If true, the dialog will be open by default. |
| onOpenChange | (open: boolean) => void | | Callback function that is called when the dialog's open state changes. |
| open | boolean | | Controlled open state of the dialog. |
| Prop | Type | Default | Description | | :-------- | :-------- | :------- | :---------------------------------------------------- | | children | ReactNode | required | The content to be rendered inside the trigger button. | | className | string | | Optional CSS class for styling the trigger button. |
| Prop | Type | Default | Description | | :-------- | :---------- | :------------ | :------------------------------------------------------ | | children | ReactNode | required | The content to be rendered inside the dialog. | | className | string | | Optional CSS class for styling the dialog content. | | container | HTMLElement | document.body | Specify a container element to portal the content into. |
| Prop | Type | Default | Description | | :-------- | :-------- | :------- | :--------------------------------------------------- | | children | ReactNode | required | The content to be rendered inside the dialog header. | | className | string | | Optional CSS class for styling the dialog header. |
| Prop | Type | Default | Description | | :-------- | :-------- | :------- | :-------------------------------------------------- | | children | ReactNode | required | The title content to be rendered inside the dialog. | | className | string | | Optional CSS class for styling the dialog title. |
| Prop | Type | Default | Description | | :-------- | :-------- | :------- | :-------------------------------------------------------- | | children | ReactNode | required | The description content to be rendered inside the dialog. | | className | string | | Optional CSS class for styling the dialog description. |
| Prop | Type | Default | Description |
| :-------- | :-------- | :------ | :----------------------------------------------------------------------------------------------------------- |
| className | string | | Optional CSS class for styling the close button. |
| children | ReactNode | | Optional content to be rendered inside the close button. If not provided, a default close icon will be used. |
| disabled | boolean | | If true, the close button will be disabled. |
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā