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

TILE in a PLEX plugin

By the end of this guide you know where TILE code goes in a plugin. You also know the four rules that keep a plugin’s UI consistent with the rest of the app.

A PLEX plugin draws its UI with TILE. PLEX is DXOS’s framework for building an app out of plugins, and Composer, DXOS’s local-first workspace, is built with it. Composer already provides the theme, the provider, the icon sprite and dark mode, so your plugin skips Installation and uses the components directly.

Components take props, and containers connect them

Section titled “Components take props, and containers connect them”

You may already split a React app into components that draw and components that fetch data. A plugin makes the same split, and gives each kind a folder:

  • A component, under src/components/, renders from its props and never reads a capability. It imports TILE and nothing from @dxos/app-framework or @dxos/app-toolkit, so you can show it in a story and reuse it.
  • A container, under src/containers/, is the React component that a PLEX surface renders. It reads capabilities, queries the user’s data and invokes operations, then passes the results to components as props.

A PLEX surface is a named place in the app’s UI that plugins fill, which is not the surface of a TILE token. Surfaces explains how the app picks the container for a place.

Example (Writing a component that takes its data as props)

import * as
import Hooks
Hooks
from '@dxos/react-ui/Hooks';
import * as
import Listbox
Listbox
from '@dxos/react-ui/Listbox';
import * as
import Status
Status
from '@dxos/react-ui/Status';
export type
type ContactListProps = {
contacts: {
id: string;
name: string;
}[];
onSelect?: (id: string) => void;
}
ContactListProps
= {
contacts: {
id: string;
name: string;
}[]
contacts
: {
id: string
id
: string;
name: string
name
: string }[];
onSelect?: ((id: string) => void) | undefined
onSelect
?: (
id: string
id
: string) => void;
};
/** Takes its data and callbacks as props; a container reads them from the app and passes them in. */
export const
const ContactList: ({ contacts, onSelect }: ContactListProps) => React.JSX.Element

Takes its data and callbacks as props; a container reads them from the app and passes them in.

