A composite component is a TILE component with more than one element, written as a namespace of parts. A dialog, for
example, is Dialog.Root, Dialog.Trigger, Dialog.Content, Dialog.Title and so on. You compose the parts in JSX,
in the shape you want.
If you have used Radix or Ark UI, you already know the shape. Those libraries split a component into parts that you
arrange yourself, where others give you one Dialog and a prop for each thing it can show. TILE does the same.
One entry point, one namespace. Each component is its own entry point of @dxos/react-ui. You import it as a
namespace, the object that holds its parts:
1
import*as Dialog from'@dxos/react-ui/Dialog';
2
import*as Input from'@dxos/react-ui/Input';
A few namespaces group related components. Button holds Root, Group, Menu and Toggle. Input holds Root,
Checkbox, Switch, Textarea and the other controls. Layout and Status each hold several small components,
which Layout and Status list.
Parts. A part is one element of the component. Root holds the state, and renders either no element or the
outer one. The other parts each render one element and read the state from Root through React context.
A part you leave out renders nothing, so you decide what a component shows by the parts you write.
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).
Names the control; while the root is required it ends with the required indicator, unless a
RequiredIndicator among its children places the mark itself.
Names the control; while the root is required it ends with the required indicator, unless a
RequiredIndicator among its children places the mark itself.
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
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).
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.
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.
Dialog.Root takes no props here, so it holds the open state itself. Dialog.Trigger opens the dialog, and each
Dialog.CloseTrigger closes it.
asChild. A part with asChild renders no element of its own. It becomes a slot for its single child, and
passes its props, ref and handlers to that child. Use asChild when the child is already the element you want. In
the example above, Dialog.Trigger asChild makes the Button.Root the trigger, where the trigger would otherwise
wrap it in a second button.
Behavior from state machines. The parts are built on Ark UI, whose components run
zag state machines. The machine owns opening, closing, keyboard handling and the ARIA attributes,
and each part spreads the props the machine gives it.
asChild needs exactly one child element that forwards its ref and spreads its props. A TILE component does both.
A plain function component that drops its props does not. In development, a part such as Panel.Body or
Layout.Flex logs a warning for a child like that.
A part needs its Root above it. Outside one it has no state to read, and it fails.