Dialog
adn-ui/dialogFreeComponent
A popup that opens on top of the entire page.
Live preview
live · rendered by the registry
Rendered by adn-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.awaiden.com/r/dialog.jsonSource
1"use client";23import "./dialog.css";4import { Dialog as BaseDialog } from "@base-ui/react/dialog";5import React from "react";6import { cn } from "tailwind-variants";78import { DialogContext, useDialogContext } from "./dialog.context";9import { dialogVariants, type DialogVariants } from "./dialog.variants";1011export type DialogProps = DialogVariants & React.ComponentProps<typeof BaseDialog.Root>;1213export const DialogRoot = ({ children, size, ...props }: DialogProps) => {14 const slots = dialogVariants({ size });1516 return (17 <DialogContext.Provider value={{ slots }}>18 <BaseDialog.Root {...props}>{children}</BaseDialog.Root>19 </DialogContext.Provider>20 );21};2223export type DialogTriggerProps = React.ComponentProps<typeof BaseDialog.Trigger> & {24 render?: React.ReactElement;25 asChild?: boolean;26};2728export const DialogTrigger = ({29 className,30 children,31 render,32 asChild: _asChild,33 ...props34}: DialogTriggerProps) => {35 const { slots } = useDialogContext();36 const renderElement = render ?? (React.isValidElement(children) ? children : undefined);37 return (38 <BaseDialog.Trigger39 className={cn(slots.trigger(), className)}40 {...props}41 {...(renderElement ? { render: renderElement } : { children })}42 />43 );44};4546export type DialogPortalProps = React.ComponentProps<typeof BaseDialog.Portal>;4748export const DialogPortal = (props: DialogPortalProps) => {49 return <BaseDialog.Portal {...props} />;50};5152export type DialogBackdropProps = React.ComponentProps<typeof BaseDialog.Backdrop>;5354export const DialogBackdrop = ({ className, ...props }: DialogBackdropProps) => {55 const { slots } = useDialogContext();56 return <BaseDialog.Backdrop className={cn(slots.backdrop(), className)} {...props} />;57};5859export const DialogOverlay = DialogBackdrop;60export type DialogOverlayProps = DialogBackdropProps;6162export type DialogPopupProps = React.ComponentProps<typeof BaseDialog.Popup>;6364export const DialogPopup = ({ className, ...props }: DialogPopupProps) => {65 const { slots } = useDialogContext();66 return <BaseDialog.Popup className={cn(slots.popup(), className)} {...props} />;67};6869export type DialogTitleProps = React.ComponentProps<typeof BaseDialog.Title>;7071export const DialogTitle = ({ className, ...props }: DialogTitleProps) => {72 const { slots } = useDialogContext();73 return <BaseDialog.Title className={cn(slots.title(), className)} {...props} />;74};7576// … truncated
What it pulls in
npm packages
Files it writes
More from adn-ui
All 46 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | adn-ui | Components | Free | 2 deps · 5 files | |
| Alert Dialogalert-dialog | adn-ui | Components | Free | 2 deps · 5 files | |
| Aspect Ratioaspect-ratio | adn-ui | Components | Free | 1 dep · 5 files | |
| Autocompleteautocomplete | adn-ui | Components | Free | 2 deps · 5 files | |
| Avataravatar | adn-ui | Components | Free | 2 deps · 5 files | |
| Badgebadge | adn-ui | Components | Free | 1 dep · 5 files | |
| Breadcrumbbreadcrumb | adn-ui | Components | Free | 1 dep · 5 files | |
| Buttonbutton | adn-ui | Components | Free | 1 dep · 4 files |