ContactList
= ({
contacts: {
id: string;
name: string;
}[]
contacts
,
onSelect: ((id: string) => void) | undefined
onSelect
}:
type ContactListProps = {
contacts: {
id: string;
name: string;
}[];
onSelect?: (id: string) => void;
}
ContactListProps
) => {
// Every string comes from the plugin's translations.
const {
const t: TFunction<Namespace<string>, KeyPrefix<Namespace<string>>>
t
} =
import Hooks
Hooks
.
function useTranslation(ns?: string | string[] | readonly string[] | undefined, options?: UseTranslationOptions<KeyPrefix<Namespace<string>>> | undefined): {
toString(): string;
toLocaleString(): string;
toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string;
pop(): boolean | TFunction<Namespace<string>, KeyPrefix<Namespace<string>>> | i18n | undefined;
push(...items: (boolean | TFunction<Namespace<string>, KeyPrefix<Namespace<string>>> | i18n)[]): number;
concat(...items: ConcatArray<boolean | TFunction<...> | i18n>[]): (boolean | TFunction<...> | i18n)[];
concat(...items: (boolean | ConcatArray<boolean | TFunction<...> | i18n> | TFunction<...> | i18n)[]): (boolean | TFunction<...> | i18n)[];
join(separator?: string): string;
reverse(): (boolean | TFunction<...> | i18n)[];
shift(): boolean | TFunction<...> | i18n | undefined;
slice(start?: number, end?: number): (boolean | TFunction<...> | i18n)[];
sort(compareFn?: ((a: boolean | TFunction<...> | i18n, b: boolean | TFunction<...> | i18n) => number) | undefined): UseTranslationResponse<...>;
splice(start: number, deleteCount?: number): (boolean | TFunction<...> | i18n)[];
splice(start: number, deleteCount: number, ...items: (boolean | TFunction<...> | i18n)[]): (boolean | TFunction<...> | i18n)[];
unshift(...items: (boolean | TFunction<...> | i18n)[]): number;
indexOf(searchElement: boolean | TFunction<...> | i18n, fromIndex?: number): number;
lastIndexOf(searchElement: boolean | TFunction<...> | i18n, fromIndex?: number): number;
every<S extends boolean | TFunction<...> | i18n>(predicate: (value: boolean | TFunction<...> | i18n, index: number, array: (boolean | TFunction<...> | i18n)[]) => value is S, thisArg?: any): this is S[];
every(predicate: (value: boolean | TFunction<...> | i18n, index: number, array: (boolean | TFunction<...> | i18n)[]) => unknown, thisArg?: any): boolean;
some(predicate: (value: boolean | TFunction<...> | i18n, index: number, array: (boolean | TFunction<...> | i18n)[]) => unknown, thisArg?: any): boolean;
forEach(callbackfn: (value: boolean | TFunction<...> | i18n, index: number, array: (boolean | TFunction<...> | i18n)[]) => void, thisArg?: any): void;
map<U>(callbackfn: (value: boolean | TFunction<...> | i18n, index: number, array: (boolean | TFunction<...> | i18n)[]) => U, thisArg?: any): U[];
filter<S extends boolean | TFunction<...> | i18n>(predicate: (value: boolean | TFunction<...> | i18n, index: number, array: (boolean | TFunction<...> | i18n)[]) => value is S, thisArg?: any): S[];
filter(predicate: (value: boolean | TFunction<...> | i18n, index: number, array: (boolean | TFunction<...> | i18n)[]) => unknown, thisArg?: any): (boolean | TFunction<...> | i18n)[];
reduce(callbackfn: (previousValue: boolean | TFunction<...> | i18n, currentValue: boolean | TFunction<...> | i18n, currentIndex: number, array: (boolean | TFunction<...> | i18n)[]) => boolean | TFunction<...> | i18n): boolean | TFunction<...> | i18n;
reduce(callbackfn: (previousValue: boolean | TFunction<...> | i18n, currentValue: boolean | TFunction<...> | i18n, currentIndex: number, array: (boolean | TFunction<...> | i18n)[]) => boolean | TFunction<...> | i18n, initialValue: boolean | TFunction<...> | i18n): boolean | TFunction<...> | i18n;
reduce<U>(callbackfn: (previousValue: U, currentValue: boolean | TFunction<...> | i18n, currentIndex: number, array: (boolean | TFunction<...> | i18n)[]) => U, initialValue: U): U;
reduceRight(callbackfn: (previousValue: boolean | TFunction<...> | i18n, currentValue: boolean | TFunction<...> | i18n, currentIndex: number, array: (boolean | TFunction<...> | i18n)[]) => boolean | TFunction<...> | i18n): boolean | TFunction<...> | i18n;
reduceRight(callbackfn: (previousValue: boolean | TFunction<...> | i18n, currentValue: boolean | TFunction<...> | i18n, currentIndex: number, array: (boolean | TFunction<...> | i18n)[]) => boolean | TFunction<...> | i18n, initialValue: boolean | TFunction<...> | i18n): boolean | TFunction<...> | i18n;
reduceRight<U>(callbackfn: (previousValue: U, currentValue: boolean | TFunction<...> | i18n, currentIndex: number, array: (boolean | TFunction<...> | i18n)[]) => U, initialValue: U): U;
find<S extends boolean | TFunction<...> | i18n>(predicate: (value: boolean | TFunction<...> | i18n, index: number, obj: (boolean | TFunction<...> | i18n)[]) => value is S, thisArg?: any): S | undefined;
find(predicate: (value: boolean | TFunction<...> | i18n, index: number, obj: (boolean | TFunction<...> | i18n)[]) => unknown, thisArg?: any): boolean | TFunction<...> | i18n | undefined;
findIndex(predicate: (value: boolean | TFunction<...> | i18n, index: number, obj: (boolean | TFunction<...> | i18n)[]) => unknown, thisArg?: any): number;
fill(value: boolean | TFunction<...> | i18n, start?: number, end?: number): UseTranslationResponse<...>;
copyWithin ...
export useTranslation
useTranslation
(
const ns: "com.example.contacts"
ns
);
if (
contacts: {
id: string;
name: string;
}[]
contacts
.
Array<{ id: string; name: string; }>.length: number

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

length
=== 0) {
return (
<
import Status
Status
.
const Empty: React.ForwardRefExoticComponent<Omit<Status.EmptyProps, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>

Stands in for content that is not there (no items, no selection, no result): a centred status message, its text the children or the translated "No items". Composites build their own Empty part on it.

Empty
icon?: string | undefined

A Phosphor icon above the message; decorative, since the message carries the statement.

icon
='ph--address-book--regular'>
{
const t: TFunction
<"empty.message", ReactI18NextChild | Iterable<ReactI18NextChild>, StringMap>(key: "empty.message" | "empty.message"[], options?: string | TOptions<StringMap> | undefined) => ReactI18NextChild | Iterable<ReactI18NextChild> (+1 overload)
t
('empty.message')}
</
import Status
Status
.
const Empty: React.ForwardRefExoticComponent<Omit<Status.EmptyProps, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>

Stands in for content that is not there (no items, no selection, no result): a centred status message, its text the children or the translated "No items". Composites build their own Empty part on it.

Empty
>
);
}
const
const items: {
value: string;
label: string;
}[]
items
=
contacts: {
id: string;
name: string;
}[]
contacts
.
Array<{ id: string; name: string; }>.map<{
value: string;
label: string;
}>(callbackfn: (value: {
id: string;
name: string;
}, index: number, array: {
id: string;
name: string;
}[]) => {
value: string;
label: string;
}, thisArg?: any): {
value: string;
label: string;
}[]

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
(({
id: string
id
,
name: string
name
}) => ({
value: string
value
:
id: string
id
,
label: string
label
:
name: string
name
}));
return (
<
import Listbox
Listbox
.
const Root: React.ForwardRefExoticComponent<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "onSelect" | "defaultValue">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
items: readonly Listbox.Option[];
selectionMode?: Listbox.SelectionMode;
value?: string[];
defaultValue?: string[];
onValueChange?: (value: string[]) => void;
highlightedValue?: string | null;
onHighlightChange?: (value: string | null) => void;
... 8 more ...;
size?: Size;
} & React.RefAttributes<...>>
export Root

Ark listbox: single, multiple or no selection, with keyboard navigation, typeahead and aria-selected from zag. A flex column that caps itself at its parent's height, so a long list scrolls in its Content.

Root
items: readonly Listbox.Option[]
items
={
const items: {
value: string;
label: string;
}[]
items
}
onValueChange?: ((value: string[]) => void) | undefined
onValueChange
={([
id: string
id
]) =>
id: string
id
&&
onSelect: ((id: string) => void) | undefined
onSelect
?.(
id: string
id
)}>
<
import Listbox
Listbox
.
const Viewport: React.ForwardRefExoticComponent<Omit<Pick<ScrollAreaRootProps, "mode" | "native" | "width">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
children: React.ReactNode;
} & React.RefAttributes<HTMLDivElement>>
export Viewport

A thin overlay ScrollArea (decision 5) that grows to fill the Root, for a list that owns its scrolling (a picker, a fixed-height panel). Its Content is the scrolling element, so the thumb sits in the Content's end gutter. Omit it inside a host that already scrolls, which would otherwise trap wheel and trackpad gestures in a nested scroller.

Viewport
>
<
import Listbox
Listbox
.
const Content: React.ForwardRefExoticComponent<Omit<ContainerProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
export Content

The listbox element: zag's content props with the grid keyboard in front of them, a Container's attributes so a Viewport's slot merges onto it, and the Root's virtual windowing over its direct children (the rows). Under a Viewport it is the scrolling element (inset gutter by default); otherwise its host scrolls and the rows inherit the host's rails (inherit). A windowed (virtual) list measures its scroller, so it needs a Viewport.

Content
"aria-label"?: string | undefined

Defines a string value that labels the current element.

@see ― aria-labelledby.

aria-label
={
const t: TFunction
<"list.label", string | undefined, StringMap>(key: "list.label" | "list.label"[], options?: string | TOptions<StringMap> | undefined) => string | undefined (+1 overload)
t
('list.label')}>
{
const items: {
value: string;
label: string;
}[]
items
.
Array<{ value: string; label: string; }>.map<React.JSX.Element>(callbackfn: (value: {
value: string;
label: string;
}, index: number, array: {
value: string;
label: string;
}[]) => 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: {
value: string;
label: string;
}
item
) => (
<
import Listbox
Listbox
.
const Item: React.ForwardRefExoticComponent<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "children">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
item: Listbox.Option;
current?: boolean;
highlightOnHover?: boolean;
children?: React.ReactNode;
} & React.RefAttributes<HTMLDivElement>>
export Item

A row (option) at least one block tall: without children, the option's icon, label and description; with them, the caller's parts, which the theme places by part (leading cells, text over description, then trailing cells) or, under Root columns, in order across the shared tracks. Pointer presses on a row control stay with the control: they neither select the row nor take focus from the control.

Item
Attributes.key?: React.Key | null | undefined
key
={
item: {
value: string;
label: string;
}
item
.
value: string
value
}
item: Listbox.Option
item
={
item: {
value: string;
label: string;
}
item
} />
))}
</
import Listbox
Listbox
.
const Content: React.ForwardRefExoticComponent<Omit<ContainerProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
export Content

