Todae

Todae

Using Todae with A2UI

A2UI v1.0 is a message format. An agent sends JSON that describes a surface, and the app renders it. Todae does not parse those messages and does not depend on @a2ui/react or @a2ui/web_core. The app owns the catalog. Todae supplies the widgets.

On this page

Install @a2ui/react and @a2ui/web_core at 0.16 in the app. The names below are the exports in 0.16.1. v0.8 is deprecated. This page is v1.0 only.

The app owns the catalog

The app advertises catalog ids. catalogId is an identifier, not a URL the agent fetches. For the official basic catalog the id is https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json. The agent picks one advertised id on createSurface.

Keep that id when your widgets still accept the basic components and their props. Take a new id only when the contract changes, such as a new component or a new prop. v1.0 has no theme on the wire. Wrap the tree in ThemeProvider and DensityProvider, and style in the app.

Send the same id in each of these places.

  • An A2A message sets message.metadata.a2uiRendererCapabilities["1.0"].supportedCatalogIds.
  • A stateful MCP client sets initialize params.capabilities.a2ui.rendererCapabilities.
  • A stateless MCP tools/call sets params._meta.a2ui.rendererCapabilities.

MessageProcessor.getRendererCapabilities({ versions: ['1.0'] }) returns the version-keyed object those three fields hold.

Map the basic catalog

weight is a number, the flex grow of a direct child of Row or Column. It is not font weight. Stack has no weight prop, so set flexGrow on the element when weight is a number. spaceAround and spaceEvenly have no Stack justify. Those two, and stretch on the main axis, pack at the start.

A2UITodaeProps and gaps
TextText.Roottext is the children. variant is body (default) or caption. Caption has no size, so use tone="muted". Text has no markdown. A markdown string renders as characters.
ImagenoneUse img. url is src. description is alt. fit is object-fit, and scaleDown is scale-down. variant (icon, avatar, smallFeature, mediumFeature, largeFeature, header) is the app's CSS.
IconnoneTodae ships no icon set. Map name to your icons. The example uses lucide-react. name may instead be an object with svgPath. GlyphsProvider swaps Todae's own glyphs, not this catalog.
VideononeUse video. url is src. posterUrl is poster.
AudioPlayernoneUse audio with controls. url is src. Put description in a Text.Root beside it.
RowStack.Rootdirection="row". children is a list of child ids. justify maps start, center, end, and spaceBetween to between. align maps start, center, end, stretch.
ColumnStack.RootSame as Row with direction="column". The default direction of Stack is already column.
ListStack.Rootas="ul", and wrap each child in li. direction vertical is column and horizontal is row. align maps as on Row. There is no List export.
CardCard.RootOne child. Card takes any number of children, so render that one child inside it.
TabsTabs.Roottabs is title plus child. Render Tabs.List, Tabs.Tab, and Tabs.Panel, paired by value. The catalog has no selected tab. The app holds it, starting at the first tab.
ModalDialog.Roottrigger and content are child ids. Dialog has no trigger part. Render the trigger and set open from a click on a wrapper around it. Put content in Dialog.Body, and include Dialog.Close.
DividerSeparator.Rootaxis is horizontal (default) or vertical. Separator is an hr and has no orientation. A vertical rule is the app's border.
ButtonButton.Rootchild is the label component, rendered inside the button. action resolves to a function. Call it from onClick. variant primary is primary, borderless is ghost, and default is secondary.
TextFieldFieldlabel is Label.Root, which requires htmlFor. value is a string, and the binder adds setValue. shortText is Field.TextInput. obscured is type="password". longText is Field.Textarea. number is still a string on the wire. Parse it for Field.NumberInput and write the string back. checks set isValid. Pass invalid when that is false.
CheckBoxCheckbox.Rootlabel is the children. value is boolean. Bind checked and onCheckedChange to setValue.
ChoicePickerRadioGroup, Checkbox, ToggleGroup, or the combobox recipeoptions are label and value. value is a string list. mutuallyExclusive (default) is RadioGroup, whose value is one string or null. multipleSelection is a Checkbox.Root per option. displayStyle chips is ToggleGroup (single or multiple). filterable uses the combobox recipe (useCombobox and OptionList). There is no Combobox export.
SliderSlider.Rootvalue is a number, with setValue. min defaults to 0. max is required. steps is a count of divisions, so the native step is (max - min) / steps. Omit steps and Todae's step stays 1. One thumb takes onChange.
DateTimeInputField.DateInput, Field.TimeInput, or Field.DateTimeInputvalue is an ISO string. Todae wants Temporal.PlainDate, PlainTime, or PlainDateTime, and ships no polyfill. enableDate alone is the date input. enableTime alone is the time input. Both is the date-time input. Both default to false, and then there is nothing to render. A date-time string with a UTC offset is not a PlainDateTime.

