Connect to ECHO
By the end of this page the contacts are objects in ECHO, DXOS’s database. They are stored on the device, and they sync to your other devices and to anyone you share the space with. The edit dialog is a form built from their schema.
Background
Section titled “Background”So far the contacts live in React state, which a reload resets and no other device sees. To move them into ECHO, we change three things from the last page:
- An ECHO type replaces the
Contacttype. ECHO checks and syncs objects of a type it knows. Step 2 adds the type. useQueryreplaces theuseStatethat held the list. It returns the objects that match, and the component renders again when one is added or removed, here or on another device. Step 7 makes the swap.useObjectreads one object. A component that reads an object’s fields this way renders again when that object changes. Steps 4 and 5 use it.
We take the type from ECHO’s own learning path. Its Person has a name, an email and an employer, and no role. The
role select, the role’s tooltip and the role.* strings from the earlier pages therefore have no place on this
screen.
-
Install the React client and the form package.
@dxos/react-clientholds the hooks, and@dxos/react-ui-formholds the form. Until the next npm release, they come from the same build as the packages in Installation:Terminal window npm install \https://pkg.pr.new/dxos/dxos/@dxos/react-client@20a14b9 \https://pkg.pr.new/dxos/dxos/@dxos/react-ui-form@20a14b9npm install --save-dev vite-plugin-wasmThen add the bundler settings from step 2 of ECHO’s Installation to
vite.config.ts, so the database’s worker and WebAssembly load. Those settings usevite-plugin-wasm. -
Use ECHO’s Person type. This is the
Personfrom ECHO’s Defining types, with a name, an optional email and an optional employer. Addsrc/echo/schema.ts. Put that page’sOrganizationtype in it first, becauseemployerrefers to it:import * asSchema from 'effect/Schema';import Schemaimport {Annotation,import AnnotationDXN,import DXNFormat,import FormatRef,import RefType } from '@dxos/echo';import Type15 collapsed lines// The ECHO tutorial's types, unchanged; see /docs/echo/learn/defining-types/.export classOrganization extendsclass OrganizationType.import TypemakeObject<const makeObject: <Organization>(dxn: DXN.DXN, options?: {id?: EntityId;}) => Type.MakeObject<Organization>Factory function to create an ECHO object type.
Returns a
Type.Typeentity — a live, in-memoryTypeSchemainstance, NOT aSchema.Schema. UseType.InstanceType<typeof Foo>for the instance type andType.getSchema(Foo)to obtain the underlying Effect Schema.The entity's id defaults to
EntityId.deterministic(typename, version)so constructing a type never reachescrypto.getRandomValues()— required for Cloudflare workerd, which forbids RNG calls in global (module-evaluation) scope. Pass{ id }to override (e.g. withEntityId.random()from a request handler).Giving the type a nominal class name keeps its inferred type portable for declaration emit: structural expansion (which can pull in unnameable union members from referenced schemas) is replaced by a reference to the class.
The second call takes either a schema, or struct fields (wrapped in
Schema.Struct) with an optional function that pipes annotations onto the struct.Organization>(class OrganizationDXN.import DXNmake('com.example.type.organization', '0.1.0'))(const make: <"com.example.type.organization">(nsid: "com.example.type.organization", version?: string) => DXN.DXNConstructs a DXN from an NSID (and optional version). Throws if the result is not a valid DXN. Use
tryMakefor non-throwing string parsing.Static NSID strings are validated at compile time via
Name
: the final segment must be camelCase (no hyphens). Template-literal strings with a runtime prefix are accepted here but still validated at runtime.
Schema.import SchemaStruct({function Struct<{readonly name: Schema.String;readonly website: Schema.optional<Schema.String>;}>(fields: {readonly name: Schema.String;readonly website: Schema.optional<Schema.String>;}): Schema.Struct<{readonly name: Schema.String;readonly website: Schema.optional<Schema.String>;}>Defines a struct schema from a map of field schemas.
Details
Each field value is a schema. Use
optionalKey
or
optional
to mark fields as optional, and
mutableKey
to mark them as mutable. Field definitions are discovered from own enumerable string and symbol properties of
fields. Non-enumerable and inherited definitions are ignored.The resulting schema's
Typeis a readonly object type with the fields' decoded types. TheEncodedform mirrors the field schemas' encoded types. Declared fields on the input may be non-enumerable or inherited and are copied to own properties in the output. The__proto__field is accepted only when it is an own property. Parsing does not guarantee that output keys retain their input order.Example (Defining a basic struct)
import { Schema } from "effect"const Person = Schema.Struct({name: Schema.String,age: Schema.Number,email: Schema.optionalKey(Schema.String)})// { readonly name: string; readonly age: number; readonly email?: string }type Person = typeof Person.TypeSchema.decodeUnknownSync(Person)({ name: "Alice", age: 30 }) // => { name: "Alice", age: 30 }name:name: Schema.StringSchema.import SchemaString,const String: Schema.StringType-level representation of
String
.
Schema for
stringvalues. Validates that the input istypeof"string".website:website: Schema.optional<Schema.String>Schema.import Schemaoptional(const optional: optionalLambda<Schema.String>(self: Schema.String) => Schema.optional<Schema.String>Type-level representation returned by
optional
.
Marks a struct field as optional, allowing the key to be absent or
undefined.Details
The resulting property may be absent or explicitly set to
undefined. Equivalent tooptionalKey(UndefinedOr(S)).Use
optionalKey
instead if you want exact optional semantics (absent only, not
undefined).Example (Defining an optional field accepting undefined)
import { Schema } from "effect"const schema = Schema.Struct({name: Schema.String,age: Schema.optional(Schema.Number)})// { readonly name: string; readonly age?: number | undefined }type Person = typeof schema.TypeFormat.import FormatURL),const URL: Schema.String}).pipe(Pipeable.pipe<Schema.Struct<{readonly name: Schema.String;readonly website: Schema.optional<Schema.String>;}>, Schema.Struct<{readonly name: Schema.String;readonly website: Schema.optional<Schema.String>;}>>(this: Schema.Struct<...>, ab: (_: Schema.Struct<{readonly name: Schema.String;readonly website: Schema.optional<Schema.String>;}>) => Schema.Struct<{readonly name: Schema.String;readonly website: Schema.optional<Schema.String>;}>): Schema.Struct<...> (+21 overloads)Annotation.import AnnotationIconAnnotation.const IconAnnotation: Annotation.Annotation<Annotation.IconAnnotation>export IconAnnotationIcon to render in the UI.
set({Annotation<IconAnnotation>.set: (value: Annotation.IconAnnotation) => <S extends Schema.Top>(schema: S) => SSet the annotation on an Effect schema.
Only accepts
Schema.Top— annotations must be applied to the source schema BEFORE wrapping it withType.makeObject/Type.makeRelation. In a pipe, place everyAnnotation.X.set(...)before theType.make...step.icon: 'ph--buildings--regular',icon: stringSprite icon name (e.g., 'ph--user--regular', 'ph--cube--regular', 'px--anthropic--regular').
ph--*is Phosphor;px--*anddx--*are brand glyphs, which are sprite-only and carry no weight variants. All three are admitted because a type whose subject IS a brand — an Anthropic session, a GitHub repo — has no honest Phosphor equivalent.hue: 'amber',hue?: string | undefinedColor name.
List of colors:
- 'red'
- 'orange'
- 'amber'
- 'yellow'
- 'lime'
- 'green'
- 'emerald'
- 'teal'
- 'cyan'
- 'violet'
- 'purple'
- 'fuchsia'
- 'pink'
- 'rose'
}),),) {}export classPerson extendsclass PersonType.import TypemakeObject<const makeObject: <Person>(dxn: DXN.DXN, options?: {id?: EntityId;}) => Type.MakeObject<Person>Factory function to create an ECHO object type.
Returns a
Type.Typeentity — a live, in-memoryTypeSchemainstance, NOT aSchema.Schema. UseType.InstanceType<typeof Foo>for the instance type andType.getSchema(Foo)to obtain the underlying Effect Schema.The entity's id defaults to
EntityId.deterministic(typename, version)so constructing a type never reachescrypto.getRandomValues()— required for Cloudflare workerd, which forbids RNG calls in global (module-evaluation) scope. Pass{ id }to override (e.g. withEntityId.random()from a request handler).Giving the type a nominal class name keeps its inferred type portable for declaration emit: structural expansion (which can pull in unnameable union members from referenced schemas) is replaced by a reference to the class.
The second call takes either a schema, or struct fields (wrapped in
Schema.Struct) with an optional function that pipes annotations onto the struct.Person>(class PersonDXN.import DXNmake('com.example.type.person', '0.1.0'))(const make: <"com.example.type.person">(nsid: "com.example.type.person", version?: string) => DXN.DXNConstructs a DXN from an NSID (and optional version). Throws if the result is not a valid DXN. Use
tryMakefor non-throwing string parsing.Static NSID strings are validated at compile time via
Name
: the final segment must be camelCase (no hyphens). Template-literal strings with a runtime prefix are accepted here but still validated at runtime.
Schema.import SchemaStruct({function Struct<{readonly name: Schema.String;readonly email: Schema.optional<Schema.String>;readonly employer: Schema.optional<Ref.RefSchema<Organization & OfKind<EntityKind.Object> & Unknown>>;}>(fields: {readonly name: Schema.String;readonly email: Schema.optional<Schema.String>;readonly employer: Schema.optional<Ref.RefSchema<Organization & OfKind<EntityKind.Object> & Unknown>>;}): Schema.Struct<...>Defines a struct schema from a map of field schemas.
Details
Each field value is a schema. Use
optionalKey
or
optional
to mark fields as optional, and
mutableKey
to mark them as mutable. Field definitions are discovered from own enumerable string and symbol properties of
fields. Non-enumerable and inherited definitions are ignored.The resulting schema's
Typeis a readonly object type with the fields' decoded types. TheEncodedform mirrors the field schemas' encoded types. Declared fields on the input may be non-enumerable or inherited and are copied to own properties in the output. The__proto__field is accepted only when it is an own property. Parsing does not guarantee that output keys retain their input order.Example (Defining a basic struct)
import { Schema } from "effect"const Person = Schema.Struct({name: Schema.String,age: Schema.Number,email: Schema.optionalKey(Schema.String)})// { readonly name: string; readonly age: number; readonly email?: string }type Person = typeof Person.TypeSchema.decodeUnknownSync(Person)({ name: "Alice", age: 30 }) // => { name: "Alice", age: 30 }name:name: Schema.StringSchema.import SchemaString,const String: Schema.StringType-level representation of
String
.
Schema for
stringvalues. Validates that the input istypeof"string".email:email: Schema.optional<Schema.String>Schema.import Schemaoptional(const optional: optionalLambda<Schema.String>(self: Schema.String) => Schema.optional<Schema.String>Type-level representation returned by
optional
.
Marks a struct field as optional, allowing the key to be absent or
undefined.Details
The resulting property may be absent or explicitly set to
undefined. Equivalent tooptionalKey(UndefinedOr(S)).Use
optionalKey
instead if you want exact optional semantics (absent only, not
undefined).Example (Defining an optional field accepting undefined)
import { Schema } from "effect"const schema = Schema.Struct({name: Schema.String,age: Schema.optional(Schema.Number)})// { readonly name: string; readonly age?: number | undefined }type Person = typeof schema.TypeFormat.import FormatEmail),const Email: Schema.StringEmail address (RFC 5321). The local part also allows an apostrophe, which real mail carries (
o'day@corp.com). https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.2employer:employer: Schema.optional<Ref.RefSchema<Organization & OfKind<EntityKind.Object> & Unknown>>Schema.import Schemaoptional(const optional: optionalLambda<Ref.RefSchema<Organization & OfKind<EntityKind.Object> & Unknown>>(self: Ref.RefSchema<Organization & OfKind<EntityKind.Object> & Unknown>) => Schema.optional<Ref.RefSchema<Organization & OfKind<EntityKind.Object> & Unknown>>Type-level representation returned by
optional
.
Marks a struct field as optional, allowing the key to be absent or
undefined.Details
The resulting property may be absent or explicitly set to
undefined. Equivalent tooptionalKey(UndefinedOr(S)).Use
optionalKey
instead if you want exact optional semantics (absent only, not
undefined).Example (Defining an optional field accepting undefined)
import { Schema } from "effect"const schema = Schema.Struct({name: Schema.String,age: Schema.optional(Schema.Number)})// { readonly name: string; readonly age?: number | undefined }type Person = typeof schema.TypeRef.import RefRef(const Ref: <typeof Organization>(type: typeof Organization) => Ref.RefSchema<Organization & OfKind<EntityKind.Object> & Unknown> (+3 overloads)Organization)),class Organization}).pipe(Pipeable.pipe<Schema.Struct<{readonly name: Schema.String;readonly email: Schema.optional<Schema.String>;readonly employer: Schema.optional<Ref.RefSchema<Organization & OfKind<EntityKind.Object> & Unknown>>;}>, Schema.Struct<{readonly name: Schema.String;readonly email: Schema.optional<Schema.String>;readonly employer: Schema.optional<Ref.RefSchema<Organization & OfKind<EntityKind.Object> & Unknown>>;}>>(this: Schema.Struct<...>, ab: (_: Schema.Struct<...>) => Schema.Struct<...>): Schema.Struct<...> (+21 overloads)Annotation.import AnnotationIconAnnotation.const IconAnnotation: Annotation.Annotation<Annotation.IconAnnotation>export IconAnnotationIcon to render in the UI.
set({Annotation<IconAnnotation>.set: (value: Annotation.IconAnnotation) => <S extends Schema.Top>(schema: S) => SSet the annotation on an Effect schema.
Only accepts
Schema.Top— annotations must be applied to the source schema BEFORE wrapping it withType.makeObject/Type.makeRelation. In a pipe, place everyAnnotation.X.set(...)before theType.make...step.icon: 'ph--user--regular',icon: stringSprite icon name (e.g., 'ph--user--regular', 'ph--cube--regular', 'px--anthropic--regular').
ph--*is Phosphor;px--*anddx--*are brand glyphs, which are sprite-only and carry no weight variants. All three are admitted because a type whose subject IS a brand — an Anthropic session, a GitHub repo — has no honest Phosphor equivalent.hue: 'cyan' })),hue?: string | undefinedColor name.
List of colors:
- 'red'
- 'orange'
- 'amber'
- 'yellow'
- 'lime'
- 'green'
- 'emerald'
- 'teal'
- 'cyan'
- 'violet'
- 'purple'
- 'fuchsia'
- 'pink'
- 'rose'
) {} -
Query the people. The query selects every
Person, sorted by name. Addsrc/echo/ContactsScreen.tsx:import { typeDatabase,import DatabaseFilter,import FilterObj,import ObjOrder,import OrderQuery } from '@dxos/echo';import Query15 collapsed linesimport {useObject,const useObject: {<T extends Obj.Unknown>(ref: Ref<T>): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(ref: Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(ref: Ref<T> | undefined, options: LoadOptions): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(obj: T): [Obj.Snapshot<T>, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(obj: T | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(objOrRef: T | Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown, K extends keyof T>(obj: T, property: K): [T[K], ObjectPropUpdateCallback<T[K]>];<T extends Obj.Unknown, K extends keyof T>(obj: T | undefined, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];<T, K extends keyof T>(ref: Ref<T>, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];<T, K extends keyof T>(ref: Ref<T> | undefined, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];}useQuery } from '@dxos/react-client/echo';const useQuery: UseQueryFnCreate subscription.
import {ObjectForm } from '@dxos/react-ui-form';const ObjectForm: ({ object, type, schema, showTags }: ObjectFormProps) => React.JSX.ElementAn object's properties (and meta tags) as a next Form in its host's grid, writing each change back.
import * asButton from '@dxos/react-ui/Button';import Buttonimport * asDialog from '@dxos/react-ui/Dialog';import Dialogimport * asHooks from '@dxos/react-ui/Hooks';import Hooksimport * asIcon from '@dxos/react-ui/Icon';import Iconimport * asLayout from '@dxos/react-ui/Layout';import Layoutimport * asListbox from '@dxos/react-ui/Listbox';import Listboximport * asPanel from '@dxos/react-ui/Panel';import Panelimport * asStatus from '@dxos/react-ui/Status';import Statusimport * asToolbar from '@dxos/react-ui/Toolbar';import Toolbarimport * asTypography from '@dxos/react-ui/Typography';import Typographyimport {ns } from '../icons/translations.ts';const ns: "com.example.contacts"import {DeletePopover } from '../overlays/ContactsScreen.tsx';const DeletePopover: ({ label, onDelete }: DeletePopoverProps) => React.JSX.Elementimport {Person } from './schema.ts';class Personconstpeople =const people: Query.Query<Person & OfKind<EntityKind.Object>>Query.import Queryselect(const select: <Filter.Filter<Person & OfKind<EntityKind.Object>>>(filter: Filter.Filter<Person & OfKind<EntityKind.Object>>) => Query.Query<Person & OfKind<EntityKind.Object>>Select objects based on a filter.
Filter.import Filtertype(const type: <typeof Person>(type: typeof Person, props?: Filter.Props<Person & OfKind<EntityKind.Object>> | undefined) => Filter.Filter<Person & OfKind<EntityKind.Object>> (+4 overloads)Person)).class PersonorderBy(Query<Person & OfKind<EntityKind.Object>>.orderBy(order_0: Order.Order<Person & OfKind<EntityKind.Object>>, ...order: Order.Order<Person & OfKind<EntityKind.Object>>[]): Query.Query<Person & OfKind<EntityKind.Object>>Order the query results. Orders are specified in priority order. The first order will be applied first, etc.
Order.propertyorders by the current result shape's fields, so it works both before and after anaggregate
: before, by member (row) properties; after, by the flat record's fields (any group or aggregate field — e.g.
Order.property('lastMessageAt')reorders the groups by that aggregate).Order.import Orderproperty<const property: <Person>(property: "~@dxos/echo/Kind" | "email" | "employer" | "name" | "id", direction: OrderDirection) => Order.Order<Person>Order by a property of the current result shape.
Person>('name', 'asc'));class Personpeopleonly describes the query. Nothing reads the database until step 7 passes it touseQuery. -
List them. The list is the same
Listboxas before. Each row reads its person withuseObject, so a rename shows in the list at once:import {useObject,const useObject: {<T extends Obj.Unknown>(ref: Ref<T>): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(ref: Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(ref: Ref<T> | undefined, options: LoadOptions): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(obj: T): [Obj.Snapshot<T>, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(obj: T | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(objOrRef: T | Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown, K extends keyof T>(obj: T, property: K): [T[K], ObjectPropUpdateCallback<T[K]>];<T extends Obj.Unknown, K extends keyof T>(obj: T | undefined, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];<T, K extends keyof T>(ref: Ref<T>, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];<T, K extends keyof T>(ref: Ref<T> | undefined, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];}useQuery } from '@dxos/react-client/echo';const useQuery: UseQueryFnCreate subscription.
6 collapsed linesimport {ObjectForm } from '@dxos/react-ui-form';const ObjectForm: ({ object, type, schema, showTags }: ObjectFormProps) => React.JSX.ElementAn object's properties (and meta tags) as a next Form in its host's grid, writing each change back.
import * asButton from '@dxos/react-ui/Button';import Buttonimport * asDialog from '@dxos/react-ui/Dialog';import Dialogimport * asHooks from '@dxos/react-ui/Hooks';import Hooksimport * asIcon from '@dxos/react-ui/Icon';import Iconimport * asLayout from '@dxos/react-ui/Layout';import Layoutimport * asListbox from '@dxos/react-ui/Listbox';import Listbox7 collapsed linesimport * asPanel from '@dxos/react-ui/Panel';import Panelimport * asStatus from '@dxos/react-ui/Status';import Statusimport * asToolbar from '@dxos/react-ui/Toolbar';import Toolbarimport * asTypography from '@dxos/react-ui/Typography';import Typographyimport {ns } from '../icons/translations.ts';const ns: "com.example.contacts"import {DeletePopover } from '../overlays/ContactsScreen.tsx';const DeletePopover: ({ label, onDelete }: DeletePopoverProps) => React.JSX.Elementimport {Person } from './schema.ts';class Person3 collapsed linesconstpeople =const people: Query.Query<Person & OfKind<EntityKind.Object>>Query.import Queryselect(const select: <Filter.Filter<Person & OfKind<EntityKind.Object>>>(filter: Filter.Filter<Person & OfKind<EntityKind.Object>>) => Query.Query<Person & OfKind<EntityKind.Object>>Select objects based on a filter.
Filter.import Filtertype(const type: <typeof Person>(type: typeof Person, props?: Filter.Props<Person & OfKind<EntityKind.Object>> | undefined) => Filter.Filter<Person & OfKind<EntityKind.Object>> (+4 overloads)Person)).class PersonorderBy(Query<Person & OfKind<EntityKind.Object>>.orderBy(order_0: Order.Order<Person & OfKind<EntityKind.Object>>, ...order: Order.Order<Person & OfKind<EntityKind.Object>>[]): Query.Query<Person & OfKind<EntityKind.Object>>Order the query results. Orders are specified in priority order. The first order will be applied first, etc.
Order.propertyorders by the current result shape's fields, so it works both before and after anaggregate
: before, by member (row) properties; after, by the flat record's fields (any group or aggregate field — e.g.
Order.property('lastMessageAt')reorders the groups by that aggregate).Order.import Orderproperty<const property: <Person>(property: "~@dxos/echo/Kind" | "email" | "employer" | "name" | "id", direction: OrderDirection) => Order.Order<Person>Order by a property of the current result shape.
Person>('name', 'asc'));class Person/** A row that re-renders when its person is renamed. */constPersonRow = ({const PersonRow: ({ person }: {person: Person;}) => React.JSX.ElementA row that re-renders when its person is renamed.
person }: {person: Personperson:person: PersonPerson }) => {class Personconst [snapshot] =const snapshot: Obj.Snapshot<Person>useObject(useObject<Person>(obj: Person): [Obj.Snapshot<Person>, ObjectUpdateCallback<Person>] (+9 overloads)Hook to subscribe to an entire Echo object. Returns a snapshot of the current object value and automatically re-renders when the object changes.
person);person: Personreturn <Listbox.import ListboxItemconst 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 ItemA 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 Rootcolumns, 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={{item: Listbox.Optionvalue:value: stringperson.person: Personid,OfKind<K extends Kind>.id: stringlabel:label: stringsnapshot.const snapshot: Obj.Snapshot<Person>name,name: stringdescription:description?: string | undefinedSecond line of the default row.
snapshot.const snapshot: Obj.Snapshot<Person>email }} />;email?: string | undefined};typePeopleListProps = {type PeopleListProps = {people: Person[];selected?: string;onSelect: (id: string) => void;}people:people: Person[]Person[];class Personselected?: string;selected?: string | undefinedonSelect: (onSelect: (id: string) => voidid: string) => void;id: string};constPeopleList = ({const PeopleList: ({ people, selected, onSelect }: PeopleListProps) => React.JSX.Elementpeople,people: Person[]selected,selected: string | undefinedonSelect }:onSelect: (id: string) => voidPeopleListProps) => (type PeopleListProps = {people: Person[];selected?: string;onSelect: (id: string) => void;}<Listbox.import ListboxRootconst Root: React.ForwardRefExoticComponent<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "defaultValue" | "onSelect">, "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 RootArk listbox: single, multiple or no selection, with keyboard navigation, typeahead and
aria-selectedfrom zag. A flex column that caps itself at its parent's height, so a long list scrolls in its Content.items={items: readonly Listbox.Option[]people.people: Person[]map((Array<Person>.map<{value: string;label: string;}>(callbackfn: (value: Person, index: number, array: Person[]) => {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.
person) => ({person: Personvalue:value: stringperson.person: Personid,OfKind<K extends Kind>.id: stringlabel:label: stringperson.person: Personname }))}name: stringvalue={value?: string[] | undefinedselected ? [selected: string | undefinedselected] : []}selected: stringonValueChange={([onValueChange?: ((value: string[]) => void) | undefinedid]) =>id: stringid &&id: stringonSelect(onSelect: (id: string) => voidid)}id: string><Listbox.import ListboxViewport>const Viewport: React.ForwardRefExoticComponent<Omit<Pick<ScrollAreaRootProps, "mode" | "native" | "width">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {children: React.ReactNode;} & React.RefAttributes<HTMLDivElement>>export ViewportA 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
Contentis 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.<Listbox.import ListboxContentconst Content: React.ForwardRefExoticComponent<Omit<Layout.ContainerProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export ContentThe 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'svirtualwindowing over its direct children (the rows). Under aViewportit is the scrolling element (insetgutter 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 aViewport.aria-label='Contacts'>"aria-label"?: string | undefinedDefines a string value that labels the current element.
{people.people: Person[]map((Array<Person>.map<React.JSX.Element>(callbackfn: (value: Person, index: number, array: Person[]) => 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.
person) => (person: Person<PersonRowconst PersonRow: ({ person }: {person: Person;}) => React.JSX.ElementA row that re-renders when its person is renamed.
key={Attributes.key?: React.Key | null | undefinedperson.person: Personid}OfKind<K extends Kind>.id: stringperson={person: Personperson} />person: Person))}</Listbox.import ListboxContent>const Content: React.ForwardRefExoticComponent<Omit<Layout.ContainerProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export ContentThe 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'svirtualwindowing over its direct children (the rows). Under aViewportit is the scrolling element (insetgutter 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 aViewport.</Listbox.import ListboxViewport>const Viewport: React.ForwardRefExoticComponent<Omit<Pick<ScrollAreaRootProps, "mode" | "native" | "width">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {children: React.ReactNode;} & React.RefAttributes<HTMLDivElement>>export ViewportA 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
Contentis 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.</Listbox.import ListboxRoot>const Root: React.ForwardRefExoticComponent<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "defaultValue" | "onSelect">, "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 RootArk listbox: single, multiple or no selection, with keyboard navigation, typeahead and
aria-selectedfrom zag. A flex column that caps itself at its parent's height, so a long list scrolls in its Content.);useObjectreturns a pair.snapshotis the first of the two, a copy of the person’s fields as they are now. The second is a function that changes the person. -
Show the selected person. The detail reads the person the same way. It shows the name and the email, and no role, because
Personhas none:import {useObject,const useObject: {<T extends Obj.Unknown>(ref: Ref<T>): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(ref: Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(ref: Ref<T> | undefined, options: LoadOptions): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(obj: T): [Obj.Snapshot<T>, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(obj: T | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(objOrRef: T | Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown, K extends keyof T>(obj: T, property: K): [T[K], ObjectPropUpdateCallback<T[K]>];<T extends Obj.Unknown, K extends keyof T>(obj: T | undefined, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];<T, K extends keyof T>(ref: Ref<T>, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];<T, K extends keyof T>(ref: Ref<T> | undefined, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];}useQuery } from '@dxos/react-client/echo';const useQuery: UseQueryFnCreate subscription.
4 collapsed linesimport {ObjectForm } from '@dxos/react-ui-form';const ObjectForm: ({ object, type, schema, showTags }: ObjectFormProps) => React.JSX.ElementAn object's properties (and meta tags) as a next Form in its host's grid, writing each change back.
import * asButton from '@dxos/react-ui/Button';import Buttonimport * asDialog from '@dxos/react-ui/Dialog';import Dialogimport * asHooks from '@dxos/react-ui/Hooks';import Hooksimport * asIcon from '@dxos/react-ui/Icon';import Iconimport * asLayout from '@dxos/react-ui/Layout';import Layout4 collapsed linesimport * asListbox from '@dxos/react-ui/Listbox';import Listboximport * asPanel from '@dxos/react-ui/Panel';import Panelimport * asStatus from '@dxos/react-ui/Status';import Statusimport * asToolbar from '@dxos/react-ui/Toolbar';import Toolbarimport * asTypography from '@dxos/react-ui/Typography';import Typography3 collapsed linesimport {ns } from '../icons/translations.ts';const ns: "com.example.contacts"import {DeletePopover } from '../overlays/ContactsScreen.tsx';const DeletePopover: ({ label, onDelete }: DeletePopoverProps) => React.JSX.Elementimport {Person } from './schema.ts';class Person31 collapsed linesconstpeople =const people: Query.Query<Person & OfKind<EntityKind.Object>>Query.import Queryselect(const select: <Filter.Filter<Person & OfKind<EntityKind.Object>>>(filter: Filter.Filter<Person & OfKind<EntityKind.Object>>) => Query.Query<Person & OfKind<EntityKind.Object>>Select objects based on a filter.
Filter.import Filtertype(const type: <typeof Person>(type: typeof Person, props?: Filter.Props<Person & OfKind<EntityKind.Object>> | undefined) => Filter.Filter<Person & OfKind<EntityKind.Object>> (+4 overloads)Person)).class PersonorderBy(Query<Person & OfKind<EntityKind.Object>>.orderBy(order_0: Order.Order<Person & OfKind<EntityKind.Object>>, ...order: Order.Order<Person & OfKind<EntityKind.Object>>[]): Query.Query<Person & OfKind<EntityKind.Object>>Order the query results. Orders are specified in priority order. The first order will be applied first, etc.
Order.propertyorders by the current result shape's fields, so it works both before and after anaggregate
: before, by member (row) properties; after, by the flat record's fields (any group or aggregate field — e.g.
Order.property('lastMessageAt')reorders the groups by that aggregate).Order.import Orderproperty<const property: <Person>(property: "~@dxos/echo/Kind" | "email" | "employer" | "name" | "id", direction: OrderDirection) => Order.Order<Person>Order by a property of the current result shape.
Person>('name', 'asc'));class Person/** A row that re-renders when its person is renamed. */constPersonRow = ({const PersonRow: ({ person }: {person: Person;}) => React.JSX.ElementA row that re-renders when its person is renamed.
person }: {person: Personperson:person: PersonPerson }) => {class Personconst [snapshot] =const snapshot: Obj.Snapshot<Person>useObject(useObject<Person>(obj: Person): [Obj.Snapshot<Person>, ObjectUpdateCallback<Person>] (+9 overloads)Hook to subscribe to an entire Echo object. Returns a snapshot of the current object value and automatically re-renders when the object changes.
person);person: Personreturn <Listbox.import ListboxItemconst 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 ItemA 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 Rootcolumns, 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={{item: Listbox.Optionvalue:value: stringperson.person: Personid,OfKind<K extends Kind>.id: stringlabel:label: stringsnapshot.const snapshot: Obj.Snapshot<Person>name,name: stringdescription:description?: string | undefinedSecond line of the default row.
snapshot.const snapshot: Obj.Snapshot<Person>email }} />;email?: string | undefined};typePeopleListProps = {type PeopleListProps = {people: Person[];selected?: string;onSelect: (id: string) => void;}people:people: Person[]Person[];class Personselected?: string;selected?: string | undefinedonSelect: (onSelect: (id: string) => voidid: string) => void;id: string};constPeopleList = ({const PeopleList: ({ people, selected, onSelect }: PeopleListProps) => React.JSX.Elementpeople,people: Person[]selected,selected: string | undefinedonSelect }:onSelect: (id: string) => voidPeopleListProps) => (type PeopleListProps = {people: Person[];selected?: string;onSelect: (id: string) => void;}<Listbox.import ListboxRootconst Root: React.ForwardRefExoticComponent<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "defaultValue" | "onSelect">, "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 RootArk listbox: single, multiple or no selection, with keyboard navigation, typeahead and
aria-selectedfrom zag. A flex column that caps itself at its parent's height, so a long list scrolls in its Content.items={items: readonly Listbox.Option[]people.people: Person[]map((Array<Person>.map<{value: string;label: string;}>(callbackfn: (value: Person, index: number, array: Person[]) => {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.
person) => ({person: Personvalue:value: stringperson.person: Personid,OfKind<K extends Kind>.id: stringlabel:label: stringperson.person: Personname }))}name: stringvalue={value?: string[] | undefinedselected ? [selected: string | undefinedselected] : []}selected: stringonValueChange={([onValueChange?: ((value: string[]) => void) | undefinedid]) =>id: stringid &&id: stringonSelect(onSelect: (id: string) => voidid)}id: string><Listbox.import ListboxViewport>const Viewport: React.ForwardRefExoticComponent<Omit<Pick<ScrollAreaRootProps, "mode" | "native" | "width">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {children: React.ReactNode;} & React.RefAttributes<HTMLDivElement>>export ViewportA 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
Contentis 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.<Listbox.import ListboxContentconst Content: React.ForwardRefExoticComponent<Omit<Layout.ContainerProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export ContentThe 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'svirtualwindowing over its direct children (the rows). Under aViewportit is the scrolling element (insetgutter 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 aViewport.aria-label='Contacts'>"aria-label"?: string | undefinedDefines a string value that labels the current element.
{people.people: Person[]map((Array<Person>.map<React.JSX.Element>(callbackfn: (value: Person, index: number, array: Person[]) => 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.
person) => (person: Person<PersonRowconst PersonRow: ({ person }: {person: Person;}) => React.JSX.ElementA row that re-renders when its person is renamed.
key={Attributes.key?: React.Key | null | undefinedperson.person: Personid}OfKind<K extends Kind>.id: stringperson={person: Personperson} />person: Person))}</Listbox.import ListboxContent>const Content: React.ForwardRefExoticComponent<Omit<Layout.ContainerProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export ContentThe 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'svirtualwindowing over its direct children (the rows). Under aViewportit is the scrolling element (insetgutter 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 aViewport.</Listbox.import ListboxViewport>const Viewport: React.ForwardRefExoticComponent<Omit<Pick<ScrollAreaRootProps, "mode" | "native" | "width">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {children: React.ReactNode;} & React.RefAttributes<HTMLDivElement>>export ViewportA 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
Contentis 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.</Listbox.import ListboxRoot>const Root: React.ForwardRefExoticComponent<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "defaultValue" | "onSelect">, "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 RootArk listbox: single, multiple or no selection, with keyboard navigation, typeahead and
aria-selectedfrom zag. A flex column that caps itself at its parent's height, so a long list scrolls in its Content.);/** Re-renders when this person changes, here or on another peer. */constPersonDetail = ({const PersonDetail: ({ person }: {person: Person;}) => React.JSX.ElementRe-renders when this person changes, here or on another peer.
person }: {person: Personperson:person: PersonPerson }) => {class Personconst [snapshot] =const snapshot: Obj.Snapshot<Person>useObject(useObject<Person>(obj: Person): [Obj.Snapshot<Person>, ObjectUpdateCallback<Person>] (+9 overloads)Hook to subscribe to an entire Echo object. Returns a snapshot of the current object value and automatically re-renders when the object changes.
person);person: Personreturn (<Layout.import LayoutFlexconst Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>One-axis layout box: the primitive that replaces hand-written
flex …wrapper divs.gapis restricted to the named steps of the theme spacing ramp (seeGap
), which is the point of the prop — an off-ramp
gap-2/gap-3literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes throughclassNames; 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 CSSstretchinitial value.Use
asChildto project the layout onto a semantic element (<header>,<ul>,<a>).columncolumn?: boolean | undefinedStack on the block axis instead of the inline axis.
gap='sm'gap?: Layout.Gap | undefinedclassNames='p-4'>classNames?: ClassNameValue<Typography.import TypographyTextconst Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLParagraphElement>>export TextText whose first line is centred in a block, so it lines up with a Block or control beside it however many lines it wraps to. Renders a
<p>;asChildputs the metrics on a heading or other text element instead.asChild>asChild?: boolean | undefined<h2>{JSX.IntrinsicElements.h2: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>snapshot.const snapshot: Obj.Snapshot<Person>name}</name: stringh2>JSX.IntrinsicElements.h2: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement></Typography.import TypographyText>const Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLParagraphElement>>export TextText whose first line is centred in a block, so it lines up with a Block or control beside it however many lines it wraps to. Renders a
<p>;asChildputs the metrics on a heading or other text element instead.{snapshot.const snapshot: Obj.Snapshot<Person>email && (email?: string | undefined<Layout.import LayoutFlexconst Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>One-axis layout box: the primitive that replaces hand-written
flex …wrapper divs.gapis restricted to the named steps of the theme spacing ramp (seeGap
), which is the point of the prop — an off-ramp
gap-2/gap-3literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes throughclassNames; 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 CSSstretchinitial value.Use
asChildto project the layout onto a semantic element (<header>,<ul>,<a>).gap='sm'gap?: Layout.Gap | undefinedalign='center'>align?: Layout.Align | undefined<Icon.import IconIconconst Icon: React.ForwardRefExoticComponent<Omit<Omit<React.SVGProps<SVGSVGElement>, "ref">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {icon: string;label?: string;hue?: Icon.IconHue;valence?: Icon.IconValence;tone?: Icon.IconTone;spin?: boolean;size?: Size;} & React.RefAttributes<SVGSVGElement>>icon='ph--envelope--regular' />icon: string<Typography.import TypographyTextconst Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLParagraphElement>>export TextText whose first line is centred in a block, so it lines up with a Block or control beside it however many lines it wraps to. Renders a
<p>;asChildputs the metrics on a heading or other text element instead.tone='muted'>{tone?: Typography.TextTone | undefinedEmphasis below the default (DESIGN.md "Text emphasis"):
descriptionfor secondary content,subduedfor interface text.snapshot.const snapshot: Obj.Snapshot<Person>email}</email?: stringTypography.import TypographyText>const Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLParagraphElement>>export TextText whose first line is centred in a block, so it lines up with a Block or control beside it however many lines it wraps to. Renders a
<p>;asChildputs the metrics on a heading or other text element instead.</Layout.import LayoutFlex>const Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>One-axis layout box: the primitive that replaces hand-written
flex …wrapper divs.gapis restricted to the named steps of the theme spacing ramp (seeGap
), which is the point of the prop — an off-ramp
gap-2/gap-3literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes throughclassNames; 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 CSSstretchinitial value.Use
asChildto project the layout onto a semantic element (<header>,<ul>,<a>).)}</Layout.import LayoutFlex>const Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>One-axis layout box: the primitive that replaces hand-written
flex …wrapper divs.gapis restricted to the named steps of the theme spacing ramp (seeGap
), which is the point of the prop — an off-ramp
gap-2/gap-3literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes throughclassNames; 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 CSSstretchinitial value.Use
asChildto project the layout onto a semantic element (<header>,<ul>,<a>).);}; -
Edit with a schema form.
ObjectFormbuilds its fields fromPerson’s schema: a text field for the name, an email field, and a picker of organizations for the employer. It writes each change to the object as it is made, so the dialog needs no Save button. We no longer need the editor from Inputs and actions.import {useObject,const useObject: {<T extends Obj.Unknown>(ref: Ref<T>): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(ref: Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(ref: Ref<T> | undefined, options: LoadOptions): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(obj: T): [Obj.Snapshot<T>, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(obj: T | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(objOrRef: T | Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown, K extends keyof T>(obj: T, property: K): [T[K], ObjectPropUpdateCallback<T[K]>];<T extends Obj.Unknown, K extends keyof T>(obj: T | undefined, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];<T, K extends keyof T>(ref: Ref<T>, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];<T, K extends keyof T>(ref: Ref<T> | undefined, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];}useQuery } from '@dxos/react-client/echo';const useQuery: UseQueryFnCreate subscription.
import {ObjectForm } from '@dxos/react-ui-form';const ObjectForm: ({ object, type, schema, showTags }: ObjectFormProps) => React.JSX.ElementAn object's properties (and meta tags) as a next Form in its host's grid, writing each change back.
import * asButton from '@dxos/react-ui/Button';import Buttonimport * asDialog from '@dxos/react-ui/Dialog';import Dialog11 collapsed linesimport * asHooks from '@dxos/react-ui/Hooks';import Hooksimport * asIcon from '@dxos/react-ui/Icon';import Iconimport * asLayout from '@dxos/react-ui/Layout';import Layoutimport * asListbox from '@dxos/react-ui/Listbox';import Listboximport * asPanel from '@dxos/react-ui/Panel';import Panelimport * asStatus from '@dxos/react-ui/Status';import Statusimport * asToolbar from '@dxos/react-ui/Toolbar';import Toolbarimport * asTypography from '@dxos/react-ui/Typography';import Typographyimport {ns } from '../icons/translations.ts';const ns: "com.example.contacts"import {DeletePopover } from '../overlays/ContactsScreen.tsx';const DeletePopover: ({ label, onDelete }: DeletePopoverProps) => React.JSX.Elementimport {Person } from './schema.ts';class Person49 collapsed linesconstpeople =const people: Query.Query<Person & OfKind<EntityKind.Object>>Query.import Queryselect(const select: <Filter.Filter<Person & OfKind<EntityKind.Object>>>(filter: Filter.Filter<Person & OfKind<EntityKind.Object>>) => Query.Query<Person & OfKind<EntityKind.Object>>Select objects based on a filter.
Filter.import Filtertype(const type: <typeof Person>(type: typeof Person, props?: Filter.Props<Person & OfKind<EntityKind.Object>> | undefined) => Filter.Filter<Person & OfKind<EntityKind.Object>> (+4 overloads)Person)).class PersonorderBy(Query<Person & OfKind<EntityKind.Object>>.orderBy(order_0: Order.Order<Person & OfKind<EntityKind.Object>>, ...order: Order.Order<Person & OfKind<EntityKind.Object>>[]): Query.Query<Person & OfKind<EntityKind.Object>>Order the query results. Orders are specified in priority order. The first order will be applied first, etc.
Order.propertyorders by the current result shape's fields, so it works both before and after anaggregate
: before, by member (row) properties; after, by the flat record's fields (any group or aggregate field — e.g.
Order.property('lastMessageAt')reorders the groups by that aggregate).Order.import Orderproperty<const property: <Person>(property: "~@dxos/echo/Kind" | "email" | "employer" | "name" | "id", direction: OrderDirection) => Order.Order<Person>Order by a property of the current result shape.
Person>('name', 'asc'));class Person/** A row that re-renders when its person is renamed. */constPersonRow = ({const PersonRow: ({ person }: {person: Person;}) => React.JSX.ElementA row that re-renders when its person is renamed.
person }: {person: Personperson:person: PersonPerson }) => {class Personconst [snapshot] =const snapshot: Obj.Snapshot<Person>useObject(useObject<Person>(obj: Person): [Obj.Snapshot<Person>, ObjectUpdateCallback<Person>] (+9 overloads)Hook to subscribe to an entire Echo object. Returns a snapshot of the current object value and automatically re-renders when the object changes.
person);person: Personreturn <Listbox.import ListboxItemconst 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 ItemA 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 Rootcolumns, 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={{item: Listbox.Optionvalue:value: stringperson.person: Personid,OfKind<K extends Kind>.id: stringlabel:label: stringsnapshot.const snapshot: Obj.Snapshot<Person>name,name: stringdescription:description?: string | undefinedSecond line of the default row.
snapshot.const snapshot: Obj.Snapshot<Person>email }} />;email?: string | undefined};typePeopleListProps = {type PeopleListProps = {people: Person[];selected?: string;onSelect: (id: string) => void;}people:people: Person[]Person[];class Personselected?: string;selected?: string | undefinedonSelect: (onSelect: (id: string) => voidid: string) => void;id: string};constPeopleList = ({const PeopleList: ({ people, selected, onSelect }: PeopleListProps) => React.JSX.Elementpeople,people: Person[]selected,selected: string | undefinedonSelect }:onSelect: (id: string) => voidPeopleListProps) => (type PeopleListProps = {people: Person[];selected?: string;onSelect: (id: string) => void;}<Listbox.import ListboxRootconst Root: React.ForwardRefExoticComponent<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "defaultValue" | "onSelect">, "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 RootArk listbox: single, multiple or no selection, with keyboard navigation, typeahead and
aria-selectedfrom zag. A flex column that caps itself at its parent's height, so a long list scrolls in its Content.items={items: readonly Listbox.Option[]people.people: Person[]map((Array<Person>.map<{value: string;label: string;}>(callbackfn: (value: Person, index: number, array: Person[]) => {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.
person) => ({person: Personvalue:value: stringperson.person: Personid,OfKind<K extends Kind>.id: stringlabel:label: stringperson.person: Personname }))}name: stringvalue={value?: string[] | undefinedselected ? [selected: string | undefinedselected] : []}selected: stringonValueChange={([onValueChange?: ((value: string[]) => void) | undefinedid]) =>id: stringid &&id: stringonSelect(onSelect: (id: string) => voidid)}id: string><Listbox.import ListboxViewport>const Viewport: React.ForwardRefExoticComponent<Omit<Pick<ScrollAreaRootProps, "mode" | "native" | "width">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {children: React.ReactNode;} & React.RefAttributes<HTMLDivElement>>export ViewportA 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
Contentis 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.<Listbox.import ListboxContentconst Content: React.ForwardRefExoticComponent<Omit<Layout.ContainerProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export ContentThe 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'svirtualwindowing over its direct children (the rows). Under aViewportit is the scrolling element (insetgutter 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 aViewport.aria-label='Contacts'>"aria-label"?: string | undefinedDefines a string value that labels the current element.
{people.people: Person[]map((Array<Person>.map<React.JSX.Element>(callbackfn: (value: Person, index: number, array: Person[]) => 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.
person) => (person: Person<PersonRowconst PersonRow: ({ person }: {person: Person;}) => React.JSX.ElementA row that re-renders when its person is renamed.
key={Attributes.key?: React.Key | null | undefinedperson.person: Personid}OfKind<K extends Kind>.id: stringperson={person: Personperson} />person: Person))}</Listbox.import ListboxContent>const Content: React.ForwardRefExoticComponent<Omit<Layout.ContainerProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export ContentThe 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'svirtualwindowing over its direct children (the rows). Under aViewportit is the scrolling element (insetgutter 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 aViewport.</Listbox.import ListboxViewport>const Viewport: React.ForwardRefExoticComponent<Omit<Pick<ScrollAreaRootProps, "mode" | "native" | "width">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {children: React.ReactNode;} & React.RefAttributes<HTMLDivElement>>export ViewportA 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
Contentis 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.</Listbox.import ListboxRoot>const Root: React.ForwardRefExoticComponent<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "defaultValue" | "onSelect">, "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 RootArk listbox: single, multiple or no selection, with keyboard navigation, typeahead and
aria-selectedfrom zag. A flex column that caps itself at its parent's height, so a long list scrolls in its Content.);/** Re-renders when this person changes, here or on another peer. */constPersonDetail = ({const PersonDetail: ({ person }: {person: Person;}) => React.JSX.ElementRe-renders when this person changes, here or on another peer.
person }: {person: Personperson:person: PersonPerson }) => {class Personconst [snapshot] =const snapshot: Obj.Snapshot<Person>useObject(useObject<Person>(obj: Person): [Obj.Snapshot<Person>, ObjectUpdateCallback<Person>] (+9 overloads)Hook to subscribe to an entire Echo object. Returns a snapshot of the current object value and automatically re-renders when the object changes.
person);person: Personreturn (<Layout.import LayoutFlexconst Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>One-axis layout box: the primitive that replaces hand-written
flex …wrapper divs.gapis restricted to the named steps of the theme spacing ramp (seeGap
), which is the point of the prop — an off-ramp
gap-2/gap-3literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes throughclassNames; 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 CSSstretchinitial value.Use
asChildto project the layout onto a semantic element (<header>,<ul>,<a>).columncolumn?: boolean | undefinedStack on the block axis instead of the inline axis.
gap='sm'gap?: Layout.Gap | undefinedclassNames='p-4'>classNames?: ClassNameValue<Typography.import TypographyTextconst Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLParagraphElement>>export TextText whose first line is centred in a block, so it lines up with a Block or control beside it however many lines it wraps to. Renders a
<p>;asChildputs the metrics on a heading or other text element instead.asChild>asChild?: boolean | undefined<h2>{JSX.IntrinsicElements.h2: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>snapshot.const snapshot: Obj.Snapshot<Person>name}</name: stringh2>JSX.IntrinsicElements.h2: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement></Typography.import TypographyText>const Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLParagraphElement>>export TextText whose first line is centred in a block, so it lines up with a Block or control beside it however many lines it wraps to. Renders a
<p>;asChildputs the metrics on a heading or other text element instead.{snapshot.const snapshot: Obj.Snapshot<Person>email && (email?: string | undefined<Layout.import LayoutFlexconst Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>One-axis layout box: the primitive that replaces hand-written
flex …wrapper divs.gapis restricted to the named steps of the theme spacing ramp (seeGap
), which is the point of the prop — an off-ramp
gap-2/gap-3literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes throughclassNames; 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 CSSstretchinitial value.Use
asChildto project the layout onto a semantic element (<header>,<ul>,<a>).gap='sm'gap?: Layout.Gap | undefinedalign='center'>align?: Layout.Align | undefined<Icon.import IconIconconst Icon: React.ForwardRefExoticComponent<Omit<Omit<React.SVGProps<SVGSVGElement>, "ref">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {icon: string;label?: string;hue?: Icon.IconHue;valence?: Icon.IconValence;tone?: Icon.IconTone;spin?: boolean;size?: Size;} & React.RefAttributes<SVGSVGElement>>icon='ph--envelope--regular' />icon: string<Typography.import TypographyTextconst Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLParagraphElement>>export TextText whose first line is centred in a block, so it lines up with a Block or control beside it however many lines it wraps to. Renders a
<p>;asChildputs the metrics on a heading or other text element instead.tone='muted'>{tone?: Typography.TextTone | undefinedEmphasis below the default (DESIGN.md "Text emphasis"):
descriptionfor secondary content,subduedfor interface text.snapshot.const snapshot: Obj.Snapshot<Person>email}</email?: stringTypography.import TypographyText>const Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLParagraphElement>>export TextText whose first line is centred in a block, so it lines up with a Block or control beside it however many lines it wraps to. Renders a
<p>;asChildputs the metrics on a heading or other text element instead.</Layout.import LayoutFlex>const Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>One-axis layout box: the primitive that replaces hand-written
flex …wrapper divs.gapis restricted to the named steps of the theme spacing ramp (seeGap
), which is the point of the prop — an off-ramp
gap-2/gap-3literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes throughclassNames; 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 CSSstretchinitial value.Use
asChildto project the layout onto a semantic element (<header>,<ul>,<a>).)}</Layout.import LayoutFlex>const Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>One-axis layout box: the primitive that replaces hand-written
flex …wrapper divs.gapis restricted to the named steps of the theme spacing ramp (seeGap
), which is the point of the prop — an off-ramp
gap-2/gap-3literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes throughclassNames; 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 CSSstretchinitial value.Use
asChildto project the layout onto a semantic element (<header>,<ul>,<a>).);};/** A form built from `Person`'s schema; each change is written to the object as it is made. */constEditDialog = ({const EditDialog: ({ label, person }: {label: string;person: Person;}) => React.JSX.ElementA form built from
Person's schema; each change is written to the object as it is made.label,label: stringperson }: {person: Personlabel: string;label: stringperson:person: PersonPerson }) => {class Personconst [snapshot] =const snapshot: Obj.Snapshot<Person>useObject(useObject<Person>(obj: Person): [Obj.Snapshot<Person>, ObjectUpdateCallback<Person>] (+9 overloads)Hook to subscribe to an entire Echo object. Returns a snapshot of the current object value and automatically re-renders when the object changes.
person);person: Personreturn (<Dialog.import DialogRoot>function Root({ lazyMount, unmountOnExit, closeOnInteractOutside, placement, ...props }: Dialog.RootProps): React.JSX.Elementexport Root<Dialog.import DialogTriggerconst Trigger: React.ForwardRefExoticComponent<DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>export TriggerUse
asChildto open the dialog from aButton.asChild>PolymorphicProps.asChild?: boolean | undefinedUse the provided child element as the default rendered element, combining their props and behavior.
<Button.import ButtonRootconst Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & {classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLButtonElement>>export Rooticon='ph--pencil-simple--regular'icon?: string | undefinedLeading icon.
label={label?: string | undefinedVisible text;
childrentake precedence.Required: names the button (
aria-label) and shows in a Tooltip.label}label: stringiconOnly />iconOnly?: boolean | undefinedA control-sized square inset in a block-sized cell (follow-up 19), showing only the icon.
</Dialog.import DialogTrigger>const Trigger: React.ForwardRefExoticComponent<DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>export TriggerUse
asChildto open the dialog from aButton.<Dialog.import DialogContent>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 ContentPortalled surface at
level='raised'over a scrim, centred in the viewport: a column of Header, Body and Footer.<Dialog.import DialogHeader>const Header: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & React.RefAttributes<HTMLDivElement>>export HeaderA block row holding the Title and an optional trailing CloseTrigger.
<Dialog.import DialogTitle>{const Title: React.ForwardRefExoticComponent<Omit<DialogTitleProps, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {srOnly?: boolean;} & React.RefAttributes<HTMLHeadingElement>>export Titlesnapshot.const snapshot: Obj.Snapshot<Person>name}</name: stringDialog.import DialogTitle>const Title: React.ForwardRefExoticComponent<Omit<DialogTitleProps, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {srOnly?: boolean;} & React.RefAttributes<HTMLHeadingElement>>export Title<Dialog.import DialogCloseTrigger />const CloseTrigger: React.ForwardRefExoticComponent<Omit<DialogCloseTriggerProps, "children"> & {children?: React.ReactNode;icon?: string;label?: string;} & React.RefAttributes<HTMLButtonElement>>export CloseTrigger</Dialog.import DialogHeader>const Header: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & React.RefAttributes<HTMLDivElement>>export HeaderA block row holding the Title and an optional trailing CloseTrigger.
<Dialog.import DialogBody>const Body: React.ForwardRefExoticComponent<Omit<Pick<ScrollAreaRootProps, "mode" | "native" | "width">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<Layout.ContainerProps, "gap"> & {align?: "start" | "center";children?: React.ReactNode;} & React.RefAttributes<HTMLDivElement>>export BodyComposed scroll (decision 5): a
gutter='md'Container as the viewport, so the thumb sits in the end gutter;gapspaces its rows, since they are the Container's own items. The element carries ScrollArea'sdata-scope, since parts cannot rescope a composed child (finding 10).<ObjectFormconst ObjectForm: ({ object, type, schema, showTags }: ObjectFormProps) => React.JSX.ElementAn object's properties (and meta tags) as a next Form in its host's grid, writing each change back.
type={type: AnyEntityPerson}class Personobject={object: Obj.Unknownperson}person: PersonshowTags={false} />showTags?: boolean | undefinedRender the meta-tags field. Defaults to
true.</Dialog.import DialogBody>const Body: React.ForwardRefExoticComponent<Omit<Pick<ScrollAreaRootProps, "mode" | "native" | "width">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<Layout.ContainerProps, "gap"> & {align?: "start" | "center";children?: React.ReactNode;} & React.RefAttributes<HTMLDivElement>>export BodyComposed scroll (decision 5): a
gutter='md'Container as the viewport, so the thumb sits in the end gutter;gapspaces its rows, since they are the Container's own items. The element carries ScrollArea'sdata-scope, since parts cannot rescope a composed child (finding 10).</Dialog.import DialogContent>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 ContentPortalled surface at
level='raised'over a scrim, centred in the viewport: a column of Header, Body and Footer.</Dialog.import DialogRoot>function Root({ lazyMount, unmountOnExit, closeOnInteractOutside, placement, ...props }: Dialog.RootProps): React.JSX.Elementexport Root);};Dialog.Roottakes noopennow. With no Save to close the dialog, it can hold its own state. Form shows how to describe a form’s fields and how to edit an ECHO object with one. -
Write the screen. Add puts a new object in the database with
db.add, and Delete takes it out withdb.remove. Neither changes a list of our own. The query sees the change, and the list renders again.importReact, {(alias) namespace Reactimport ReactuseState } from '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.
import { typeDatabase,import DatabaseFilter,import FilterObj,import ObjOrder,import OrderQuery } from '@dxos/echo';import Queryimport {useObject,const useObject: {<T extends Obj.Unknown>(ref: Ref<T>): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(ref: Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(ref: Ref<T> | undefined, options: LoadOptions): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(obj: T): [Obj.Snapshot<T>, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(obj: T | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown>(objOrRef: T | Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];<T extends Obj.Unknown, K extends keyof T>(obj: T, property: K): [T[K], ObjectPropUpdateCallback<T[K]>];<T extends Obj.Unknown, K extends keyof T>(obj: T | undefined, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];<T, K extends keyof T>(ref: Ref<T>, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];<T, K extends keyof T>(ref: Ref<T> | undefined, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];}useQuery } from '@dxos/react-client/echo';const useQuery: UseQueryFnCreate subscription.
1 collapsed lineimport {ObjectForm } from '@dxos/react-ui-form';const ObjectForm: ({ object, type, schema, showTags }: ObjectFormProps) => React.JSX.ElementAn object's properties (and meta tags) as a next Form in its host's grid, writing each change back.
import * asButton from '@dxos/react-ui/Button';import Button1 collapsed lineimport * asDialog from '@dxos/react-ui/Dialog';import Dialogimport * asHooks from '@dxos/react-ui/Hooks';import Hooks1 collapsed lineimport * asIcon from '@dxos/react-ui/Icon';import Iconimport * asLayout from '@dxos/react-ui/Layout';import Layout1 collapsed lineimport * asListbox from '@dxos/react-ui/Listbox';import Listboximport * asPanel from '@dxos/react-ui/Panel';import Panelimport * asStatus from '@dxos/react-ui/Status';import Statusimport * asToolbar from '@dxos/react-ui/Toolbar';import Toolbar2 collapsed linesimport * asTypography from '@dxos/react-ui/Typography';import Typographyimport {ns } from '../icons/translations.ts';const ns: "com.example.contacts"import {DeletePopover } from '../overlays/ContactsScreen.tsx';const DeletePopover: ({ label, onDelete }: DeletePopoverProps) => React.JSX.Elementimport {Person } from './schema.ts';class Person70 collapsed linesconstpeople =const people: Query.Query<Person & OfKind<EntityKind.Object>>Query.import Queryselect(const select: <Filter.Filter<Person & OfKind<EntityKind.Object>>>(filter: Filter.Filter<Person & OfKind<EntityKind.Object>>) => Query.Query<Person & OfKind<EntityKind.Object>>Select objects based on a filter.
Filter.import Filtertype(const type: <typeof Person>(type: typeof Person, props?: Filter.Props<Person & OfKind<EntityKind.Object>> | undefined) => Filter.Filter<Person & OfKind<EntityKind.Object>> (+4 overloads)Person)).class PersonorderBy(Query<Person & OfKind<EntityKind.Object>>.orderBy(order_0: Order.Order<Person & OfKind<EntityKind.Object>>, ...order: Order.Order<Person & OfKind<EntityKind.Object>>[]): Query.Query<Person & OfKind<EntityKind.Object>>Order the query results. Orders are specified in priority order. The first order will be applied first, etc.
Order.propertyorders by the current result shape's fields, so it works both before and after anaggregate
: before, by member (row) properties; after, by the flat record's fields (any group or aggregate field — e.g.
Order.property('lastMessageAt')reorders the groups by that aggregate).Order.import Orderproperty<const property: <Person>(property: "~@dxos/echo/Kind" | "email" | "employer" | "name" | "id", direction: OrderDirection) => Order.Order<Person>Order by a property of the current result shape.
Person>('name', 'asc'));class Person/** A row that re-renders when its person is renamed. */constPersonRow = ({const PersonRow: ({ person }: {person: Person;}) => React.JSX.ElementA row that re-renders when its person is renamed.
person }: {person: Personperson:person: PersonPerson }) => {class Personconst [snapshot] =const snapshot: Obj.Snapshot<Person>useObject(useObject<Person>(obj: Person): [Obj.Snapshot<Person>, ObjectUpdateCallback<Person>] (+9 overloads)Hook to subscribe to an entire Echo object. Returns a snapshot of the current object value and automatically re-renders when the object changes.
person);person: Personreturn <Listbox.import ListboxItemconst 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 ItemA 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 Rootcolumns, 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={{item: Listbox.Optionvalue:value: stringperson.person: Personid,OfKind<K extends Kind>.id: stringlabel:label: stringsnapshot.const snapshot: Obj.Snapshot<Person>name,name: stringdescription:description?: string | undefinedSecond line of the default row.
snapshot.const snapshot: Obj.Snapshot<Person>email }} />;email?: string | undefined};typePeopleListProps = {type PeopleListProps = {people: Person[];selected?: string;onSelect: (id: string) => void;}people:people: Person[]Person[];class Personselected?: string;selected?: string | undefinedonSelect: (onSelect: (id: string) => voidid: string) => void;id: string};constPeopleList = ({const PeopleList: ({ people, selected, onSelect }: PeopleListProps) => React.JSX.Elementpeople,people: Person[]selected,selected: string | undefinedonSelect }:onSelect: (id: string) => voidPeopleListProps) => (type PeopleListProps = {people: Person[];selected?: string;onSelect: (id: string) => void;}<Listbox.import ListboxRootconst Root: React.ForwardRefExoticComponent<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "defaultValue" | "onSelect">, "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 RootArk listbox: single, multiple or no selection, with keyboard navigation, typeahead and
aria-selectedfrom zag. A flex column that caps itself at its parent's height, so a long list scrolls in its Content.items={items: readonly Listbox.Option[]people.people: Person[]map((Array<Person>.map<{value: string;label: string;}>(callbackfn: (value: Person, index: number, array: Person[]) => {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.
person) => ({person: Personvalue:value: stringperson.person: Personid,OfKind<K extends Kind>.id: stringlabel:label: stringperson.person: Personname }))}name: stringvalue={value?: string[] | undefinedselected ? [selected: string | undefinedselected] : []}selected: stringonValueChange={([onValueChange?: ((value: string[]) => void) | undefinedid]) =>id: stringid &&id: stringonSelect(onSelect: (id: string) => voidid)}id: string><Listbox.import ListboxViewport>const Viewport: React.ForwardRefExoticComponent<Omit<Pick<ScrollAreaRootProps, "mode" | "native" | "width">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {children: React.ReactNode;} & React.RefAttributes<HTMLDivElement>>export ViewportA 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
Contentis 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.<Listbox.import ListboxContentconst Content: React.ForwardRefExoticComponent<Omit<Layout.ContainerProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export ContentThe 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'svirtualwindowing over its direct children (the rows). Under aViewportit is the scrolling element (insetgutter 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 aViewport.aria-label='Contacts'>"aria-label"?: string | undefinedDefines a string value that labels the current element.
{people.people: Person[]map((Array<Person>.map<React.JSX.Element>(callbackfn: (value: Person, index: number, array: Person[]) => 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.
person) => (person: Person<PersonRowconst PersonRow: ({ person }: {person: Person;}) => React.JSX.ElementA row that re-renders when its person is renamed.
key={Attributes.key?: React.Key | null | undefinedperson.person: Personid}OfKind<K extends Kind>.id: stringperson={person: Personperson} />person: Person))}</Listbox.import ListboxContent>const Content: React.ForwardRefExoticComponent<Omit<Layout.ContainerProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export ContentThe 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'svirtualwindowing over its direct children (the rows). Under aViewportit is the scrolling element (insetgutter 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 aViewport.</Listbox.import ListboxViewport>const Viewport: React.ForwardRefExoticComponent<Omit<Pick<ScrollAreaRootProps, "mode" | "native" | "width">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {children: React.ReactNode;} & React.RefAttributes<HTMLDivElement>>export ViewportA 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
Contentis 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.</Listbox.import ListboxRoot>const Root: React.ForwardRefExoticComponent<Omit<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "defaultValue" | "onSelect">, "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 RootArk listbox: single, multiple or no selection, with keyboard navigation, typeahead and
aria-selectedfrom zag. A flex column that caps itself at its parent's height, so a long list scrolls in its Content.);/** Re-renders when this person changes, here or on another peer. */constPersonDetail = ({const PersonDetail: ({ person }: {person: Person;}) => React.JSX.ElementRe-renders when this person changes, here or on another peer.
person }: {person: Personperson:person: PersonPerson }) => {class Personconst [snapshot] =const snapshot: Obj.Snapshot<Person>useObject(useObject<Person>(obj: Person): [Obj.Snapshot<Person>, ObjectUpdateCallback<Person>] (+9 overloads)Hook to subscribe to an entire Echo object. Returns a snapshot of the current object value and automatically re-renders when the object changes.
person);person: Personreturn (<Layout.import LayoutFlexconst Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>One-axis layout box: the primitive that replaces hand-written
flex …wrapper divs.gapis restricted to the named steps of the theme spacing ramp (seeGap
), which is the point of the prop — an off-ramp
gap-2/gap-3literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes throughclassNames; 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 CSSstretchinitial value.Use
asChildto project the layout onto a semantic element (<header>,<ul>,<a>).columncolumn?: boolean | undefinedStack on the block axis instead of the inline axis.
gap='sm'gap?: Layout.Gap | undefinedclassNames='p-4'>classNames?: ClassNameValue<Typography.import TypographyTextconst Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLParagraphElement>>export TextText whose first line is centred in a block, so it lines up with a Block or control beside it however many lines it wraps to. Renders a
<p>;asChildputs the metrics on a heading or other text element instead.asChild>asChild?: boolean | undefined<h2>{JSX.IntrinsicElements.h2: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>snapshot.const snapshot: Obj.Snapshot<Person>name}</name: stringh2>JSX.IntrinsicElements.h2: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement></Typography.import TypographyText>const Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLParagraphElement>>export TextText whose first line is centred in a block, so it lines up with a Block or control beside it however many lines it wraps to. Renders a
<p>;asChildputs the metrics on a heading or other text element instead.{snapshot.const snapshot: Obj.Snapshot<Person>email && (email?: string | undefined<Layout.import LayoutFlexconst Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>One-axis layout box: the primitive that replaces hand-written
flex …wrapper divs.gapis restricted to the named steps of the theme spacing ramp (seeGap
), which is the point of the prop — an off-ramp
gap-2/gap-3literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes throughclassNames; 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 CSSstretchinitial value.Use
asChildto project the layout onto a semantic element (<header>,<ul>,<a>).gap='sm'gap?: Layout.Gap | undefinedalign='center'>align?: Layout.Align | undefined<Icon.import IconIconconst Icon: React.ForwardRefExoticComponent<Omit<Omit<React.SVGProps<SVGSVGElement>, "ref">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {icon: string;label?: string;hue?: Icon.IconHue;valence?: Icon.IconValence;tone?: Icon.IconTone;spin?: boolean;size?: Size;} & React.RefAttributes<SVGSVGElement>>icon='ph--envelope--regular' />icon: string<Typography.import TypographyTextconst Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLParagraphElement>>export TextText whose first line is centred in a block, so it lines up with a Block or control beside it however many lines it wraps to. Renders a
<p>;asChildputs the metrics on a heading or other text element instead.tone='muted'>{tone?: Typography.TextTone | undefinedEmphasis below the default (DESIGN.md "Text emphasis"):
descriptionfor secondary content,subduedfor interface text.snapshot.const snapshot: Obj.Snapshot<Person>email}</email?: stringTypography.import TypographyText>const Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLParagraphElement>>export TextText whose first line is centred in a block, so it lines up with a Block or control beside it however many lines it wraps to. Renders a
<p>;asChildputs the metrics on a heading or other text element instead.</Layout.import LayoutFlex>const Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>One-axis layout box: the primitive that replaces hand-written
flex …wrapper divs.gapis restricted to the named steps of the theme spacing ramp (seeGap
), which is the point of the prop — an off-ramp
gap-2/gap-3literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes throughclassNames; 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 CSSstretchinitial value.Use
asChildto project the layout onto a semantic element (<header>,<ul>,<a>).)}</Layout.import LayoutFlex>const Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>One-axis layout box: the primitive that replaces hand-written
flex …wrapper divs.gapis restricted to the named steps of the theme spacing ramp (seeGap
), which is the point of the prop — an off-ramp
gap-2/gap-3literal in a container is the drift it prevents. Anything the props don't cover (padding, sizing, overflow, colour) goes throughclassNames; 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 CSSstretchinitial value.Use
asChildto project the layout onto a semantic element (<header>,<ul>,<a>).);};/** A form built from `Person`'s schema; each change is written to the object as it is made. */constEditDialog = ({const EditDialog: ({ label, person }: {label: string;person: Person;}) => React.JSX.ElementA form built from
Person's schema; each change is written to the object as it is made.label,label: stringperson }: {person: Personlabel: string;label: stringperson:person: PersonPerson }) => {class Personconst [snapshot] =const snapshot: Obj.Snapshot<Person>useObject(useObject<Person>(obj: Person): [Obj.Snapshot<Person>, ObjectUpdateCallback<Person>] (+9 overloads)Hook to subscribe to an entire Echo object. Returns a snapshot of the current object value and automatically re-renders when the object changes.
person);person: Personreturn (<Dialog.import DialogRoot>function Root({ lazyMount, unmountOnExit, closeOnInteractOutside, placement, ...props }: Dialog.RootProps): React.JSX.Elementexport Root<Dialog.import DialogTriggerconst Trigger: React.ForwardRefExoticComponent<DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>export TriggerUse
asChildto open the dialog from aButton.asChild>PolymorphicProps.asChild?: boolean | undefinedUse the provided child element as the default rendered element, combining their props and behavior.
<Button.import ButtonRootconst Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & {classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLButtonElement>>export Rooticon='ph--pencil-simple--regular'icon?: string | undefinedLeading icon.
label={label?: string | undefinedVisible text;
childrentake precedence.Required: names the button (
aria-label) and shows in a Tooltip.label}label: stringiconOnly />iconOnly?: boolean | undefinedA control-sized square inset in a block-sized cell (follow-up 19), showing only the icon.
</Dialog.import DialogTrigger>const Trigger: React.ForwardRefExoticComponent<DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>export TriggerUse
asChildto open the dialog from aButton.<Dialog.import DialogContent>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 ContentPortalled surface at
level='raised'over a scrim, centred in the viewport: a column of Header, Body and Footer.<Dialog.import DialogHeader>const Header: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & React.RefAttributes<HTMLDivElement>>export HeaderA block row holding the Title and an optional trailing CloseTrigger.
<Dialog.import DialogTitle>{const Title: React.ForwardRefExoticComponent<Omit<DialogTitleProps, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {srOnly?: boolean;} & React.RefAttributes<HTMLHeadingElement>>export Titlesnapshot.const snapshot: Obj.Snapshot<Person>name}</name: stringDialog.import DialogTitle>const Title: React.ForwardRefExoticComponent<Omit<DialogTitleProps, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & {srOnly?: boolean;} & React.RefAttributes<HTMLHeadingElement>>export Title<Dialog.import DialogCloseTrigger />const CloseTrigger: React.ForwardRefExoticComponent<Omit<DialogCloseTriggerProps, "children"> & {children?: React.ReactNode;icon?: string;label?: string;} & React.RefAttributes<HTMLButtonElement>>export CloseTrigger</Dialog.import DialogHeader>const Header: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & React.RefAttributes<HTMLDivElement>>export HeaderA block row holding the Title and an optional trailing CloseTrigger.
<Dialog.import DialogBody>const Body: React.ForwardRefExoticComponent<Omit<Pick<ScrollAreaRootProps, "mode" | "native" | "width">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<Layout.ContainerProps, "gap"> & {align?: "start" | "center";children?: React.ReactNode;} & React.RefAttributes<HTMLDivElement>>export BodyComposed scroll (decision 5): a
gutter='md'Container as the viewport, so the thumb sits in the end gutter;gapspaces its rows, since they are the Container's own items. The element carries ScrollArea'sdata-scope, since parts cannot rescope a composed child (finding 10).<ObjectFormconst ObjectForm: ({ object, type, schema, showTags }: ObjectFormProps) => React.JSX.ElementAn object's properties (and meta tags) as a next Form in its host's grid, writing each change back.
type={type: AnyEntityPerson}class Personobject={object: Obj.Unknownperson}person: PersonshowTags={false} />showTags?: boolean | undefinedRender the meta-tags field. Defaults to
true.</Dialog.import DialogBody>const Body: React.ForwardRefExoticComponent<Omit<Pick<ScrollAreaRootProps, "mode" | "native" | "width">, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<Layout.ContainerProps, "gap"> & {align?: "start" | "center";children?: React.ReactNode;} & React.RefAttributes<HTMLDivElement>>export BodyComposed scroll (decision 5): a
gutter='md'Container as the viewport, so the thumb sits in the end gutter;gapspaces its rows, since they are the Container's own items. The element carries ScrollArea'sdata-scope, since parts cannot rescope a composed child (finding 10).</Dialog.import DialogContent>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 ContentPortalled surface at
level='raised'over a scrim, centred in the viewport: a column of Header, Body and Footer.</Dialog.import DialogRoot>function Root({ lazyMount, unmountOnExit, closeOnInteractOutside, placement, ...props }: Dialog.RootProps): React.JSX.Elementexport Root);};export constContactsScreen = ({const ContactsScreen: ({ db }: {db: Database.Database;}) => React.JSX.Elementdb }: {db: Database.Databasedb:db: Database.DatabaseDatabase.import DatabaseDatabase }) => {interface DatabaseECHO Database interface.
const {t } =const t: TFunction<Namespace<string>, KeyPrefix<Namespace<string>>>Hooks.import HooksuseTranslation(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 useTranslationns);const ns: "com.example.contacts"constcontacts =const contacts: Entity<Person & OfKind<EntityKind.Object>>[]useQuery(useQuery<Query.Query<Person & OfKind<EntityKind.Object>>, Entity<Person & OfKind<EntityKind.Object>>>(resource: Database.Queryable | undefined, query: Query.Query<Person & OfKind<EntityKind.Object>>): Entity<Person & OfKind<EntityKind.Object>>[] (+3 overloads)Create subscription.
db,db: Database.Databasepeople);const people: Query.Query<Person & OfKind<EntityKind.Object>>const [selected,const selected: string | undefinedsetSelected] =const setSelected: React.Dispatch<React.SetStateAction<string | undefined>>useState<string>();useState<string>(): [string | undefined, React.Dispatch<React.SetStateAction<string | undefined>>] (+1 overload)Returns a stateful value, and a function to update it.
constperson =const person: Entity<Person & OfKind<EntityKind.Object>> | undefinedcontacts.const contacts: Entity<Person & OfKind<EntityKind.Object>>[]find(({Array<Entity<Person & OfKind<EntityKind.Object>>>.find(predicate: (value: Entity<Person & OfKind<EntityKind.Object>>, index: number, obj: Entity<Person & OfKind<EntityKind.Object>>[]) => unknown, thisArg?: any): Entity<Person & OfKind<EntityKind.Object>> | undefined (+1 overload)Returns the value of the first element in the array where predicate is true, and undefined otherwise.
id }) =>id: stringid ===id: stringselected);const selected: string | undefinedconsthandleAdd = () => {const handleAdd: () => voidconstname: string =const name: stringt('new-contact.name');const t: TFunction<"new-contact.name", string, StringMap>(key: "new-contact.name" | "new-contact.name"[], options?: string | TOptions<StringMap> | undefined) => string (+1 overload)constperson =const person: BaseObj & Person & OfKind<EntityKind.Object>db.db: Database.Databaseadd(Database.add<BaseObj & Person & OfKind<EntityKind.Object>>(obj: BaseObj & Person & OfKind<EntityKind.Object>, opts?: Database.AddOptions): BaseObj & Person & OfKind<EntityKind.Object>Adds an object or relation to the database.
Only Object and Relation entities are accepted. To persist a Type definition use
addType
— passing a Type entity is rejected at compile time (and at runtime).
Pass
{ to: feed }to append to a feed instead (synchronous; confirm withflush
).
Obj.import Objmake(function make<typeof Person>(type: typeof Person, props: NoInfer<Obj.MakeProps<typeof Person>>, options?: Obj.MakeOptions): Obj.OfShape<Person & OfKind<EntityKind.Object>>Creates a new echo object of the given schema or
Type.Type.Person, {class Personname }));name: stringsetSelected(const setSelected: (value: React.SetStateAction<string | undefined>) => voidperson.const person: BaseObj & Person & OfKind<EntityKind.Object>id);id: string};consthandleDelete = (const handleDelete: (person: Person) => voidperson:person: PersonPerson) => {class Persondb.db: Database.Databaseremove(Database.remove(obj: Unknown, opts?: Database.WriteOptions): voidRemoves object from the database.
person);person: PersonsetSelected(const setSelected: (value: React.SetStateAction<string | undefined>) => voidundefined);var undefined};return (<Panel.import PanelRoot>const Root: React.ForwardRefExoticComponent<Omit<Panel.RootProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export RootThe plank host: fills its parent, sets
data-sizeand a level for its subtree, and is the pane's query container, so its header, body and footer collapse at the same pane width.<Panel.import PanelHeader>const Header: React.ForwardRefExoticComponent<Omit<{asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export HeaderThe 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.<Toolbar.import ToolbarRoot>const Root: React.ForwardRefExoticComponent<Omit<Toolbar.RootProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export Rootrole=toolbarwith 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.<Toolbar.import ToolbarText>{const Text: React.ForwardRefExoticComponent<Omit<{asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export TextA run of text that takes the free space and truncates; not an item, so roving focus skips it.
t('title.label')}</const t: TFunction<"title.label", ReactI18NextChild | Iterable<ReactI18NextChild>, StringMap>(key: "title.label" | "title.label"[], options?: string | TOptions<StringMap> | undefined) => ReactI18NextChild | Iterable<ReactI18NextChild> (+1 overload)Toolbar.import ToolbarText>const Text: React.ForwardRefExoticComponent<Omit<{asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export TextA run of text that takes the free space and truncates; not an item, so roving focus skips it.
<Toolbar.import ToolbarText>{const Text: React.ForwardRefExoticComponent<Omit<{asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export TextA run of text that takes the free space and truncates; not an item, so roving focus skips it.
t('count.label', {const t: TFunction<"count.label", ReactI18NextChild | Iterable<ReactI18NextChild>, {count: number;}>(key: "count.label" | "count.label"[], options?: string | TOptions<{count: number;}> | undefined) => ReactI18NextChild | Iterable<ReactI18NextChild> (+1 overload)count:count: numberCount value used for plurals
contacts.const contacts: Entity<Person & OfKind<EntityKind.Object>>[]length })}</Array<T>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.
Toolbar.import ToolbarText>const Text: React.ForwardRefExoticComponent<Omit<{asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export TextA run of text that takes the free space and truncates; not an item, so roving focus skips it.
<Toolbar.import ToolbarSeparatorconst Separator: React.ForwardRefExoticComponent<Omit<Toolbar.SeparatorProps, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export SeparatorA 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.variant='gap' />variant?: "line" | "gap" | undefinedgapis an empty spacer that grows, pushing the items after it to the toolbar's end.<Button.import ButtonRootconst Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & {classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLButtonElement>>export Rooticon='ph--plus--regular'icon?: string | undefinedLeading icon.
label={label?: string | undefinedVisible text;
childrentake precedence.Required: names the button (
aria-label) and shows in a Tooltip.t('add.label')}const t: TFunction<"add.label", string | undefined, StringMap>(key: "add.label" | "add.label"[], options?: string | TOptions<StringMap> | undefined) => string | undefined (+1 overload)iconOnlyiconOnly?: boolean | undefinedA control-sized square inset in a block-sized cell (follow-up 19), showing only the icon.
onClick={onClick?: React.MouseEventHandler<HTMLButtonElement> | undefinedhandleAdd} />const handleAdd: () => void{person && <const person: Entity<Person & OfKind<EntityKind.Object>> | undefinedEditDialogconst EditDialog: ({ label, person }: {label: string;person: Person;}) => React.JSX.ElementA form built from
Person's schema; each change is written to the object as it is made.label={label: stringt('edit.label')}const t: TFunction<"edit.label", string, StringMap>(key: "edit.label" | "edit.label"[], options?: string | TOptions<StringMap> | undefined) => string (+1 overload)person={person: Personperson} />}const person: Entity<Person & OfKind<EntityKind.Object>>{person && <const person: Entity<Person & OfKind<EntityKind.Object>> | undefinedDeletePopoverconst DeletePopover: ({ label, onDelete }: DeletePopoverProps) => React.JSX.Elementlabel={label: stringt('delete.label')}const t: TFunction<"delete.label", string, StringMap>(key: "delete.label" | "delete.label"[], options?: string | TOptions<StringMap> | undefined) => string (+1 overload)onDelete={() =>onDelete: () => voidhandleDelete(const handleDelete: (person: Person) => voidperson)} />}const person: Entity<Person & OfKind<EntityKind.Object>></Toolbar.import ToolbarRoot>const Root: React.ForwardRefExoticComponent<Omit<Toolbar.RootProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export Rootrole=toolbarwith 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.</Panel.import PanelHeader>const Header: React.ForwardRefExoticComponent<Omit<{asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export HeaderThe 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.<Panel.import PanelBodyconst Body: React.ForwardRefExoticComponent<Omit<{asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export BodyThe growing middle row, a plain slot: it neither scrolls nor adds a gutter, so content composes its own frame (
asChildonto aScrollArea.Rootaround 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.asChild>asChild?: boolean | undefined<Layout.import LayoutGridconst Grid: React.ForwardRefExoticComponent<Omit<Layout.GridProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>CSS grid container.
cols/rowstake a count for equal tracks, or a list of tokens for anything asymmetric:cols={['fill', 'min']}isgrid-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.subgridadopts 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. CheckColumn.RowandCard.Rowfirst — both already are 3-track subgrid rows.gapis restricted to the named steps of the theme spacing ramp (seeGap
). As with
Flex, padding, sizing, and colour go throughclassNamesrather than growing props here.cols={['16rem', 'fill']}cols?: Layout.GridTracks | undefinedgrow>grow?: boolean | undefinedFill and clip the parent (
dx-expand); off by default, asFlex's is, so a grid sizes to its content.<PeopleListconst PeopleList: ({ people, selected, onSelect }: PeopleListProps) => React.JSX.Elementpeople={people: Person[]contacts}const contacts: Entity<Person & OfKind<EntityKind.Object>>[]selected={selected?: string | undefinedselected}const selected: string | undefinedonSelect={onSelect: (id: string) => voidsetSelected} />const setSelected: React.Dispatch<React.SetStateAction<string | undefined>>{person ? (const person: Entity<Person & OfKind<EntityKind.Object>> | undefined<PersonDetailconst PersonDetail: ({ person }: {person: Person;}) => React.JSX.ElementRe-renders when this person changes, here or on another peer.
person={person: Personperson} />const person: Entity<Person & OfKind<EntityKind.Object>>) : (<Status.import StatusEmptyconst Empty: React.ForwardRefExoticComponent<Omit<Status.EmptyProps, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & 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
Emptypart on it.icon='ph--address-book--regular'>{icon?: string | undefinedA Phosphor icon above the message; decorative, since the message carries the statement.
t('empty.message')}</const t: TFunction<"empty.message", ReactI18NextChild | Iterable<ReactI18NextChild>, StringMap>(key: "empty.message" | "empty.message"[], options?: string | TOptions<StringMap> | undefined) => ReactI18NextChild | Iterable<ReactI18NextChild> (+1 overload)Status.import StatusEmpty>const Empty: React.ForwardRefExoticComponent<Omit<Status.EmptyProps, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & 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
Emptypart on it.)}</Layout.import LayoutGrid>const Grid: React.ForwardRefExoticComponent<Omit<Layout.GridProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>CSS grid container.
cols/rowstake a count for equal tracks, or a list of tokens for anything asymmetric:cols={['fill', 'min']}isgrid-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.subgridadopts 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. CheckColumn.RowandCard.Rowfirst — both already are 3-track subgrid rows.gapis restricted to the named steps of the theme spacing ramp (seeGap
). As with
Flex, padding, sizing, and colour go throughclassNamesrather than growing props here.</Panel.import PanelBody>const Body: React.ForwardRefExoticComponent<Omit<{asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export BodyThe growing middle row, a plain slot: it neither scrolls nor adds a gutter, so content composes its own frame (
asChildonto aScrollArea.Rootaround 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.</Panel.import PanelRoot>const Root: React.ForwardRefExoticComponent<Omit<Panel.RootProps & {asChild?: boolean;}, "className"> & {classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "style" | "role" | "children"> & React.RefAttributes<HTMLDivElement>>export RootThe plank host: fills its parent, sets
data-sizeand a level for its subtree, and is the pane's query container, so its header, body and footer collapse at the same pane width.);};const contacts = useQuery(db, people)is the line that replacesuseState(CONTACTS). OneuseStateis left, and it holdsselected, the id of the chosen person, whichhandleAddandhandleDeletestill set. -
Open a space. A space is a database that its members share, and an identity owns the spaces it creates. The first time the app runs,
setUpcreates an identity and then a space.Contactsshows the screen once the space is there.Add
src/echo/main.tsx, starting with the same stylesheet imports as the first entry point,import '@dxos-theme';andimport '@dxos/react-ui/theme.css';:import { typeClient } from '@dxos/client';class ClientThe Client class encapsulates the core client-side API of DXOS.
2 collapsed linesimport {Config } from '@dxos/config';class ConfigGlobal configuration object. NOTE: Config objects are immutable.
import {ClientProvider } from '@dxos/react-client';const ClientProvider: React.ForwardRefExoticComponent<Omit<ClientOptions, "config" | "services"> & Pick<ClientContextProps, "status"> & {client?: Client | Provider<Promise<Client>>;config?: Config | Provider<Promise<Config>>;services?: ClientServicesProvider | ((config?: Config) => MaybePromise<ClientServicesProvider>);fallback?: React.FunctionComponent<Partial<ClientContextProps>>;suspend?: boolean;noBanner?: boolean;onInitialized?: (client: Client) => MaybePromise<void>;} & {...;} & React.RefAttributes<...>>Root component that provides the DXOS client instance to child components. To be used with the
useClienthook.import {useSpaces } from '@dxos/react-client/echo';const useSpaces: ({ all }?: UseSpacesProps) => Space[]Get all Spaces available to current user. Requires a ClientProvider somewhere in the parent tree. By default, only ready spaces are returned.
6 collapsed linesimport '@dxos/react-ui/theme.css';import {translations asconst translations: [{readonly 'en-US': {readonly "@dxos/react-ui-form": {readonly "ref-editor.placeholder": "Type '@' to add a reference, or enter a value";readonly "ref-editor-auto.placeholder": "Search by name, or enter a value";readonly "fields.label": "Fields";readonly "hidden-fields.label": "Hidden Fields";readonly "empty-readonly-ref-field.label": "(none)";readonly "field-property.label": "Property";readonly "field-property.placeholder": "Property name";readonly "field-format.label": "Type";readonly "field-path.label": "Field path";readonly "remove-item.button": "Delete item";readonly "add-item.button": "Add item";readonly "add-property-button.label": "Add property";readonly "boolean-input-true.value": "Yes";readonly "boolean-input-false.value": "No";readonly "indeterminate.placeholder": "Mixed";readonly "select-none.label": "None";readonly "show-field.label": "Show field";readonly "hide-field.label": "Hide field";readonly "delete-field.label": "Delete field";readonly "create-option.label": "Create";readonly "add-tag.label": "Add tag";readonly "add-tag-query.label": "Add tag \u201C{{text}}\u201D";readonly "ref-field-combobox-input.placeholder": "Search\u2026";readonly "ref-field.placeholder": "Select\u2026";readonly "ref-field.placeholder_one": "Select\u2026";readonly "ref-field.placeholder_other": "Select items\u2026";readonly "untitled.label": "Untitled";readonly "example.placeholder": "Example";readonly "select.placeholder": "Select\u2026";readonly "latitude.placeholder": "Latitude (e.g., 40.7128)";readonly "longitude.placeholder": "Longitude (e.g., -74.0060)";readonly "cancel-button.label": "Cancel";readonly "save-button.label": "Save";readonly "create-text.label": "Create text";readonly "format.boolean.label": "Boolean";readonly "format.currency.label": "Currency";readonly "format.date.label": "Date";readonly "format.date-time.label": "DateTime";readonly "format.did.label": "DID";readonly "format.duration.label": "Duration";readonly "format.dxn.label": "DXN";readonly "format.email.label": "Email";readonly "format.formula.label": "Formula";readonly "format.hostname.label": "Hostname";readonly "format.integer.label": "Integer";readonly "format.json.label": "JSON";readonly "format.lnglat.label": "Geopoint";readonly "format.markdown.label": "Markdown";readonly "format.password.label": "Password";readonly "format.percent.label": "Percent";readonly "format.ref.label": "Reference";readonly "format.regex.label": "RegExp";readonly "format.string.label": "String";readonly "format.single-select.label": "Select";readonly "format.multi-select.label": "Multi-select";readonly "format.text.label": "Long text";readonly "format.time.label": "Time";readonly "format.timestamp.label": "Timestamp";readonly "format.user.label": "User";readonly "format.number.label": "Number";readonly "format.uri.label": "URI";readonly "format.url.label": "URL";readonly "format.uuid.label": "UUID";readonly "latitude.label": "Latitude";readonly "longitude.label": "Longitude";readonly "select-option.label": "Label";readonly "select-option-label.placeholder": "Option label";readonly "select-option-color.label": "Color";readonly "select-option-delete.button": "Delete";readonly "select-option-add.button": "Add option";readonly "system-schema.title": "System type";readonly "system-schema.description": "System type: cannot add or remove fields.";readonly "remove.button": "Delete";};};}]formTranslations } from '@dxos/react-ui-form/translations';const formTranslations: [{readonly 'en-US': {readonly "@dxos/react-ui-form": {readonly "ref-editor.placeholder": "Type '@' to add a reference, or enter a value";readonly "ref-editor-auto.placeholder": "Search by name, or enter a value";readonly "fields.label": "Fields";readonly "hidden-fields.label": "Hidden Fields";readonly "empty-readonly-ref-field.label": "(none)";readonly "field-property.label": "Property";readonly "field-property.placeholder": "Property name";readonly "field-format.label": "Type";readonly "field-path.label": "Field path";readonly "remove-item.button": "Delete item";readonly "add-item.button": "Add item";readonly "add-property-button.label": "Add property";readonly "boolean-input-true.value": "Yes";readonly "boolean-input-false.value": "No";readonly "indeterminate.placeholder": "Mixed";readonly "select-none.label": "None";readonly "show-field.label": "Show field";readonly "hide-field.label": "Hide field";readonly "delete-field.label": "Delete field";readonly "create-option.label": "Create";readonly "add-tag.label": "Add tag";readonly "add-tag-query.label": "Add tag \u201C{{text}}\u201D";readonly "ref-field-combobox-input.placeholder": "Search\u2026";readonly "ref-field.placeholder": "Select\u2026";readonly "ref-field.placeholder_one": "Select\u2026";readonly "ref-field.placeholder_other": "Select items\u2026";readonly "untitled.label": "Untitled";readonly "example.placeholder": "Example";readonly "select.placeholder": "Select\u2026";readonly "latitude.placeholder": "Latitude (e.g., 40.7128)";readonly "longitude.placeholder": "Longitude (e.g., -74.0060)";readonly "cancel-button.label": "Cancel";readonly "save-button.label": "Save";readonly "create-text.label": "Create text";readonly "format.boolean.label": "Boolean";readonly "format.currency.label": "Currency";readonly "format.date.label": "Date";readonly "format.date-time.label": "DateTime";readonly "format.did.label": "DID";readonly "format.duration.label": "Duration";readonly "format.dxn.label": "DXN";readonly "format.email.label": "Email";readonly "format.formula.label": "Formula";readonly "format.hostname.label": "Hostname";readonly "format.integer.label": "Integer";readonly "format.json.label": "JSON";readonly "format.lnglat.label": "Geopoint";readonly "format.markdown.label": "Markdown";readonly "format.password.label": "Password";readonly "format.percent.label": "Percent";readonly "format.ref.label": "Reference";readonly "format.regex.label": "RegExp";readonly "format.string.label": "String";readonly "format.single-select.label": "Select";readonly "format.multi-select.label": "Multi-select";readonly "format.text.label": "Long text";readonly "format.time.label": "Time";readonly "format.timestamp.label": "Timestamp";readonly "format.user.label": "User";readonly "format.number.label": "Number";readonly "format.uri.label": "URI";readonly "format.url.label": "URL";readonly "format.uuid.label": "UUID";readonly "latitude.label": "Latitude";readonly "longitude.label": "Longitude";readonly "select-option.label": "Label";readonly "select-option-label.placeholder": "Option label";readonly "select-option-color.label": "Color";readonly "select-option-delete.button": "Delete";readonly "select-option-add.button": "Add option";readonly "system-schema.title": "System type";readonly "system-schema.description": "System type: cannot add or remove fields.";readonly "remove.button": "Delete";};};}]import * asTheme from '@dxos/react-ui/Theme';import Themeimport {translations asconst translations: [{readonly 'en-US': {readonly "@dxos/react-ui": {readonly "empty.label": "No items";readonly "error-fallback.title.label": "Runtime Error";readonly "error-fallback.stack.label": "Stack";readonly "error-fallback.data.label": "Data";readonly "steps.step.label": "Step {{index}}";readonly "remove.label": "Delete";readonly "toolbar-menu.label": "Action menu";readonly "toolbar-drag-handle.label": "Drag to rearrange";readonly "toolbar-close.label": "Close";readonly "toolbar-delete.label": "Delete";readonly "floating-panel.minimize.label": "Minimize";readonly "floating-panel.maximize.label": "Maximize";readonly "floating-panel.restore.label": "Restore";readonly "drawer.resize.label": "Resize drawer";readonly "system-button.star.label": "Star";readonly "system-button.unstar.label": "Unstar";readonly "system-button.bookmark.label": "Bookmark";readonly "system-button.unbookmark.label": "Remove bookmark";readonly "system-button.check.label": "Check";readonly "system-button.uncheck.label": "Uncheck";readonly "system-button.expand.label": "Expand";readonly "system-button.collapse.label": "Collapse";readonly "system-button.ai.label": "Run AI";readonly "system-button.add.label": "Add";readonly "system-button.delete.label": "Delete";readonly "system-button.remove.label": "Delete";readonly "system-button.edit.label": "Edit";readonly "system-button.close.label": "Close";readonly "system-button.open.label": "Open";readonly "system-button.save.label": "Save";readonly "system-button.cancel.label": "Cancel";readonly "system-button.upload.label": "Upload";readonly "system-button.download.label": "Download";readonly "system-button.clipboard.label": "Copy";readonly "system-button.copied.label": "Copied";readonly "carousel-viewport.label": "Carousel";readonly "carousel-prev.label": "Previous slide";readonly "carousel-next.label": "Next slide";readonly "carousel-indicators.label": "Carousel slides";readonly "carousel-go-to.label": "Go to slide {{index}}";readonly "date-picker.placeholder.single.label": "Pick a date";readonly "date-picker.placeholder.range.label": "Pick a date range";readonly "date-picker.placeholder.multiple.label": "Pick dates";readonly "date-picker.clear.label": "Clear";readonly "calendar.nav.previous.label": "Previous month";readonly "calendar.nav.next.label": "Next month";readonly "calendar.nav.previous-year.label": "Previous year";readonly "calendar.nav.next-year.label": "Next year";readonly "calendar.nav.previous-decade.label": "Previous decade";readonly "calendar.nav.next-decade.label": "Next decade";readonly "calendar.footer.today.label": "Today";readonly "trigger-button.label": "Open";readonly "number-input.increment.label": "Increment";readonly "number-input.decrement.label": "Decrement";readonly "number-input.slider.label": "Adjust";readonly "password-input.show.label": "Show password";readonly "password-input.hide.label": "Hide password";readonly "tag.delete.label": "Remove {{label}}";readonly "combobox.search.label": "Search";readonly "combobox.empty.label": "No results";readonly "combobox.loading.label": "Loading\u2026";readonly "combobox.create.label": "Create \u201C{{query}}\u201D";readonly "drag-handle.label": "Drag to rearrange";readonly "drag-handle.role.label": "drag handle";readonly "drag-handle.grabbed.message": "Grabbed. Press the arrow keys to move, Space to drop.";readonly "drag-handle.moved-up.message": "Moved up.";readonly "drag-handle.moved-down.message": "Moved down.";readonly "drag-handle.dropped.message": "Dropped.";};};}]uiTranslations } from '@dxos/react-ui/translations';const uiTranslations: [{readonly 'en-US': {readonly "@dxos/react-ui": {readonly "empty.label": "No items";readonly "error-fallback.title.label": "Runtime Error";readonly "error-fallback.stack.label": "Stack";readonly "error-fallback.data.label": "Data";readonly "steps.step.label": "Step {{index}}";readonly "remove.label": "Delete";readonly "toolbar-menu.label": "Action menu";readonly "toolbar-drag-handle.label": "Drag to rearrange";readonly "toolbar-close.label": "Close";readonly "toolbar-delete.label": "Delete";readonly "floating-panel.minimize.label": "Minimize";readonly "floating-panel.maximize.label": "Maximize";readonly "floating-panel.restore.label": "Restore";readonly "drawer.resize.label": "Resize drawer";readonly "system-button.star.label": "Star";readonly "system-button.unstar.label": "Unstar";readonly "system-button.bookmark.label": "Bookmark";readonly "system-button.unbookmark.label": "Remove bookmark";readonly "system-button.check.label": "Check";readonly "system-button.uncheck.label": "Uncheck";readonly "system-button.expand.label": "Expand";readonly "system-button.collapse.label": "Collapse";readonly "system-button.ai.label": "Run AI";readonly "system-button.add.label": "Add";readonly "system-button.delete.label": "Delete";readonly "system-button.remove.label": "Delete";readonly "system-button.edit.label": "Edit";readonly "system-button.close.label": "Close";readonly "system-button.open.label": "Open";readonly "system-button.save.label": "Save";readonly "system-button.cancel.label": "Cancel";readonly "system-button.upload.label": "Upload";readonly "system-button.download.label": "Download";readonly "system-button.clipboard.label": "Copy";readonly "system-button.copied.label": "Copied";readonly "carousel-viewport.label": "Carousel";readonly "carousel-prev.label": "Previous slide";readonly "carousel-next.label": "Next slide";readonly "carousel-indicators.label": "Carousel slides";readonly "carousel-go-to.label": "Go to slide {{index}}";readonly "date-picker.placeholder.single.label": "Pick a date";readonly "date-picker.placeholder.range.label": "Pick a date range";readonly "date-picker.placeholder.multiple.label": "Pick dates";readonly "date-picker.clear.label": "Clear";readonly "calendar.nav.previous.label": "Previous month";readonly "calendar.nav.next.label": "Next month";readonly "calendar.nav.previous-year.label": "Previous year";readonly "calendar.nav.next-year.label": "Next year";readonly "calendar.nav.previous-decade.label": "Previous decade";readonly "calendar.nav.next-decade.label": "Next decade";readonly "calendar.footer.today.label": "Today";readonly "trigger-button.label": "Open";readonly "number-input.increment.label": "Increment";readonly "number-input.decrement.label": "Decrement";readonly "number-input.slider.label": "Adjust";readonly "password-input.show.label": "Show password";readonly "password-input.hide.label": "Hide password";readonly "tag.delete.label": "Remove {{label}}";readonly "combobox.search.label": "Search";readonly "combobox.empty.label": "No results";readonly "combobox.loading.label": "Loading\u2026";readonly "combobox.create.label": "Create \u201C{{query}}\u201D";readonly "drag-handle.label": "Drag to rearrange";readonly "drag-handle.role.label": "drag handle";readonly "drag-handle.grabbed.message": "Grabbed. Press the arrow keys to move, Space to drop.";readonly "drag-handle.moved-up.message": "Moved up.";readonly "drag-handle.moved-down.message": "Moved down.";readonly "drag-handle.dropped.message": "Dropped.";};};}]import {translations } from '../icons/translations.ts';const translations: [{readonly 'en-US': {readonly "com.example.contacts": {readonly 'title.label': "Contacts";readonly 'count.label_one': "{{count}} contact";readonly 'count.label_other': "{{count}} contacts";readonly 'add.label': "Add contact";readonly 'edit.label': "Edit contact";readonly 'delete.label': "Delete contact";readonly 'empty.message': "Choose a contact";readonly 'new-contact.name': "New contact";readonly 'role.viewer': "Can read the contact book";readonly 'role.editor': "Can change contacts";readonly 'role.admin': "Can change contacts and who has access";};};}]import {ContactsScreen } from './ContactsScreen.tsx';const ContactsScreen: ({ db }: {db: Database;}) => React.JSX.Element2 collapsed linesimport {Organization,class OrganizationPerson } from './schema.ts';class Person/** Gives the app an identity the first time it runs, and a space to keep the contacts in. */constsetUp = async (const setUp: (client: Client) => Promise<void>Gives the app an identity the first time it runs, and a space to keep the contacts in.
client:client: ClientClient) => {class ClientThe Client class encapsulates the core client-side API of DXOS.
if (!client.client: Clienthalo.Client.halo: HaloHALO credentials.
identity.Halo.identity: MulticastObservable<Identity | null>get()) {MulticastObservable<Identity | null>.get(): Identity | nullGet the current value of the observable.
awaitclient.client: Clienthalo.Client.halo: HaloHALO credentials.
createIdentity();Halo.createIdentity(options?: ProfileDocument, deviceProfile?: DeviceProfileDocument): Promise<Identity>}if (client.client: Clientspaces.Client.spaces: EchoECHO Spaces.
get().Echo.get(): Space[] (+2 overloads)Returns the list of spaces.
length === 0) {Array<T>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.
awaitclient.client: Clientspaces.Client.spaces: EchoECHO Spaces.
create({Echo.create(props?: Pick<SpaceProperties, "name" | "hue" | "icon" | "invocationTraceFeed">, options?: CreateSpaceOptions): Promise<Space>Creates a new space.
name: 'Contacts' });name?: string | undefined}};/** Shows the screen once the space is there. */constContacts = () => {const Contacts: () => React.JSX.Element | nullShows the screen once the space is there.
const [space] =const space: SpaceuseSpaces();function useSpaces({ all }?: UseSpacesProps): Space[]Get all Spaces available to current user. Requires a ClientProvider somewhere in the parent tree. By default, only ready spaces are returned.
returnspace ? <const space: SpaceContactsScreenconst ContactsScreen: ({ db }: {db: Database;}) => React.JSX.Elementdb={db: Databasespace.const space: Spacedb} /> : null;Space.db: EchoDatabaseEcho database.
}; -
Render it inside the client.
ClientProviderstarts ECHO with the types the app uses, and runssetUponce the client is ready. Its config is the one from ECHO’s Installation page. The config keeps the data across reloads, and reaches other devices through EDGE, the always-online peer that DXOS runs.The theme provider goes inside it, and now also registers
@dxos/react-ui-form’s strings:import {createRoot } from 'react-dom/client';function createRoot(container: Container, options?: RootOptions): RootcreateRoot lets you create a root to display React components inside a browser DOM node.
2 collapsed linesimport { typeClient } from '@dxos/client';class ClientThe Client class encapsulates the core client-side API of DXOS.
import {Config } from '@dxos/config';class ConfigGlobal configuration object. NOTE: Config objects are immutable.
import {ClientProvider } from '@dxos/react-client';const ClientProvider: React.ForwardRefExoticComponent<Omit<ClientOptions, "config" | "services"> & Pick<ClientContextProps, "status"> & {client?: Client | Provider<Promise<Client>>;config?: Config | Provider<Promise<Config>>;services?: ClientServicesProvider | ((config?: Config) => MaybePromise<ClientServicesProvider>);fallback?: React.FunctionComponent<Partial<ClientContextProps>>;suspend?: boolean;noBanner?: boolean;onInitialized?: (client: Client) => MaybePromise<void>;} & {...;} & React.RefAttributes<...>>Root component that provides the DXOS client instance to child components. To be used with the
useClienthook.3 collapsed linesimport {useSpaces } from '@dxos/react-client/echo';const useSpaces: ({ all }?: UseSpacesProps) => Space[]Get all Spaces available to current user. Requires a ClientProvider somewhere in the parent tree. By default, only ready spaces are returned.
import '@dxos/react-ui/theme.css';import {translations asconst translations: [{readonly 'en-US': {readonly "@dxos/react-ui-form": {readonly "ref-editor.placeholder": "Type '@' to add a reference, or enter a value";readonly "ref-editor-auto.placeholder": "Search by name, or enter a value";readonly "fields.label": "Fields";readonly "hidden-fields.label": "Hidden Fields";readonly "empty-readonly-ref-field.label": "(none)";readonly "field-property.label": "Property";readonly "field-property.placeholder": "Property name";readonly "field-format.label": "Type";readonly "field-path.label": "Field path";readonly "remove-item.button": "Delete item";readonly "add-item.button": "Add item";readonly "add-property-button.label": "Add property";readonly "boolean-input-true.value": "Yes";readonly "boolean-input-false.value": "No";readonly "indeterminate.placeholder": "Mixed";readonly "select-none.label": "None";readonly "show-field.label": "Show field";readonly "hide-field.label": "Hide field";readonly "delete-field.label": "Delete field";readonly "create-option.label": "Create";readonly "add-tag.label": "Add tag";readonly "add-tag-query.label": "Add tag \u201C{{text}}\u201D";readonly "ref-field-combobox-input.placeholder": "Search\u2026";readonly "ref-field.placeholder": "Select\u2026";readonly "ref-field.placeholder_one": "Select\u2026";readonly "ref-field.placeholder_other": "Select items\u2026";readonly "untitled.label": "Untitled";readonly "example.placeholder": "Example";readonly "select.placeholder": "Select\u2026";readonly "latitude.placeholder": "Latitude (e.g., 40.7128)";readonly "longitude.placeholder": "Longitude (e.g., -74.0060)";readonly "cancel-button.label": "Cancel";readonly "save-button.label": "Save";readonly "create-text.label": "Create text";readonly "format.boolean.label": "Boolean";readonly "format.currency.label": "Currency";readonly "format.date.label": "Date";readonly "format.date-time.label": "DateTime";readonly "format.did.label": "DID";readonly "format.duration.label": "Duration";readonly "format.dxn.label": "DXN";readonly "format.email.label": "Email";readonly "format.formula.label": "Formula";readonly "format.hostname.label": "Hostname";readonly "format.integer.label": "Integer";readonly "format.json.label": "JSON";readonly "format.lnglat.label": "Geopoint";readonly "format.markdown.label": "Markdown";readonly "format.password.label": "Password";readonly "format.percent.label": "Percent";readonly "format.ref.label": "Reference";readonly "format.regex.label": "RegExp";readonly "format.string.label": "String";readonly "format.single-select.label": "Select";readonly "format.multi-select.label": "Multi-select";readonly "format.text.label": "Long text";readonly "format.time.label": "Time";readonly "format.timestamp.label": "Timestamp";readonly "format.user.label": "User";readonly "format.number.label": "Number";readonly "format.uri.label": "URI";readonly "format.url.label": "URL";readonly "format.uuid.label": "UUID";readonly "latitude.label": "Latitude";readonly "longitude.label": "Longitude";readonly "select-option.label": "Label";readonly "select-option-label.placeholder": "Option label";readonly "select-option-color.label": "Color";readonly "select-option-delete.button": "Delete";readonly "select-option-add.button": "Add option";readonly "system-schema.title": "System type";readonly "system-schema.description": "System type: cannot add or remove fields.";readonly "remove.button": "Delete";};};}]formTranslations } from '@dxos/react-ui-form/translations';const formTranslations: [{readonly 'en-US': {readonly "@dxos/react-ui-form": {readonly "ref-editor.placeholder": "Type '@' to add a reference, or enter a value";readonly "ref-editor-auto.placeholder": "Search by name, or enter a value";readonly "fields.label": "Fields";readonly "hidden-fields.label": "Hidden Fields";readonly "empty-readonly-ref-field.label": "(none)";readonly "field-property.label": "Property";readonly "field-property.placeholder": "Property name";readonly "field-format.label": "Type";readonly "field-path.label": "Field path";readonly "remove-item.button": "Delete item";readonly "add-item.button": "Add item";readonly "add-property-button.label": "Add property";readonly "boolean-input-true.value": "Yes";readonly "boolean-input-false.value": "No";readonly "indeterminate.placeholder": "Mixed";readonly "select-none.label": "None";readonly "show-field.label": "Show field";readonly "hide-field.label": "Hide field";readonly "delete-field.label": "Delete field";readonly "create-option.label": "Create";readonly "add-tag.label": "Add tag";readonly "add-tag-query.label": "Add tag \u201C{{text}}\u201D";readonly "ref-field-combobox-input.placeholder": "Search\u2026";readonly "ref-field.placeholder": "Select\u2026";readonly "ref-field.placeholder_one": "Select\u2026";readonly "ref-field.placeholder_other": "Select items\u2026";readonly "untitled.label": "Untitled";readonly "example.placeholder": "Example";readonly "select.placeholder": "Select\u2026";readonly "latitude.placeholder": "Latitude (e.g., 40.7128)";readonly "longitude.placeholder": "Longitude (e.g., -74.0060)";readonly "cancel-button.label": "Cancel";readonly "save-button.label": "Save";readonly "create-text.label": "Create text";readonly "format.boolean.label": "Boolean";readonly "format.currency.label": "Currency";readonly "format.date.label": "Date";readonly "format.date-time.label": "DateTime";readonly "format.did.label": "DID";readonly "format.duration.label": "Duration";readonly "format.dxn.label": "DXN";readonly "format.email.label": "Email";readonly "format.formula.label": "Formula";readonly "format.hostname.label": "Hostname";readonly "format.integer.label": "Integer";readonly "format.json.label": "JSON";readonly "format.lnglat.label": "Geopoint";readonly "format.markdown.label": "Markdown";readonly "format.password.label": "Password";readonly "format.percent.label": "Percent";readonly "format.ref.label": "Reference";readonly "format.regex.label": "RegExp";readonly "format.string.label": "String";readonly "format.single-select.label": "Select";readonly "format.multi-select.label": "Multi-select";readonly "format.text.label": "Long text";readonly "format.time.label": "Time";readonly "format.timestamp.label": "Timestamp";readonly "format.user.label": "User";readonly "format.number.label": "Number";readonly "format.uri.label": "URI";readonly "format.url.label": "URL";readonly "format.uuid.label": "UUID";readonly "latitude.label": "Latitude";readonly "longitude.label": "Longitude";readonly "select-option.label": "Label";readonly "select-option-label.placeholder": "Option label";readonly "select-option-color.label": "Color";readonly "select-option-delete.button": "Delete";readonly "select-option-add.button": "Add option";readonly "system-schema.title": "System type";readonly "system-schema.description": "System type: cannot add or remove fields.";readonly "remove.button": "Delete";};};}]import * asTheme from '@dxos/react-ui/Theme';import Theme4 collapsed linesimport {translations asconst translations: [{readonly 'en-US': {readonly "@dxos/react-ui": {readonly "empty.label": "No items";readonly "error-fallback.title.label": "Runtime Error";readonly "error-fallback.stack.label": "Stack";readonly "error-fallback.data.label": "Data";readonly "steps.step.label": "Step {{index}}";readonly "remove.label": "Delete";readonly "toolbar-menu.label": "Action menu";readonly "toolbar-drag-handle.label": "Drag to rearrange";readonly "toolbar-close.label": "Close";readonly "toolbar-delete.label": "Delete";readonly "floating-panel.minimize.label": "Minimize";readonly "floating-panel.maximize.label": "Maximize";readonly "floating-panel.restore.label": "Restore";readonly "drawer.resize.label": "Resize drawer";readonly "system-button.star.label": "Star";readonly "system-button.unstar.label": "Unstar";readonly "system-button.bookmark.label": "Bookmark";readonly "system-button.unbookmark.label": "Remove bookmark";readonly "system-button.check.label": "Check";readonly "system-button.uncheck.label": "Uncheck";readonly "system-button.expand.label": "Expand";readonly "system-button.collapse.label": "Collapse";readonly "system-button.ai.label": "Run AI";readonly "system-button.add.label": "Add";readonly "system-button.delete.label": "Delete";readonly "system-button.remove.label": "Delete";readonly "system-button.edit.label": "Edit";readonly "system-button.close.label": "Close";readonly "system-button.open.label": "Open";readonly "system-button.save.label": "Save";readonly "system-button.cancel.label": "Cancel";readonly "system-button.upload.label": "Upload";readonly "system-button.download.label": "Download";readonly "system-button.clipboard.label": "Copy";readonly "system-button.copied.label": "Copied";readonly "carousel-viewport.label": "Carousel";readonly "carousel-prev.label": "Previous slide";readonly "carousel-next.label": "Next slide";readonly "carousel-indicators.label": "Carousel slides";readonly "carousel-go-to.label": "Go to slide {{index}}";readonly "date-picker.placeholder.single.label": "Pick a date";readonly "date-picker.placeholder.range.label": "Pick a date range";readonly "date-picker.placeholder.multiple.label": "Pick dates";readonly "date-picker.clear.label": "Clear";readonly "calendar.nav.previous.label": "Previous month";readonly "calendar.nav.next.label": "Next month";readonly "calendar.nav.previous-year.label": "Previous year";readonly "calendar.nav.next-year.label": "Next year";readonly "calendar.nav.previous-decade.label": "Previous decade";readonly "calendar.nav.next-decade.label": "Next decade";readonly "calendar.footer.today.label": "Today";readonly "trigger-button.label": "Open";readonly "number-input.increment.label": "Increment";readonly "number-input.decrement.label": "Decrement";readonly "number-input.slider.label": "Adjust";readonly "password-input.show.label": "Show password";readonly "password-input.hide.label": "Hide password";readonly "tag.delete.label": "Remove {{label}}";readonly "combobox.search.label": "Search";readonly "combobox.empty.label": "No results";readonly "combobox.loading.label": "Loading\u2026";readonly "combobox.create.label": "Create \u201C{{query}}\u201D";readonly "drag-handle.label": "Drag to rearrange";readonly "drag-handle.role.label": "drag handle";readonly "drag-handle.grabbed.message": "Grabbed. Press the arrow keys to move, Space to drop.";readonly "drag-handle.moved-up.message": "Moved up.";readonly "drag-handle.moved-down.message": "Moved down.";readonly "drag-handle.dropped.message": "Dropped.";};};}]uiTranslations } from '@dxos/react-ui/translations';const uiTranslations: [{readonly 'en-US': {readonly "@dxos/react-ui": {readonly "empty.label": "No items";readonly "error-fallback.title.label": "Runtime Error";readonly "error-fallback.stack.label": "Stack";readonly "error-fallback.data.label": "Data";readonly "steps.step.label": "Step {{index}}";readonly "remove.label": "Delete";readonly "toolbar-menu.label": "Action menu";readonly "toolbar-drag-handle.label": "Drag to rearrange";readonly "toolbar-close.label": "Close";readonly "toolbar-delete.label": "Delete";readonly "floating-panel.minimize.label": "Minimize";readonly "floating-panel.maximize.label": "Maximize";readonly "floating-panel.restore.label": "Restore";readonly "drawer.resize.label": "Resize drawer";readonly "system-button.star.label": "Star";readonly "system-button.unstar.label": "Unstar";readonly "system-button.bookmark.label": "Bookmark";readonly "system-button.unbookmark.label": "Remove bookmark";readonly "system-button.check.label": "Check";readonly "system-button.uncheck.label": "Uncheck";readonly "system-button.expand.label": "Expand";readonly "system-button.collapse.label": "Collapse";readonly "system-button.ai.label": "Run AI";readonly "system-button.add.label": "Add";readonly "system-button.delete.label": "Delete";readonly "system-button.remove.label": "Delete";readonly "system-button.edit.label": "Edit";readonly "system-button.close.label": "Close";readonly "system-button.open.label": "Open";readonly "system-button.save.label": "Save";readonly "system-button.cancel.label": "Cancel";readonly "system-button.upload.label": "Upload";readonly "system-button.download.label": "Download";readonly "system-button.clipboard.label": "Copy";readonly "system-button.copied.label": "Copied";readonly "carousel-viewport.label": "Carousel";readonly "carousel-prev.label": "Previous slide";readonly "carousel-next.label": "Next slide";readonly "carousel-indicators.label": "Carousel slides";readonly "carousel-go-to.label": "Go to slide {{index}}";readonly "date-picker.placeholder.single.label": "Pick a date";readonly "date-picker.placeholder.range.label": "Pick a date range";readonly "date-picker.placeholder.multiple.label": "Pick dates";readonly "date-picker.clear.label": "Clear";readonly "calendar.nav.previous.label": "Previous month";readonly "calendar.nav.next.label": "Next month";readonly "calendar.nav.previous-year.label": "Previous year";readonly "calendar.nav.next-year.label": "Next year";readonly "calendar.nav.previous-decade.label": "Previous decade";readonly "calendar.nav.next-decade.label": "Next decade";readonly "calendar.footer.today.label": "Today";readonly "trigger-button.label": "Open";readonly "number-input.increment.label": "Increment";readonly "number-input.decrement.label": "Decrement";readonly "number-input.slider.label": "Adjust";readonly "password-input.show.label": "Show password";readonly "password-input.hide.label": "Hide password";readonly "tag.delete.label": "Remove {{label}}";readonly "combobox.search.label": "Search";readonly "combobox.empty.label": "No results";readonly "combobox.loading.label": "Loading\u2026";readonly "combobox.create.label": "Create \u201C{{query}}\u201D";readonly "drag-handle.label": "Drag to rearrange";readonly "drag-handle.role.label": "drag handle";readonly "drag-handle.grabbed.message": "Grabbed. Press the arrow keys to move, Space to drop.";readonly "drag-handle.moved-up.message": "Moved up.";readonly "drag-handle.moved-down.message": "Moved down.";readonly "drag-handle.dropped.message": "Dropped.";};};}]import {translations } from '../icons/translations.ts';const translations: [{readonly 'en-US': {readonly "com.example.contacts": {readonly 'title.label': "Contacts";readonly 'count.label_one': "{{count}} contact";readonly 'count.label_other': "{{count}} contacts";readonly 'add.label': "Add contact";readonly 'edit.label': "Edit contact";readonly 'delete.label': "Delete contact";readonly 'empty.message': "Choose a contact";readonly 'new-contact.name': "New contact";readonly 'role.viewer': "Can read the contact book";readonly 'role.editor': "Can change contacts";readonly 'role.admin': "Can change contacts and who has access";};};}]import {ContactsScreen } from './ContactsScreen.tsx';const ContactsScreen: ({ db }: {db: Database;}) => React.JSX.Elementimport {Organization,class OrganizationPerson } from './schema.ts';class Person17 collapsed lines/** Gives the app an identity the first time it runs, and a space to keep the contacts in. */constsetUp = async (const setUp: (client: Client) => Promise<void>Gives the app an identity the first time it runs, and a space to keep the contacts in.
client:client: ClientClient) => {class ClientThe Client class encapsulates the core client-side API of DXOS.
if (!client.client: Clienthalo.Client.halo: HaloHALO credentials.
identity.Halo.identity: MulticastObservable<Identity | null>get()) {MulticastObservable<Identity | null>.get(): Identity | nullGet the current value of the observable.
awaitclient.client: Clienthalo.Client.halo: HaloHALO credentials.
createIdentity();Halo.createIdentity(options?: ProfileDocument, deviceProfile?: DeviceProfileDocument): Promise<Identity>}if (client.client: Clientspaces.Client.spaces: EchoECHO Spaces.
get().Echo.get(): Space[] (+2 overloads)Returns the list of spaces.
length === 0) {Array<T>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.
awaitclient.client: Clientspaces.Client.spaces: EchoECHO Spaces.
create({Echo.create(props?: Pick<SpaceProperties, "name" | "hue" | "icon" | "invocationTraceFeed">, options?: CreateSpaceOptions): Promise<Space>Creates a new space.
name: 'Contacts' });name?: string | undefined}};/** Shows the screen once the space is there. */constContacts = () => {const Contacts: () => React.JSX.Element | nullShows the screen once the space is there.
const [space] =const space: SpaceuseSpaces();function useSpaces({ all }?: UseSpacesProps): Space[]Get all Spaces available to current user. Requires a ClientProvider somewhere in the parent tree. By default, only ready spaces are returned.
returnspace ? <const space: SpaceContactsScreenconst ContactsScreen: ({ db }: {db: Database;}) => React.JSX.Elementdb={db: Databasespace.const space: Spacedb} /> : null;Space.db: EchoDatabaseEcho database.
};/** Keeps the data across reloads and reaches other devices through EDGE, as the ECHO learning path's app does. */constconfig = newconst config: ConfigKeeps the data across reloads and reaches other devices through EDGE, as the ECHO learning path's app does.
Config({new Config(config?: ConfigInit, ...objects: ConfigInit[]): ConfigCreates an immutable instance.
runtime: {runtime: {client: {storage: {persistent: true;};edgeFeatures: {signaling: true;subductionReplicator: true;feedReplicator: true;};};services: {edge: {url: string;};iceProviders: {urls: string;}[];};}client: {client: {storage: {persistent: true;};edgeFeatures: {signaling: true;subductionReplicator: true;feedReplicator: true;};}storage: {storage: {persistent: true;}persistent: true },persistent: trueedgeFeatures: {edgeFeatures: {signaling: true;subductionReplicator: true;feedReplicator: true;}signaling: true,signaling: truesubductionReplicator: true,subductionReplicator: truefeedReplicator: true },feedReplicator: true},services: {services: {edge: {url: string;};iceProviders: {urls: string;}[];}edge: {edge: {url: string;}url: 'https://dxos.network/' },url: stringiceProviders: [{iceProviders: {urls: string;}[]urls: 'https://dxos.network/ice' }],urls: string},},});/** Runs the database in a worker, in the browser's private file system. */constcreateOpfsWorker = () => newconst createOpfsWorker: () => WorkerRuns the database in a worker, in the browser's private file system.
Worker(newvar Worker: new (scriptURL: string | URL, options?: WorkerOptions) => WorkerThe
Workerinterface of the Web Workers API represents a background task that can be created via script, which can send messages back to its creator.URL('@dxos/client/opfs-worker', import.var URL: new (url: string | URL, base?: string | URL) => URLThe
URLinterface is used to parse, construct, normalize, and encode URLs. It works by providing properties which allow you to easily read and modify the components of a URL.URLclass is a global reference forimport { URL } from 'url'https://nodejs.org/api/url.html#the-whatwg-url-apimeta.The type of
import.meta.If you need to declare that a given property exists on
import.meta, this type may be augmented via interface merging.url), {ImportMeta.url: stringThe absolute
file:URL of the module.type: 'module' });WorkerOptions.type?: WorkerType | undefinedcreateRoot(function createRoot(container: Container, options?: RootOptions): RootcreateRoot lets you create a root to display React components inside a browser DOM node.
document.var document: Documentwindow.documentreturns a reference to the document contained in the window.getElementById('root')!).Document.getElementById(elementId: string): HTMLElement | nullThe
getElementById()method of the Document interface returns an Element object representing the element whose id property matches the specified string. Since element IDs are required to be unique if specified, they're a useful way to get access to a specific element quickly.render(Root.render(children: React.ReactNode): void<ClientProviderconst ClientProvider: React.ForwardRefExoticComponent<Omit<ClientOptions, "config" | "services"> & Pick<ClientContextProps, "status"> & {client?: Client | Provider<Promise<Client>>;config?: Config | Provider<Promise<Config>>;services?: ClientServicesProvider | ((config?: Config) => MaybePromise<ClientServicesProvider>);fallback?: React.FunctionComponent<Partial<ClientContextProps>>;suspend?: boolean;noBanner?: boolean;onInitialized?: (client: Client) => MaybePromise<void>;} & {...;} & React.RefAttributes<...>>Root component that provides the DXOS client instance to child components. To be used with the
useClienthook.config={config?: Config | Provider<Promise<Config>> | undefinedConfig object or async provider.
NOTE: If a
clientis provided thenconfigis ignored.config}const config: ConfigKeeps the data across reloads and reaches other devices through EDGE, as the ECHO learning path's app does.
createOpfsWorker={createOpfsWorker?: (() => Worker) | undefinedWhen running in the host mode, a factory to create the worker for OPFS sqlite database.
createOpfsWorker}const createOpfsWorker: () => WorkerRuns the database in a worker, in the browser's private file system.
types={[types?: AnyEntity[] | undefinedECHO schema.
Organization,class OrganizationPerson]}class PersononInitialized={onInitialized?: ((client: Client) => MaybePromise<void>) | undefinedPost initialization hook to enable to caller to do custom initialization.
setUp}const setUp: (client: Client) => Promise<void>Gives the app an identity the first time it runs, and a space to keep the contacts in.
><Theme.import ThemeProviderconst Provider: ({ children, fallback, resourceExtensions, appNs, tx, themeMode, platform, }: Theme.ProviderProps) => React.JSX.Elementexport Providertx={tx?: ThemeFunction<Record<string, any>> | undefinedTheme.import ThemedefaultTx}const defaultTx: ThemeFunction<Record<string, any>>resourceExtensions={[...resourceExtensions?: Theme.Resource[] | undefineduiTranslations, ...const uiTranslations: [{readonly 'en-US': {readonly "@dxos/react-ui": {readonly "empty.label": "No items";readonly "error-fallback.title.label": "Runtime Error";readonly "error-fallback.stack.label": "Stack";readonly "error-fallback.data.label": "Data";readonly "steps.step.label": "Step {{index}}";readonly "remove.label": "Delete";readonly "toolbar-menu.label": "Action menu";readonly "toolbar-drag-handle.label": "Drag to rearrange";readonly "toolbar-close.label": "Close";readonly "toolbar-delete.label": "Delete";readonly "floating-panel.minimize.label": "Minimize";readonly "floating-panel.maximize.label": "Maximize";readonly "floating-panel.restore.label": "Restore";readonly "drawer.resize.label": "Resize drawer";readonly "system-button.star.label": "Star";readonly "system-button.unstar.label": "Unstar";readonly "system-button.bookmark.label": "Bookmark";readonly "system-button.unbookmark.label": "Remove bookmark";readonly "system-button.check.label": "Check";readonly "system-button.uncheck.label": "Uncheck";readonly "system-button.expand.label": "Expand";readonly "system-button.collapse.label": "Collapse";readonly "system-button.ai.label": "Run AI";readonly "system-button.add.label": "Add";readonly "system-button.delete.label": "Delete";readonly "system-button.remove.label": "Delete";readonly "system-button.edit.label": "Edit";readonly "system-button.close.label": "Close";readonly "system-button.open.label": "Open";readonly "system-button.save.label": "Save";readonly "system-button.cancel.label": "Cancel";readonly "system-button.upload.label": "Upload";readonly "system-button.download.label": "Download";readonly "system-button.clipboard.label": "Copy";readonly "system-button.copied.label": "Copied";readonly "carousel-viewport.label": "Carousel";readonly "carousel-prev.label": "Previous slide";readonly "carousel-next.label": "Next slide";readonly "carousel-indicators.label": "Carousel slides";readonly "carousel-go-to.label": "Go to slide {{index}}";readonly "date-picker.placeholder.single.label": "Pick a date";readonly "date-picker.placeholder.range.label": "Pick a date range";readonly "date-picker.placeholder.multiple.label": "Pick dates";readonly "date-picker.clear.label": "Clear";readonly "calendar.nav.previous.label": "Previous month";readonly "calendar.nav.next.label": "Next month";readonly "calendar.nav.previous-year.label": "Previous year";readonly "calendar.nav.next-year.label": "Next year";readonly "calendar.nav.previous-decade.label": "Previous decade";readonly "calendar.nav.next-decade.label": "Next decade";readonly "calendar.footer.today.label": "Today";readonly "trigger-button.label": "Open";readonly "number-input.increment.label": "Increment";readonly "number-input.decrement.label": "Decrement";readonly "number-input.slider.label": "Adjust";readonly "password-input.show.label": "Show password";readonly "password-input.hide.label": "Hide password";readonly "tag.delete.label": "Remove {{label}}";readonly "combobox.search.label": "Search";readonly "combobox.empty.label": "No results";readonly "combobox.loading.label": "Loading\u2026";readonly "combobox.create.label": "Create \u201C{{query}}\u201D";readonly "drag-handle.label": "Drag to rearrange";readonly "drag-handle.role.label": "drag handle";readonly "drag-handle.grabbed.message": "Grabbed. Press the arrow keys to move, Space to drop.";readonly "drag-handle.moved-up.message": "Moved up.";readonly "drag-handle.moved-down.message": "Moved down.";readonly "drag-handle.dropped.message": "Dropped.";};};}]formTranslations, ...const formTranslations: [{readonly 'en-US': {readonly "@dxos/react-ui-form": {readonly "ref-editor.placeholder": "Type '@' to add a reference, or enter a value";readonly "ref-editor-auto.placeholder": "Search by name, or enter a value";readonly "fields.label": "Fields";readonly "hidden-fields.label": "Hidden Fields";readonly "empty-readonly-ref-field.label": "(none)";readonly "field-property.label": "Property";readonly "field-property.placeholder": "Property name";readonly "field-format.label": "Type";readonly "field-path.label": "Field path";readonly "remove-item.button": "Delete item";readonly "add-item.button": "Add item";readonly "add-property-button.label": "Add property";readonly "boolean-input-true.value": "Yes";readonly "boolean-input-false.value": "No";readonly "indeterminate.placeholder": "Mixed";readonly "select-none.label": "None";readonly "show-field.label": "Show field";readonly "hide-field.label": "Hide field";readonly "delete-field.label": "Delete field";readonly "create-option.label": "Create";readonly "add-tag.label": "Add tag";readonly "add-tag-query.label": "Add tag \u201C{{text}}\u201D";readonly "ref-field-combobox-input.placeholder": "Search\u2026";readonly "ref-field.placeholder": "Select\u2026";readonly "ref-field.placeholder_one": "Select\u2026";readonly "ref-field.placeholder_other": "Select items\u2026";readonly "untitled.label": "Untitled";readonly "example.placeholder": "Example";readonly "select.placeholder": "Select\u2026";readonly "latitude.placeholder": "Latitude (e.g., 40.7128)";readonly "longitude.placeholder": "Longitude (e.g., -74.0060)";readonly "cancel-button.label": "Cancel";readonly "save-button.label": "Save";readonly "create-text.label": "Create text";readonly "format.boolean.label": "Boolean";readonly "format.currency.label": "Currency";readonly "format.date.label": "Date";readonly "format.date-time.label": "DateTime";readonly "format.did.label": "DID";readonly "format.duration.label": "Duration";readonly "format.dxn.label": "DXN";readonly "format.email.label": "Email";readonly "format.formula.label": "Formula";readonly "format.hostname.label": "Hostname";readonly "format.integer.label": "Integer";readonly "format.json.label": "JSON";readonly "format.lnglat.label": "Geopoint";readonly "format.markdown.label": "Markdown";readonly "format.password.label": "Password";readonly "format.percent.label": "Percent";readonly "format.ref.label": "Reference";readonly "format.regex.label": "RegExp";readonly "format.string.label": "String";readonly "format.single-select.label": "Select";readonly "format.multi-select.label": "Multi-select";readonly "format.text.label": "Long text";readonly "format.time.label": "Time";readonly "format.timestamp.label": "Timestamp";readonly "format.user.label": "User";readonly "format.number.label": "Number";readonly "format.uri.label": "URI";readonly "format.url.label": "URL";readonly "format.uuid.label": "UUID";readonly "latitude.label": "Latitude";readonly "longitude.label": "Longitude";readonly "select-option.label": "Label";readonly "select-option-label.placeholder": "Option label";readonly "select-option-color.label": "Color";readonly "select-option-delete.button": "Delete";readonly "select-option-add.button": "Add option";readonly "system-schema.title": "System type";readonly "system-schema.description": "System type: cannot add or remove fields.";readonly "remove.button": "Delete";};};}]translations]}>const translations: [{readonly 'en-US': {readonly "com.example.contacts": {readonly 'title.label': "Contacts";readonly 'count.label_one': "{{count}} contact";readonly 'count.label_other': "{{count}} contacts";readonly 'add.label': "Add contact";readonly 'edit.label': "Edit contact";readonly 'delete.label': "Delete contact";readonly 'empty.message': "Choose a contact";readonly 'new-contact.name': "New contact";readonly 'role.viewer': "Can read the contact book";readonly 'role.editor': "Can change contacts";readonly 'role.admin': "Can change contacts and who has access";};};}]<Contacts />const Contacts: () => React.JSX.Element | nullShows the screen once the space is there.
</Theme.import ThemeProvider>const Provider: ({ children, fallback, resourceExtensions, appNs, tx, themeMode, platform, }: Theme.ProviderProps) => React.JSX.Elementexport Provider</ClientProvider>,const ClientProvider: React.ForwardRefExoticComponent<Omit<ClientOptions, "config" | "services"> & Pick<ClientContextProps, "status"> & {client?: Client | Provider<Promise<Client>>;config?: Config | Provider<Promise<Config>>;services?: ClientServicesProvider | ((config?: Config) => MaybePromise<ClientServicesProvider>);fallback?: React.FunctionComponent<Partial<ClientContextProps>>;suspend?: boolean;noBanner?: boolean;onInitialized?: (client: Client) => MaybePromise<void>;} & {...;} & React.RefAttributes<...>>Root component that provides the DXOS client instance to child components. To be used with the
useClienthook.);Then point
index.htmlatsrc/echo/main.tsx.
Try it
Section titled “Try it”Run the app and add a few contacts. Reload, and they are still there.
To see the contacts sync, a second browser profile has to join the space, and this screen has no way to invite one. ECHO’s Sharing a space adds an invitation. With that in place, edits in one window appear in the other.
What you can do now
Section titled “What you can do now”You can build a screen with TILE whose data lives in ECHO. From here:
- The API section covers each component package, such as Listbox, Form, ActionToolbar and Editor.
- TILE in a PLEX plugin shows how this screen would become a plugin for Composer, DXOS’s local-first workspace.