The listbox element: zag's content props with the grid keyboard in front of them, a Container's attributes so a Viewport's slot merges onto it, and the Root's virtual windowing over its direct children (the rows). Under a Viewport it is the scrolling element (inset gutter by default); otherwise its host scrolls and the rows inherit the host's rails (inherit). A windowed (virtual) list measures its scroller, so it needs a Viewport.

Content
>
</
import Listbox
Listbox
.
const Viewport: React.ForwardRefExoticComponent<Omit<Pick<ScrollAreaRootProps, "mode" | "native" | "width">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
children: React.ReactNode;
} & React.RefAttributes<HTMLDivElement>>
export Viewport

A thin overlay ScrollArea (decision 5) that grows to fill the Root, for a list that owns its scrolling (a picker, a fixed-height panel). Its Content is the scrolling element, so the thumb sits in the Content's end gutter. Omit it inside a host that already scrolls, which would otherwise trap wheel and trackpad gestures in a nested scroller.

Viewport
>
</
import Listbox
Listbox
.
const Root: React.ForwardRefExoticComponent<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "onSelect" | "defaultValue">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
items: readonly Listbox.Option[];
selectionMode?: Listbox.SelectionMode;
value?: string[];
defaultValue?: string[];
onValueChange?: (value: string[]) => void;
highlightedValue?: string | null;
onHighlightChange?: (value: string | null) => void;
... 8 more ...;
size?: Size;
} & React.RefAttributes<...>>
export Root

