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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQAumujy5kXaOKurr6zgTP2krHrFVXi2kj8seRYrlvq2GssUjReh5MiVpQbLFQNy9HsmcasqpBNVsXytWTw0ZDjA=

Inputs and actions

By the end of this page the detail column is a form. You can change a contact’s name, email or role, then save or revert.

We build the form from three components:

  • A Field holds one input. It ties the label to the control for screen readers, and lines up labels, help text and errors. Use one around every input that has a label.
  • Input.Root is a text input. Use its type for one kind of text, such as the 'email' of step 1.
  • Select opens a list of options, and the user picks one. Use it when the choices are fixed, as our three roles are.

Input.Root and Select both work controlled, with a value and a change handler, the way React inputs do. Input lists the other controls, such as checkboxes and switches, and Button lists the button variants.

  1. Write the editor. The editor edits a copy of the contact, which it keeps in draft, so nothing changes until Save. We disable Save until the draft differs from the contact, and while the name is empty. Add src/inputs/ContactEditor.tsx:

    import
    (alias) namespace React
    import React
    React
    , {
    function useState<S>(initialState: S | (() => S)): [S, React.Dispatch<React.SetStateAction<S>>] (+1 overload)

    Returns a stateful value, and a function to update it.

    @version ― 16.8.0

    @see ― https://react.dev/reference/react/useState

    useState
    } from 'react';
    import * as
    import Button
    Button
    from '@dxos/react-ui/Button';
    import * as
    import Field
    Field
    from '@dxos/react-ui/Field';
    import * as
    import Input
    Input
    from '@dxos/react-ui/Input';
    import * as
    import Layout
    Layout
    from '@dxos/react-ui/Layout';
    import * as
    import Select
    Select
    from '@dxos/react-ui/Select';
    import { type
    type Contact = {
    id: string;
    name: string;
    email: string;
    role: string;
    }
    Contact
    ,
    const ROLES: Select.Option[]
    ROLES
    } from '../contacts.ts';
    6 collapsed lines
    export type
    type ContactEditorProps = {
    contact: Contact;
    onSave: (contact: Contact) => void;
    }
    ContactEditorProps
    = {
    contact: Contact
    contact
    :
    type Contact = {
    id: string;
    name: string;
    email: string;
    role: string;
    }
    Contact
    ;
    onSave: (contact: Contact) => void
    onSave
    : (
    contact: Contact
    contact
    :
    type Contact = {
    id: string;
    name: string;
    email: string;
    role: string;
    }
    Contact
    ) => void;
    };
    /** Edits a copy of `contact`; nothing changes until Save. */
    export const
    const ContactEditor: ({ contact, onSave }: ContactEditorProps) => React.JSX.Element

    Edits a copy of contact; nothing changes until Save.

    ContactEditor
    = ({
    contact: Contact
    contact
    ,
    onSave: (contact: Contact) => void
    onSave
    }:
    type ContactEditorProps = {
    contact: Contact;
    onSave: (contact: Contact) => void;
    }
    ContactEditorProps
    ) => {
    const [
    const draft: Contact
    draft
    ,
    const setDraft: React.Dispatch<React.SetStateAction<Contact>>
    setDraft
    ] =
    useState<Contact>(initialState: Contact | (() => Contact)): [Contact, React.Dispatch<React.SetStateAction<Contact>>] (+1 overload)

    Returns a stateful value, and a function to update it.

    @version ― 16.8.0

    @see ― https://react.dev/reference/react/useState

    useState
    (
    contact: Contact
    contact
    );
    const
    const changed: boolean
    changed
    =
    var JSON: JSON

    An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

    JSON
    .
    JSON.stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string (+1 overload)

    Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

    @param ― value A JavaScript value, usually an object or array, to be converted.

    @param ― replacer A function that transforms the results.

    @param ― space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.

    @throws ― {TypeError} If a circular reference or a BigInt value is found.

    stringify
    (
    const draft: Contact
    draft
    ) !==
    var JSON: JSON

    An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

    JSON
    .
    JSON.stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string (+1 overload)

    Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

    @param ― value A JavaScript value, usually an object or array, to be converted.

    @param ― replacer A function that transforms the results.

    @param ― space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.

    @throws ― {TypeError} If a circular reference or a BigInt value is found.

    stringify
    (
    contact: Contact
    contact
    );
    return (
    <
    import Layout
    Layout
    .
    const Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>

    One-axis layout box: the primitive that replaces hand-written flex … wrapper divs.

    gap is restricted to the named steps of the theme spacing ramp (see

    Gap

    ), which is the point of the prop — an off-ramp gap-2/gap-3 literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes through classNames; the component deliberately grows no padding or colour props, since components own their own spacing.

    There is no implicit align. Row-centering is the common case, but defaulting it would silently restyle any consumer relying on the CSS stretch initial value.

    Use asChild to project the layout onto a semantic element (<header>, <ul>, <a>).

    @example

    <Flex column gap='sm'>…</Flex>
    <Flex gap='sm' justify='end'>…</Flex>
    <Flex center classNames='h-full text-fg-subtle' role='status'>{t('empty.message')}</Flex>

    Flex
    column?: boolean | undefined

    Stack on the block axis instead of the inline axis.

    column
    gap?: Layout.Gap | undefined
    gap
    ='form'>
    <
    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>, "children" | "role" | "style"> & 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
    value?: string | number | readonly string[] | undefined
    value
    ={
    const draft: Contact
    draft
    .
    name: string
    name
    }
    onChange?: React.ChangeEventHandler<HTMLInputElement, HTMLInputElement> | undefined
    onChange
    ={(
    event: React.ChangeEvent<HTMLInputElement, HTMLInputElement>
    event
    ) =>
    const setDraft: (value: React.SetStateAction<Contact>) => void
    setDraft
    ({ ...
    const draft: Contact
    draft
    ,
    name: string
    name
    :
    event: React.ChangeEvent<HTMLInputElement, HTMLInputElement>
    event
    .
    React.ChangeEvent<HTMLInputElement, HTMLInputElement>.target: EventTarget & HTMLInputElement
    target
    .
    HTMLInputElement.value: string

    The value property of the HTMLInputElement interface represents the current value of the element as a string.

    MDN Reference

    value
    })} />
    </
    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 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
    >Email</
    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>, "children" | "role" | "style"> & 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
    type?: React.HTMLInputTypeAttribute | undefined
    type
    ='email'
    value?: string | number | readonly string[] | undefined
    value
    ={
    const draft: Contact
    draft
    .
    email: string
    email
    }
    onChange?: React.ChangeEventHandler<HTMLInputElement, HTMLInputElement> | undefined
    onChange
    ={(
    event: React.ChangeEvent<HTMLInputElement, HTMLInputElement>
    event
    ) =>
    const setDraft: (value: React.SetStateAction<Contact>) => void
    setDraft
    ({ ...
    const draft: Contact
    draft
    ,
    email: string
    email
    :
    event: React.ChangeEvent<HTMLInputElement, HTMLInputElement>
    event
    .
    React.ChangeEvent<HTMLInputElement, HTMLInputElement>.target: EventTarget & HTMLInputElement
    target
    .
    HTMLInputElement.value: string

    The value property of the HTMLInputElement interface represents the current value of the element as a string.

    MDN Reference

    value
    })}
    />
    </
    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 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
    >Role</
    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 Select
    Select
    .
    const Root: React.ForwardRefExoticComponent<Omit<Omit<SelectRootProps<Select.Option>, "collection" | "positioning">, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & {
    items: Select.Option[];
    positioning?: Select.Positioning;
    } & React.RefAttributes<HTMLDivElement>>
    export Root

    Ark select over a flat option list (grouped in the popup with ItemGroup); the root takes no box so its trigger is laid out as the parent's child. multiple keeps the popup open while choosing. The popup is at least as wide as the trigger and grows to fit its widest option, up to the viewport's width.

    Root
    items: Select.Option[]
    items
    ={
    const ROLES: Select.Option[]
    ROLES
    }
    value?: string[] | undefined

    The controlled keys of the selected items

    value
    ={[
    const draft: Contact
    draft
    .
    role: string
    role
    ]}
    onValueChange?: ((details: ValueChangeDetails<Select.Option>) => void) | undefined

    The callback fired when the selected item changes.

    onValueChange
    ={({
    ValueChangeDetails<SelectOption>.value: string[]
    value
    : [
    role: string
    role
    ] }) =>
    const setDraft: (value: React.SetStateAction<Contact>) => void
    setDraft
    ({ ...
    const draft: Contact
    draft
    ,
    role: string
    role
    })}
    >
    <
    import Select
    Select
    .
    const Trigger: React.ForwardRefExoticComponent<Omit<Omit<SelectTriggerProps, "children">, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & {
    placeholder?: string;
    loading?: boolean;
    fixed?: boolean;
    tag?: boolean;
    icon?: string;
    } & React.RefAttributes<HTMLButtonElement>>
    export Trigger

    Shows the chosen option (its icon when exactly one is chosen; multiple lists the labels) and a caret.

    Trigger
    />
    <
    import Select
    Select
    .
    const Content: React.ForwardRefExoticComponent<Omit<SelectContentProps, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & {
    size?: Size;
    container?: React.RefObject<HTMLElement | null>;
    } & React.RefAttributes<HTMLDivElement>>
    export Content

    Portalled listbox at level='popup', scrolling in a thin ScrollArea whose viewport is the listbox itself.

    Content
    >
    {
    const ROLES: Select.Option[]
    ROLES
    .
    Array<SelectOption>.map<React.JSX.Element>(callbackfn: (value: Select.Option, index: number, array: Select.Option[]) => React.JSX.Element, thisArg?: any): React.JSX.Element[]

    Calls a defined callback function on each element of an array, and returns an array that contains the results.

    @param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.

    @param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

    map
    ((
    item: Select.Option
    item
    ) => (
    <
    import Select
    Select
    .
    const Item: React.ForwardRefExoticComponent<Omit<Omit<SelectItemProps, "children" | "item">, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & {
    item: Select.Option;
    children?: React.ReactNode;
    } & React.RefAttributes<HTMLDivElement>>
    export Item

    A block-tall row: without children, the option's icon, its label and the check shown while it is selected.

    Item
    React.Attributes.key?: React.Key | null | undefined
    key
    ={
    item: Select.Option
    item
    .
    value: string
    value
    }
    item: Select.Option
    item
    ={
    item: Select.Option
    item
    } />
    ))}
    </
    import Select
    Select
    .
    const Content: React.ForwardRefExoticComponent<Omit<SelectContentProps, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & {
    size?: Size;
    container?: React.RefObject<HTMLElement | null>;
    } & React.RefAttributes<HTMLDivElement>>
    export Content

    Portalled listbox at level='popup', scrolling in a thin ScrollArea whose viewport is the listbox itself.

    Content
    >
    </
    import Select
    Select
    .
    const Root: React.ForwardRefExoticComponent<Omit<Omit<SelectRootProps<Select.Option>, "collection" | "positioning">, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & {
    items: Select.Option[];
    positioning?: Select.Positioning;
    } & React.RefAttributes<HTMLDivElement>>
    export Root

    Ark select over a flat option list (grouped in the popup with ItemGroup); the root takes no box so its trigger is laid out as the parent's child. multiple keeps the popup open while choosing. The popup is at least as wide as the trigger and grows to fit its widest option, up to the viewport's width.

    Root
    >
    </
    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 Layout
    Layout
    .
    const Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>

    One-axis layout box: the primitive that replaces hand-written flex … wrapper divs.

    gap is restricted to the named steps of the theme spacing ramp (see

    Gap

    ), which is the point of the prop — an off-ramp gap-2/gap-3 literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes through classNames; the component deliberately grows no padding or colour props, since components own their own spacing.

    There is no implicit align. Row-centering is the common case, but defaulting it would silently restyle any consumer relying on the CSS stretch initial value.

    Use asChild to project the layout onto a semantic element (<header>, <ul>, <a>).

    @example

    <Flex column gap='sm'>…</Flex>
    <Flex gap='sm' justify='end'>…</Flex>
    <Flex center classNames='h-full text-fg-subtle' role='status'>{t('empty.message')}</Flex>

    Flex
    gap?: Layout.Gap | undefined
    gap
    ='sm'
    justify?: Layout.Justify | undefined
    justify
    ='end'>
    <
    import Button
    Button
    .
    const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & {
    classNames?: ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLButtonElement>>
    export Root
    Root
    disabled?: boolean | undefined
    disabled
    ={!
    const changed: boolean
    changed
    }
    onClick?: React.MouseEventHandler<HTMLButtonElement> | undefined
    onClick
    ={() =>
    const setDraft: (value: React.SetStateAction<Contact>) => void
    setDraft
    (
    contact: Contact
    contact
    )}>
    Revert
    </
    import Button
    Button
    .
    const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & {
    classNames?: ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLButtonElement>>
    export Root
    Root
    >
    <
    import Button
    Button
    .
    const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & {
    classNames?: ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLButtonElement>>
    export Root
    Root
    variant?: Button.Variant | undefined
    variant
    ='primary'
    disabled?: boolean | undefined
    disabled
    ={!
    const changed: boolean
    changed
    ||
    const draft: Contact
    draft
    .
    name: string
    name
    .
    String.trim(): string

    Removes the leading and trailing white space and line terminator characters from a string.

    trim
    () === ''}
    onClick?: React.MouseEventHandler<HTMLButtonElement> | undefined
    onClick
    ={() =>
    onSave: (contact: Contact) => void
    onSave
    (
    const draft: Contact
    draft
    )}>
    Save
    </
    import Button
    Button
    .
    const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & {
    classNames?: ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLButtonElement>>
    export Root
    Root
    >
    </
    import Layout
    Layout
    .
    const Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>

    One-axis layout box: the primitive that replaces hand-written flex … wrapper divs.

    gap is restricted to the named steps of the theme spacing ramp (see

    Gap

    ), which is the point of the prop — an off-ramp gap-2/gap-3 literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes through classNames; the component deliberately grows no padding or colour props, since components own their own spacing.

    There is no implicit align. Row-centering is the common case, but defaulting it would silently restyle any consumer relying on the CSS stretch initial value.

    Use asChild to project the layout onto a semantic element (<header>, <ul>, <a>).

    @example

    <Flex column gap='sm'>…</Flex>
    <Flex gap='sm' justify='end'>…</Flex>
    <Flex center classNames='h-full text-fg-subtle' role='status'>{t('empty.message')}</Flex>

    Flex
    >
    </
    import Layout
    Layout
    .
    const Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>

    One-axis layout box: the primitive that replaces hand-written flex … wrapper divs.

    gap is restricted to the named steps of the theme spacing ramp (see

    Gap

    ), which is the point of the prop — an off-ramp gap-2/gap-3 literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes through classNames; the component deliberately grows no padding or colour props, since components own their own spacing.

    There is no implicit align. Row-centering is the common case, but defaulting it would silently restyle any consumer relying on the CSS stretch initial value.

    Use asChild to project the layout onto a semantic element (<header>, <ul>, <a>).

    @example

    <Flex column gap='sm'>…</Flex>
    <Flex gap='sm' justify='end'>…</Flex>
    <Flex center classNames='h-full text-fg-subtle' role='status'>{t('empty.message')}</Flex>

    Flex
    >
    );
    };

    gap='form' is the spacing the theme uses between fields. A Select’s value is a list, because a select can allow several choices, so onValueChange takes its first item.

  2. Put the editor in the detail column. The screen now holds the contacts with setContacts, and Save replaces the one that changed. Add src/inputs/ContactsScreen.tsx, which reuses ContactList from the last page, and render this ContactsScreen from src/main.tsx:

    import
    (alias) namespace React
    import React
    React
    , {
    function useState<S>(initialState: S | (() => S)): [S, React.Dispatch<React.SetStateAction<S>>] (+1 overload)

    Returns a stateful value, and a function to update it.

    @version ― 16.8.0

    @see ― https://react.dev/reference/react/useState

    useState
    } from 'react';
    import * as
    import Layout
    Layout
    from '@dxos/react-ui/Layout';
    import * as
    import Panel
    Panel
    from '@dxos/react-ui/Panel';
    import * as
    import ScrollArea
    ScrollArea
    from '@dxos/react-ui/ScrollArea';
    import * as
    import Toolbar
    Toolbar
    from '@dxos/react-ui/Toolbar';
    import { type
    type Contact = {
    id: string;
    name: string;
    email: string;
    role: string;
    }
    Contact
    ,
    const CONTACTS: Contact[]
    CONTACTS
    } from '../contacts.ts';
    import {
    const ContactList: ({ contacts, selected, onSelect }: ContactListProps) => React.JSX.Element

    One row per contact; the list scrolls inside its own viewport.

    ContactList
    } from '../layout/ContactsScreen.tsx';
    import {
    const ContactEditor: ({ contact, onSave }: ContactEditorProps) => React.JSX.Element

    Edits a copy of contact; nothing changes until Save.

    ContactEditor
    } from './ContactEditor.tsx';
    export const
    const ContactsScreen: () => React.JSX.Element
    ContactsScreen
    = () => {
    const [
    const contacts: Contact[]
    contacts
    ,
    const setContacts: React.Dispatch<React.SetStateAction<Contact[]>>
    setContacts
    ] =
    useState<Contact[]>(initialState: Contact[] | (() => Contact[])): [Contact[], React.Dispatch<React.SetStateAction<Contact[]>>] (+1 overload)

    Returns a stateful value, and a function to update it.

    @version ― 16.8.0

    @see ― https://react.dev/reference/react/useState

    useState
    (
    const CONTACTS: Contact[]
    CONTACTS
    );
    const [
    const selected: string
    selected
    ,
    const setSelected: React.Dispatch<React.SetStateAction<string>>
    setSelected
    ] =
    useState<string>(initialState: string | (() => string)): [string, React.Dispatch<React.SetStateAction<string>>] (+1 overload)

    Returns a stateful value, and a function to update it.

    @version ― 16.8.0

    @see ― https://react.dev/reference/react/useState

    useState
    <string>(
    const contacts: Contact[]
    contacts
    [0].
    id: string
    id
    );
    const
    const contact: Contact | undefined
    contact
    =
    const contacts: Contact[]
    contacts
    .
    Array<Contact>.find(predicate: (value: Contact, index: number, obj: Contact[]) => unknown, thisArg?: any): Contact | undefined (+1 overload)

    Returns the value of the first element in the array where predicate is true, and undefined otherwise.

    @param ― predicate find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.

    @param ― thisArg If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

    find
    (({
    id: string
    id
    }) =>
    id: string
    id
    ===
    const selected: string
    selected
    );
    const
    const handleSave: (next: Contact) => void
    handleSave
    = (
    next: Contact
    next
    :
    type Contact = {
    id: string;
    name: string;
    email: string;
    role: string;
    }
    Contact
    ) =>
    const setContacts: (value: React.SetStateAction<Contact[]>) => void
    setContacts
    ((
    contacts: Contact[]
    contacts
    ) =>
    contacts: Contact[]
    contacts
    .
    Array<Contact>.map<Contact>(callbackfn: (value: Contact, index: number, array: Contact[]) => Contact, thisArg?: any): Contact[]

    Calls a defined callback function on each element of an array, and returns an array that contains the results.

    @param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.

    @param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

    map
    ((
    contact: Contact
    contact
    ) => (
    contact: Contact
    contact
    .
    id: string
    id
    ===
    next: Contact
    next
    .
    id: string
    id
    ?
    next: Contact
    next
    :
    contact: Contact
    contact
    )));
    return (
    <
    import Panel
    Panel
    .
    const Root: React.ForwardRefExoticComponent<Omit<Panel.RootProps & {
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Root

    The plank host: fills its parent, sets data-size and a level for its subtree, and is the pane's query container, so its header, body and footer collapse at the same pane width.

    Root
    >
    <
    import Panel
    Panel
    .
    const Header: React.ForwardRefExoticComponent<Omit<{
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Header

    The top row on the bar aspect, which steps off whatever level hosts the panel; it sizes to its content, so it takes no space when empty and one block when it holds a Toolbar.Root.

    Header
    >
    <
    import Toolbar
    Toolbar
    .
    const Root: React.ForwardRefExoticComponent<Omit<Toolbar.RootProps & {
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Root

    role=toolbar with the roving focus that role promises (decision 9); items that overflow scroll along its axis in a thin ScrollArea whose bar shows on hover, the toolbar itself being the viewport.

    Root
    >
    <
    import Toolbar
    Toolbar
    .
    const Text: React.ForwardRefExoticComponent<Omit<{
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Text

    A run of text that takes the free space and truncates; not an item, so roving focus skips it.

    Text
    >Contacts</
    import Toolbar
    Toolbar
    .
    const Text: React.ForwardRefExoticComponent<Omit<{
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Text

    A run of text that takes the free space and truncates; not an item, so roving focus skips it.

    Text
    >
    <
    import Toolbar
    Toolbar
    .
    const Separator: React.ForwardRefExoticComponent<Omit<Toolbar.SeparatorProps, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Separator

    A rule across the toolbar's axis (vertical in a horizontal toolbar), or with variant='gap' a growing spacer; not an item, so roving focus skips it.

    Separator
    variant?: "gap" | "line" | undefined

    gap is an empty spacer that grows, pushing the items after it to the toolbar's end.

    variant
    ='gap' />
    <
    import Toolbar
    Toolbar
    .
    const Text: React.ForwardRefExoticComponent<Omit<{
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Text

    A run of text that takes the free space and truncates; not an item, so roving focus skips it.

    Text
    >{
    const contacts: Contact[]
    contacts
    .
    Array<Contact>.length: number

    Gets or sets the length of the array. This is a number one higher than the highest index in the array.

    length
    } contacts</
    import Toolbar
    Toolbar
    .
    const Text: React.ForwardRefExoticComponent<Omit<{
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Text

    A run of text that takes the free space and truncates; not an item, so roving focus skips it.

    Text
    >
    </
    import Toolbar
    Toolbar
    .
    const Root: React.ForwardRefExoticComponent<Omit<Toolbar.RootProps & {
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Root

    role=toolbar with the roving focus that role promises (decision 9); items that overflow scroll along its axis in a thin ScrollArea whose bar shows on hover, the toolbar itself being the viewport.

    Root
    >
    </
    import Panel
    Panel
    .
    const Header: React.ForwardRefExoticComponent<Omit<{
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Header

    The top row on the bar aspect, which steps off whatever level hosts the panel; it sizes to its content, so it takes no space when empty and one block when it holds a Toolbar.Root.

    Header
    >
    <
    import Panel
    Panel
    .
    const Body: React.ForwardRefExoticComponent<Omit<{
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Body

    The growing middle row, a plain slot: it neither scrolls nor adds a gutter, so content composes its own frame (asChild onto a ScrollArea.Root around a Container, or a canvas that fills the row). The first Container under it takes the panel's gutter unless it names one. Like the header and footer it is no query container, so its content collapses against the panel.

    Body
    asChild?: boolean | undefined
    asChild
    >
    <
    import Layout
    Layout
    .
    const Grid: React.ForwardRefExoticComponent<Omit<Layout.GridProps & {
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>

    CSS grid container.

    cols/rows take a count for equal tracks, or a list of tokens for anything asymmetric: cols={['fill', 'min']} is grid-cols-[1fr_min-content], with the flexible track allowed to shrink so long content truncates rather than widening the grid. The tokens are typed, so a misspelt track is a compile error rather than an invalid template.

    subgrid adopts the parent's tracks and spans them (grid-column: 1 / -1), which is the only way it is ever useful; the parent must actually define those tracks. Check Column.Row and Card.Row first — both already are 3-track subgrid rows.

    gap is restricted to the named steps of the theme spacing ramp (see

    Gap

    ). As with Flex, padding, sizing, and colour go through classNames rather than growing props here.

    @example

    <Grid cols={3} gap='sm'>…</Grid>
    <Grid cols={['fill', 'auto']} gap='md' align='center'>…</Grid>
    <Grid cols={['18rem', 'fill']}>…</Grid>
    <Grid cols='subgrid' gap='sm' align='center'>…</Grid>

    Grid
    cols?: Layout.GridTracks | undefined
    cols
    ={['16rem', 'fill']}
    grow?: boolean | undefined

    Fill and clip the parent (dx-expand); off by default, as Flex's is, so a grid sizes to its content.

    grow
    >
    <
    const ContactList: ({ contacts, selected, onSelect }: ContactListProps) => React.JSX.Element

    One row per contact; the list scrolls inside its own viewport.

    ContactList
    contacts: Contact[]
    contacts
    ={
    const contacts: Contact[]
    contacts
    }
    selected?: string | undefined
    selected
    ={
    const selected: string
    selected
    }
    onSelect: (id: string) => void
    onSelect
    ={
    const setSelected: React.Dispatch<React.SetStateAction<string>>
    setSelected
    } />
    <
    import ScrollArea
    ScrollArea
    .
    const Root: React.ForwardRefExoticComponent<Omit<ScrollArea.RootProps & {
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Root

    Non-scrolling frame: hosts the overlay thumbs and is the query container for its content.

    Root
    >
    <
    import ScrollArea
    ScrollArea
    .
    const Viewport: React.ForwardRefExoticComponent<Omit<ScrollArea.ViewportProps & {
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Viewport

    The scrolling element; under asChild it is the child (e.g. a Container) itself.

    Viewport
    classNames?: ClassNameValue
    classNames
    ='p-4'>
    {
    const contact: Contact | undefined
    contact
    && <
    const ContactEditor: ({ contact, onSave }: ContactEditorProps) => React.JSX.Element

    Edits a copy of contact; nothing changes until Save.

    ContactEditor
    React.Attributes.key?: React.Key | null | undefined
    key
    ={
    const contact: Contact
    contact
    .
    id: string
    id
    }
    contact: Contact
    contact
    ={
    const contact: Contact
    contact
    }
    onSave: (contact: Contact) => void
    onSave
    ={
    const handleSave: (next: Contact) => void
    handleSave
    } />}
    </
    import ScrollArea
    ScrollArea
    .
    const Viewport: React.ForwardRefExoticComponent<Omit<ScrollArea.ViewportProps & {
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Viewport

    The scrolling element; under asChild it is the child (e.g. a Container) itself.

    Viewport
    >
    </
    import ScrollArea
    ScrollArea
    .
    const Root: React.ForwardRefExoticComponent<Omit<ScrollArea.RootProps & {
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Root

    Non-scrolling frame: hosts the overlay thumbs and is the query container for its content.

    Root
    >
    </
    import Layout
    Layout
    .
    const Grid: React.ForwardRefExoticComponent<Omit<Layout.GridProps & {
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>

    CSS grid container.

    cols/rows take a count for equal tracks, or a list of tokens for anything asymmetric: cols={['fill', 'min']} is grid-cols-[1fr_min-content], with the flexible track allowed to shrink so long content truncates rather than widening the grid. The tokens are typed, so a misspelt track is a compile error rather than an invalid template.

    subgrid adopts the parent's tracks and spans them (grid-column: 1 / -1), which is the only way it is ever useful; the parent must actually define those tracks. Check Column.Row and Card.Row first — both already are 3-track subgrid rows.

    gap is restricted to the named steps of the theme spacing ramp (see

    Gap

    ). As with Flex, padding, sizing, and colour go through classNames rather than growing props here.

    @example

    <Grid cols={3} gap='sm'>…</Grid>
    <Grid cols={['fill', 'auto']} gap='md' align='center'>…</Grid>
    <Grid cols={['18rem', 'fill']}>…</Grid>
    <Grid cols='subgrid' gap='sm' align='center'>…</Grid>

    Grid
    >
    </
    import Panel
    Panel
    .
    const Body: React.ForwardRefExoticComponent<Omit<{
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Body

    The growing middle row, a plain slot: it neither scrolls nor adds a gutter, so content composes its own frame (asChild onto a ScrollArea.Root around a Container, or a canvas that fills the row). The first Container under it takes the panel's gutter unless it names one. Like the header and footer it is no query container, so its content collapses against the panel.

    Body
    >
    </
    import Panel
    Panel
    .
    const Root: React.ForwardRefExoticComponent<Omit<Panel.RootProps & {
    asChild?: boolean;
    }, "className"> & {
    classNames?: import("@dxos/ui-types").ClassNameValue;
    } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
    export Root

    The plank host: fills its parent, sets data-size and a level for its subtree, and is the pane's query container, so its header, body and footer collapse at the same pane width.

    Root
    >
    );
    };

    key={contact.id} gives each contact its own editor. Without it, the editor would keep the last contact’s draft when we choose another.

Change Ada’s name, and Save and Revert become active. Save, and the list shows the new name.

You can build a form from fields, inputs, a select and buttons, and keep its state in React. Next, Overlays moves the editor into a dialog.