Dialog
import * as Dialog from '@dxos/react-ui/Dialog';A dialog is a modal window for a task the user finishes or cancels before going on. It opens above the page, in a portal, and the page behind it is inert until it closes.
import * as import Button
Button from '@dxos/react-ui/Button';import * as import Dialog
Dialog from '@dxos/react-ui/Dialog';import * as import Field
Field from '@dxos/react-ui/Field';import * as import Input
Input from '@dxos/react-ui/Input';
export const const EditDialog: () => React.JSX.Element
EditDialog = () => ( <import Dialog
Dialog.function Root({ lazyMount, unmountOnExit, closeOnInteractOutside, placement, ...props }: Dialog.RootProps): React.JSX.Element
export Root
Root> <import Dialog
Dialog.const Trigger: React.ForwardRefExoticComponent<DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>export Trigger
Use asChild to open the dialog from a Button.
Trigger PolymorphicProps.asChild?: boolean | undefined
Use the provided child element as the default rendered element, combining their props and behavior.
asChild> <import Button
Button.const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & { classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLButtonElement>>export Root
Root>Edit contact</import Button
Button.const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & { classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLButtonElement>>export Root
Root> </import Dialog
Dialog.const Trigger: React.ForwardRefExoticComponent<DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>export Trigger
Use asChild to open the dialog from a Button.
Trigger> <import Dialog
Dialog.const Content: React.ForwardRefExoticComponent<Omit<DialogContentProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & { size?: Size; container?: React.RefObject<HTMLElement | null>; placement?: Dialog.Placement; scrim?: boolean; closeOnInteractOutside?: boolean;} & React.RefAttributes<HTMLDivElement>>export Content
Portalled surface at level='raised' over a scrim, centred in the viewport: a column of Header, Body and Footer.
Content> <import Dialog
Dialog.const Header: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & React.RefAttributes<HTMLDivElement>>export Header
A block row holding the Title and an optional trailing CloseTrigger.
Header> <import Dialog
Dialog.const Title: React.ForwardRefExoticComponent<Omit<DialogTitleProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & { srOnly?: boolean;} & React.RefAttributes<HTMLHeadingElement>>export Title
Title>Edit contact</import Dialog
Dialog.const Title: React.ForwardRefExoticComponent<Omit<DialogTitleProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & { srOnly?: boolean;} & React.RefAttributes<HTMLHeadingElement>>export Title
Title> <import Dialog
Dialog.const CloseTrigger: React.ForwardRefExoticComponent<Omit<DialogCloseTriggerProps, "children"> & { children?: React.ReactNode; icon?: string; label?: string;} & React.RefAttributes<HTMLButtonElement>>export CloseTrigger
CloseTrigger /> </import Dialog
Dialog.const Header: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & React.RefAttributes<HTMLDivElement>>export Header
A block row holding the Title and an optional trailing CloseTrigger.
Header> <import Dialog
Dialog.const Body: React.ForwardRefExoticComponent<Omit<Pick<ScrollArea.RootProps, "mode" | "native" | "width">, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<Layout.ContainerProps, "gap"> & { align?: "start" | "center"; children?: React.ReactNode;} & React.RefAttributes<HTMLDivElement>>export Body
Composed scroll (decision 5): a gutter='md' Container as the viewport, so the thumb sits in the end gutter; gap
spaces its rows, since they are the Container's own items.
The element carries ScrollArea's data-scope, since parts cannot rescope a composed child (finding 10).
Body> <import Dialog
Dialog.const Description: React.ForwardRefExoticComponent<Omit<DialogDescriptionProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & { srOnly?: boolean;} & React.RefAttributes<HTMLParagraphElement>>export Description
Description> Changes are saved when you press Save. </import Dialog
Dialog.const Description: React.ForwardRefExoticComponent<Omit<DialogDescriptionProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & { srOnly?: boolean;} & React.RefAttributes<HTMLParagraphElement>>export Description
Description> <import Field
Field.const Root: React.ForwardRefExoticComponent<Omit<FieldRootProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & { validationValence?: Field.Valence; layout?: "stack" | "row" | "inline"; level?: Layout.Level; span?: Layout.Span; tone?: "muted";} & React.RefAttributes<HTMLDivElement>>export Root
A part, not a container (decision 13): a flex stack in the content track with the label above its control.
Root> <import Field
Field.const Label: React.ForwardRefExoticComponent<Omit<FieldLabelProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & { srOnly?: boolean;} & React.RefAttributes<HTMLLabelElement>>export Label
Names the control; while the root is required it ends with the required indicator, unless a
RequiredIndicator among its children places the mark itself.
Label>Name</import Field
Field.const Label: React.ForwardRefExoticComponent<Omit<FieldLabelProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & { srOnly?: boolean;} & React.RefAttributes<HTMLLabelElement>>export Label
Names the control; while the root is required it ends with the required indicator, unless a
RequiredIndicator among its children places the mark itself.
Label> <import Input
Input.const Root: React.ForwardRefExoticComponent<Omit<Input.RootProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLInputElement>>export Root
Text input at control size; inside a Field.Root it takes the field's id, label and description wiring. With
start or end it renders a ControlFrame holding the adornments and a bare input; data-testid and classes then
go to the frame, the ref to the input.
Root defaultValue?: string | number | readonly string[] | undefined
defaultValue='Ada Lovelace' /> </import Field
Field.const Root: React.ForwardRefExoticComponent<Omit<FieldRootProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & { validationValence?: Field.Valence; layout?: "stack" | "row" | "inline"; level?: Layout.Level; span?: Layout.Span; tone?: "muted";} & React.RefAttributes<HTMLDivElement>>export Root
A part, not a container (decision 13): a flex stack in the content track with the label above its control.
Root> </import Dialog
Dialog.const Body: React.ForwardRefExoticComponent<Omit<Pick<ScrollArea.RootProps, "mode" | "native" | "width">, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<Layout.ContainerProps, "gap"> & { align?: "start" | "center"; children?: React.ReactNode;} & React.RefAttributes<HTMLDivElement>>export Body
Composed scroll (decision 5): a gutter='md' Container as the viewport, so the thumb sits in the end gutter; gap
spaces its rows, since they are the Container's own items.
The element carries ScrollArea's data-scope, since parts cannot rescope a composed child (finding 10).
Body> <import Dialog
Dialog.const Footer: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & React.RefAttributes<HTMLDivElement>>export Footer
An end-justified Group of actions; the child div wins the merge, so the part keeps the dialog scope. The
actions stay regular-sized in a small dialog, since they are the dialog's primary targets.
Footer> <import Dialog
Dialog.const CloseTrigger: React.ForwardRefExoticComponent<Omit<DialogCloseTriggerProps, "children"> & { children?: React.ReactNode; icon?: string; label?: string;} & React.RefAttributes<HTMLButtonElement>>export CloseTrigger
CloseTrigger asChild?: boolean | undefined
Use the provided child element as the default rendered element, combining their props and behavior.
asChild> <import Button
Button.const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & { classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLButtonElement>>export Root
Root>Cancel</import Button
Button.const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & { classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLButtonElement>>export Root
Root> </import Dialog
Dialog.const CloseTrigger: React.ForwardRefExoticComponent<Omit<DialogCloseTriggerProps, "children"> & { children?: React.ReactNode; icon?: string; label?: string;} & React.RefAttributes<HTMLButtonElement>>export CloseTrigger
CloseTrigger> <import Dialog
Dialog.const CloseTrigger: React.ForwardRefExoticComponent<Omit<DialogCloseTriggerProps, "children"> & { children?: React.ReactNode; icon?: string; label?: string;} & React.RefAttributes<HTMLButtonElement>>export CloseTrigger
CloseTrigger asChild?: boolean | undefined
Use the provided child element as the default rendered element, combining their props and behavior.
asChild> <import Button
Button.const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & { classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLButtonElement>>export Root
Root variant?: Button.Variant | undefined
variant='primary'>Save</import Button
Button.const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & { classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLButtonElement>>export Root
Root> </import Dialog
Dialog.const CloseTrigger: React.ForwardRefExoticComponent<Omit<DialogCloseTriggerProps, "children"> & { children?: React.ReactNode; icon?: string; label?: string;} & React.RefAttributes<HTMLButtonElement>>export CloseTrigger
CloseTrigger> </import Dialog
Dialog.const Footer: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & React.RefAttributes<HTMLDivElement>>export Footer
An end-justified Group of actions; the child div wins the merge, so the part keeps the dialog scope. The
actions stay regular-sized in a small dialog, since they are the dialog's primary targets.
Footer> </import Dialog
Dialog.const Content: React.ForwardRefExoticComponent<Omit<DialogContentProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & { size?: Size; container?: React.RefObject<HTMLElement | null>; placement?: Dialog.Placement; scrim?: boolean; closeOnInteractOutside?: boolean;} & React.RefAttributes<HTMLDivElement>>export Content
Portalled surface at level='raised' over a scrim, centred in the viewport: a column of Header, Body and Footer.
Content> </import Dialog
Dialog.function Root({ lazyMount, unmountOnExit, closeOnInteractOutside, placement, ...props }: Dialog.RootProps): React.JSX.Element
export Root
Root>);
The parts are Dialog.Root, Dialog.Trigger, Dialog.Content, Dialog.Header, Dialog.Title,
Dialog.Description, Dialog.Body, Dialog.Footer and Dialog.CloseTrigger.
- Use
openandonOpenChangeonDialog.Rootto open the dialog from code. Dialog.CloseTriggerwith no children is a close button. WithasChild, it makes its child close the dialog.- Use
sizeonDialog.Contentto set the dialog’s size, from'xs'to'xl'. Without it, the dialog takes the size set around its trigger, or'md'. Dialog.Bodyscrolls when the content is taller than the screen.