Ark listbox: single, multiple or no selection, with keyboard navigation, typeahead and aria-selected from zag. A flex column that caps itself at its parent's height, so a long list scrolls in its Content.

Root
>
);
};

ContactList renders no Panel, because the panel belongs to its container. That container would query the contacts and pass each one’s id and name. It would also pass an onSelect that invokes one of the plugin’s operations.

The container owns the Panel. A container that fills a pane of the app or a dialog renders Panel.Root, with a toolbar in Panel.Header and a scrolling Panel.Body, and puts its components in the body. Layout explains how the body scrolls, and Panel lists the panel’s props.

Lists and forms inside the body own their spacing, so add no padding around them.

You usually build a plugin’s toolbar from its actions with @dxos/react-ui-menu, so that other plugins can add to it. ActionToolbar shows how to build one and how to add another plugin’s actions.

A plugin keeps its strings in a translations.ts resource, in a translation namespace named after the plugin’s key, and registers it in dx.config.ts:

dx.config.ts
AppCapability.translations(() => import('./src/translations.ts', { with: { type: 'module-url' } })),

Components read the strings with Hooks.useTranslation, as ContactList does above. Translations and icons explains resources and namespaces.

These four rules hold for every component and container:

  • Colors and sizes come from tokens and the size prop, never raw values.
  • Overrides go through classNames.
  • Every string a user sees comes from the plugin’s translations.
  • Icons are named in full, ph--<name>--<weight>.