A child prop is a string id, or an object with id and basePath. buildChild(id, basePath) renders it. createComponentImplementation copies name and schema off the API object. Pass TextApi, not the web component A2uiText. Spreading A2uiText would keep its custom element.

Register implementations

basicCatalog.copyWith({ components }) keeps the basic catalog id, the protocol version 1.0, and the catalog functions such as formatString and required. The components array replaces the whole list. Include every basic component you still accept. new Catalog(basicCatalog.id, '1.0', implementations, [...basicCatalog.functions.values()]) is the same catalog written out.

'use client';

import { useEffect, useState, type ReactNode } from 'react';
import { A2uiSurface, createComponentImplementation } from '@a2ui/react';
import { MessageProcessor } from '@a2ui/web_core';
import {
  AudioPlayerApi, ButtonApi, CardApi, CheckBoxApi, ChoicePickerApi, ColumnApi, DateTimeInputApi,
  DividerApi, IconApi, ImageApi, ListApi, ModalApi, RowApi, SliderApi, TabsApi, TextApi, TextFieldApi,
  VideoApi, basicCatalog,
} from '@a2ui/web_core/catalogs/basic/v1';
import {
  Button, Card, Checkbox, Dialog, Field, Label, OptionList, Popover, RadioGroup, Separator, Slider,
  Stack, Tabs, Text, ToggleGroup, useCombobox,
} from '@tounsoo/todae';
import { Calendar, Check, CircleUser, Plus, Search, X, type LucideIcon } from 'lucide-react';

type Build = (id: string, basePath?: string) => ReactNode;
type Child = string | { id: string; basePath?: string };

function renderChild(child: Child | undefined, build: Build) {

a2aMetadata is message.metadata on an A2A message. mcpInitializeCapabilities is params.capabilities on MCP initialize. mcpCallMeta is params._meta on a stateless tools/call. catalog.id is the basic catalog id.

TextField sets aria-label from label. A visible label is Label.Root with htmlFor set to the field id. number parses the wire string for Field.NumberInput and writes a string back. A filterable ChoicePicker is useCombobox with Field, OptionList, and Popover, the combobox recipe. There is no Combobox export. Unmapped icon names render nothing. A vertical Divider renders the same Separator.Root. spaceAround and spaceEvenly pack at the start.

A catalog of your own

Add a component with createComponentImplementation and a Zod schema. CommonSchemas from @a2ui/web_core/v1_0 supplies DynamicString and Action. Give the catalog a new id with derive. A string in components keeps that entry. An object adds or replaces one. toJson() is the catalog document. Publish it at the new id, or pass it as an inline catalog, and advertise that id. createSurface.catalogId must be the new id.

import { z } from 'zod';
import { CommonSchemas } from '@a2ui/web_core/v1_0';

const ProfileApi = {
  name: 'Profile',
  schema: z.object({ username: CommonSchemas.DynamicString, onEdit: CommonSchemas.Action }),
};

const profile = createComponentImplementation(ProfileApi, ({ props }) => (
  <Button.Root variant="secondary" onClick={() => props.onEdit()}>{props.username}</Button.Root>
));

const profileCatalog = catalog.derive({
  catalogId: 'https://example.com/a2ui/profile.json',
  components: [...catalog.components.keys(), profile],
});

Change a prop, and change the id in the same edit. The Zod schema, toJson(), and supportedCatalogIds have to name that id together.