Skip to content

The web toolkit

The pieces web front ends are made of, laid out and themed without CSS: layout, forms, confirmations, records in dialogs and refused fields, table exports and totals, dates (ranges to the second, typed day-times read back), bars, toasts, shortcuts, printing, PDF logos, Code 39, Code 128 and EAN barcodes, a route's own page and a sign-in (Screen), and every token a theme sets.

On this page 70

copilotz/web exports the pieces every web front end is made of: buttons and fields, tables, date pickers, dialogs, bars, toasts, and the layout pieces that place them. A screen composes them and writes no CSS. Its look is the app's theme: the theme's tokens set the colours, fonts and radii, and each piece's own tokens set its sizes and surfaces. className stays on most pieces as an escape hatch for what no token reaches. A printed document (a receipt, an invoice) is the one place for an app's own CSS: its print layout.

TSX
import { Button, DataTable, Field, Input, Page, Stack, Toolbar } from "copilotz/web";

Theming without CSS

A theme is a theme resource (see The web's look and words). It sets three kinds of tokens:

  • The theme's own in light and dark: primary, background, border, success… (shadcn's names, and the toolkit's), with radius and font. Every piece reads them.
  • The same on both screens in tokens: sizes, paddings, radii, weights, and the spacing scale. They're written on :root before light's, so a colour set in light wins on a clash.
  • Each piece's own (button-height, table-stripe, dialog-head-background…), in tokens when it's a size and in light/dark when it's a colour. Every one has a default, which is Copilotz's look, so a theme sets only what it changes. The tables below list them all.
TypeScript
definePlugin({
  name: "brand",
  resources: {
    theme: {
      radius: "6px",
      tokens: { "button-height": "34px", "input-height": "34px", "space-md": "10px" },
      light: {
        primary: "#0f766e",
        "table-stripe": "color-mix(in oklab, var(--muted) 50%, transparent)",
      },
      dark: { primary: "#2dd4bf", "primary-foreground": "#042f2e" },
    },
  },
});

A token is a CSS variable (var(--button-height)), so a value may use the theme's own (var(--muted)). A piece's token never changes a theme token's meaning: primary is still the brand everywhere.

Laying out a screen

Page is a View's frame: its title, actions, description, and the width it centres at (align="center" centres the title and description too). Inside it, these place things without CSS, and hidden hides any of them. Gaps are steps of one spacing scale, xs (4px), sm (8px), md (12px), lg (16px), xl (24px), 2xl (32px), each a token (space-md).

PieceWhat it is
StackThings one after another, down (direction="column", the default) or along (row): gap, align, justify, wrap; as makes it a form, a section, a list.
Spacer, DividerThe room left in a row, pushing what follows to its end; a line between parts.
Grid, GridItemColumns: columns={3}, a template ("1fr 2fr"), or as many as fit (min="220px"). One column when the grid itself is narrower than collapse (sm, 480px, by default). GridItem span={2} spans.
ToolbarA row of controls over what they act on: start (the screen's actions), grow (a field taking the room left), end (filters, dates); it wraps.
SplitTwo columns: the screen's main one, and an aside that stays in view (sticky), at the end or start, sm/md/lg wide; they stack when narrow.
CardA surface; with title (and icon, action), a heading over its body.
ListGroupRows one under another: links, actions, or text, with a description, an icon and an end; the active one marked. flush inside a card.
ScreenA frame that fills the window: what it holds centred in the window's height at screen-width, and a footer kept at the window's foot. For a sign-in or a route's own page.
Text, HeadingWords in the theme's type: Text with a size, tone, weight, align, mono, truncate; Heading h1 to h4.

A list screen:

TSX
<Page
  title="Items"
  width="lg"
  actions={<Button variant="primary" icon="plus" href="/items/new">New item</Button>}
>
  <Stack gap="lg">
    <Toolbar end={<DateRangePicker value={range} onChange={setRange} today={today} presets />} />
    <DataTable columns={columns} rows={rows} rowKey={(r) => r.id} exportName="items" />
  </Stack>
</Page>;

A visit being booked, its services beside its total:

TSX
<Split aside={<Card title="Total"><Stack>…<Button variant="primary" block>Book the visit</Button></Stack></Card>} sticky label="Total">
  <Stack>
    <Autocomplete … />
    <DataTable columns={chosen} rows={services} rowKey={(s) => s.id} toolbar={false} pagination={false} />
  </Stack>
</Split>

Reports, as a card of links:

TSX
<Grid min="280px">
  <Card title="Summary reports" icon="chart" padding="none">
    <ListGroup
      flush
      items={[{ href: "/reports/visits", label: "Visits", description: "By day" }]}
    />
  </Card>
</Grid>;

A page that is the whole window. Page frames a View under its title, at a width. A page with no title over it, a sign-in, a landing, an error, or a route's own page, is a Screen: it fills the window (at least its height), centres what it holds both ways at screen-width (420px), and keeps its footer at the window's foot. Taller than the window, it grows, and the footer follows it.

TSX
<Screen
  footer={
    <Text size="sm" tone="muted">
      Acme Salon · <a href="/help">Help</a>
    </Text>
  }
>
  <Card title="Sign in">
    <Stack as="form" method="post" action="/sign-in">
      <Field label="Email" htmlFor="email" required>
        <Input id="email" name="email" type="email" autoComplete="username" />
      </Field>
      <Field label="Password" htmlFor="password" required>
        <Input id="password" name="password" type="password" autoComplete="current-password" />
      </Field>
      <Button type="submit" variant="primary" block>Sign in</Button>
    </Stack>
  </Card>
</Screen>;

Forms

  • Field labels a control: a hint under it, or the error in its place. required adds a mark that screen readers say as "required". Its children are a function of the control's props, or the control itself with htmlFor. layout="row" puts the label in a column beside the control, and it stacks again under 560px. labelWidth (30% by default) and controlWidth (the rest by default) are each a share of the whole row, as a grid's columns are: "33.33%" and "66.67%" fill the row, "25%" and "50%" leave its last quarter empty, and a length ("320px") is the most the control takes. The tokens field-row-label-width and field-row-control-width set them for every field. Before rc.54, controlWidth was a share of the control's own column: an older "50%" beside a 30% label is now about "35%".
  • Input: sm, md, lg; an icon inside the box; end for buttons that act on it; addon and addonEnd, segments outside the box and joined to it: words or an icon get a tinted face, and a button or a Switch there is the segment itself.
  • Select (with addon and addonEnd, as Input's), Textarea, Checkbox, and Radio (radios sharing a name are one choice).
  • Switch: a setting that takes effect as it's flipped (role="switch"), with words on and off if wanted; joined="end" in an addonEnd.
  • TagsInput: values as tags. Enter or a comma adds what's typed, a paste of "a, b, c" adds three, Backspace in the empty field removes the last; no duplicates; name sends them as one comma-separated value.
  • Picker and MultiPicker: a choice the app draws, not the browser: a button showing the choice, opening its options. search puts a box over a long list. MultiPicker ticks several and says "None chosen", the one chosen, or "{count} chosen". name sends the choice with a form. Both take addon and addonEnd.
  • FileInput: the browser's own file field (name, accept, multiple, required, so a form sends the files), drawn as a toolkit field: a button ("Choose a file", then "Change"), what's chosen, and Remove. Files dropped on it are chosen too, only those accept takes. onChange(files) hears each change. chooseLabel, changeLabel and removeLabel are one field's own words ("Select image"); current names a file already stored (its name or address), shown until another is chosen, and its Remove calls onRemove.
  • RowsEditor: a list of records edited as one form, one row of fields each (render(row, index, set)), numbered, with a button to add a row after each and to remove it, "Add a row" at the end, min and max, and an error under a row. Adding focuses the new row's first field. add={false} leaves the add buttons out; removeIcon and removeLabel set the remove button.
  • Button: primary, secondary, outline (the default), ghost, destructive, success, info, warning, link; xs, sm, md, lg; block fills its box.
TSX
<Stack as="form" onSubmit={save}>
  <Field layout="row" label="Email" htmlFor="email" required error={errors.email}>
    <Input id="email" type="email" icon="mail" />
  </Field>
  <Field layout="row" label="Postcode" htmlFor="postcode" controlWidth="35%">
    <Input id="postcode" autoComplete="postal-code" />
  </Field>
  <Field layout="row" label="Discount" htmlFor="discount">
    <Input
      id="discount"
      inputMode="decimal"
      addonEnd={
        <Switch
          joined="end"
          label="Discount type"
          checked={fixed}
          onChange={setFixed}
          on="
quot;
off="%" />
} /> </Field>
<Field layout="row" label="Customer" htmlFor="customer"> <Picker id="customer" label="Customer" search value={customer} options={customers} onChange={setCustomer} /> </Field> <Stack direction="row" justify="end"> <Button type="submit" variant="primary">Save</Button> </Stack> </Stack>;
TSX
<RowsEditor
  label="Rooms"
  rows={codes}
  onChange={setCodes}
  make={() => ({ code: "", name: "" })}
  error={(row) => (row.code ? undefined : "Give the code.")}
  render={(row, _i, set) => (
    <Grid columns="1fr 2fr" collapse={false}>
      <Input
        aria-label="Code"
        value={row.code}
        onChange={(e) => set({ ...row, code: e.target.value })}
      />
      <Input
        aria-label="Name"
        value={row.name}
        onChange={(e) => set({ ...row, name: e.target.value })}
      />
    </Grid>
  )}
/>;

A form with parts. Form is a <form> whose parts take part in its save: each joins with useFormSubmit(handler), another plugin's View shown inside it too (a shown View is in the form's React tree). On submit, each part's handler runs in the order they joined: values it returns are handed to the form's onSubmit(values, form); nothing means it saved its own part; false stops the save (the part says why); a throw stops it, and the form says the failure's words at its top. useFormState() tells buttons it's submitting; outside a Form, useFormSubmit says inForm: false, so a part can show its own Submit. Handing values up and saving them in one Action keeps the save one transaction.

TSX
<Form
  onSubmit={(values, form) =>
    ctx.call("bookings.settings.save", { on: new FormData(form).has("on"), hours: values.hours })}
>
  <Checkbox name="on" label="Take bookings online" />
  {ctx.show("panel:opening_hours", {})}
  <Button type="submit" variant="primary">Save</Button>
</Form>;
// In the panel's View:
const { inForm } = useFormSubmit(() => (valid(rows) ? { hours: rows } : false));

Dialogs: Dialog is the browser's modal <dialog>. placement="top" opens it near the top instead of centred, and focus="dialog" gives the focus to the dialog itself rather than its first field (Tab then goes to it). size is sm, md, lg or auto. busy (a save it started is under way) keeps it open: Escape, a press on the backdrop and its × wait, and it says so (aria-busy). role="alertdialog" is for one that interrupts to ask, and aria-describedby names what describes it when that isn't its description. isolated makes its close and Escape its own: React passes a dialog's close and cancel up through the components, so without it a dialog shown inside another (a confirmation over a form) closing closes the outer one too. ConfirmDialog, useConfirm's questions and RecordDialog are isolated always: dismissing one never closes the Dialog or Drawer it's shown in.

Confirming an action

A delete, or anything that can't be undone, asks first. useConfirm() asks from a handler: draw its dialog once in the component, then await confirm({ … }). It's true once confirmed, and false when cancelled.

TSX
import { IconButton, useConfirm } from "copilotz/web";

/** A customer's Delete, in their row: asks, then deletes. */
export function DeleteCustomer({ customer, remove }: {
  customer: { _id: string; name: string };
  remove(): Promise<unknown>;
}) {
  const [dialog, confirm] = useConfirm();
  return (
    <>
      <IconButton
        icon="trash"
        label={`Delete ${customer.name}`}
        size="sm"
        onClick={() =>
          confirm({
            title: `Delete ${customer.name}?`,
            message: "Their visits stay, under their name. This can't be undone.",
            danger: true,
            toast: "Customer deleted.",
            onConfirm: remove,
          })}
      />
      {dialog}
    </>
  );
}
  • onConfirm runs once it's confirmed, and may be async. While it runs, the confirm button is busy, Cancel waits, and Escape and the backdrop do nothing. A throw shows its words in the dialog (toolkit.notDone, "It wasn't done. Try again.", when it has none), which stays open to try again or cancel. Done, the dialog says toast and closes. Without onConfirm, confirming just closes it, and the caller acts on true.
  • danger makes the button destructive and its words "Delete" (toolkit.delete; otherwise "Confirm", toolkit.confirm), and gives Cancel the focus, so Enter never deletes. Without it, Confirm has the focus. confirmLabel and cancelLabel change the words; message describes the question; children go under it (what's affected).
  • The questions belong to the component. They show one at a time, in order. When the component goes (its row deleted, the screen left) or stops drawing {dialog}, a question still waiting is answered false and never shows again. One whose onConfirm runs is answered by how it ends, and says so with a toast: toast when it's done, its words when it failed. Asking with no {dialog} ever drawn rejects, so the mistake shows. confirm is the same function on every render.

ConfirmDialog is the same question as a component: a dialog View at an address (/customers/12/delete), or one the screen's state opens. It's open while open (true by default); onConfirm is what confirming does, and onClose says it's done (cancelled, or confirmed and done), once. Closing it yourself (open={false}, or not drawing it) calls nothing. One element is one question: give it the key of what it asks about, so that when the address moves to another record the question is a new one. An operation whose question has gone (closed, reopened, or replaced by a new key) closes nothing, and its outcome is a toast.

A question ends once, cancelled or done, and until its owner closes it, it takes no more actions. What it does is what it shows: its actions use the props it was last drawn with on the screen, never those of a render React didn't commit (a transition that suspended).

TSX
<ConfirmDialog
  key={customer._id}
  title={`Delete ${customer.name}?`}
  message="Their visits stay, under their name."
  danger
  toast="Customer deleted."
  onConfirm={() => customers.deleteOne({ _id: customer._id })}
  onClose={() => go(back)}
/>;

Both are an alertdialog, named by the title and described by the message, and give the focus back to what opened them.

A record in a dialog

RecordDialog adds a record, or edits one: a Dialog holding a Form, with Cancel and Save. Its children are a function of form, whose binders tie each control to a field of the record. It keeps a draft of what was edited, over the record as the View reads it, so a field nobody touched always shows its newest value. Save gives onSave a change of only what changed.

TSX
import { DatePicker, Field, Input, RecordDialog } from "copilotz/web";

<RecordDialog<Customer>
  title={customer ? customer.name : "New customer"}
  record={customer}
  defaults={{ since: today }}
  errors={{ name: "Give the customer's name.", email: "That email address isn't complete." }}
  toast="Customer saved."
  onSave={(change) =>
    change.kind === "create"
      ? customers.insertOne(change.values)
      : customers.updateOne({ _id: change._id }, change.update)}
  onClose={close}
>
  {(form) => (
    <>
      <Field layout="row" label="Name" required error={form.error("name")}>
        {(control) => <Input {...control} {...form.text("name")} required />}
      </Field>
      <Field layout="row" label="Email" error={form.error("email")}>
        {(control) => <Input {...control} {...form.text("email")} type="email" />}
      </Field>
      <Field layout="row" label="Visits a year" error={form.error("visits")}>
        {(control) => <Input {...control} {...form.number("visits")} min={0} />}
      </Field>
      <Field layout="row" label="Customer since" htmlFor="since" error={form.error("since")}>
        <DatePicker id="since" {...form.value("since")} today={today} format={dayFormat} />
      </Field>
    </>
  )}
</RecordDialog>;
  • Binders, by field name or dot path (address.city), each spread on its control: form.text(name) for an Input, a Textarea or a Select; form.number(name) for a number Input (type="number", any step: its text while typed, a number once saved); form.checked(name) for a Checkbox or a Switch; form.radio(name, option) for each Radio; form.value(name) for a control that gives its value (Picker, DatePicker, DateTimePicker); form.list(name) for several values (TagsInput, MultiPicker). A control of the app's own uses form.get(name) and form.set(name, value). form.record is the record as the form shows it, and form.saving says a save is under way. Bind each field once; _id isn't a field.
  • A new record (no record): onSave gets { kind: "create", values }, the defaults with the edits, for insertOne(change.values). TypeScript calls it the record's type, but the browser doesn't check that: the collection's schema does, on insert.
  • A stored record: onSave gets { kind: "update", _id, set, unset, update, record }, only what changed:
  • a field nobody touched is never in it, nor a field with no control, so a newer value someone else saved stays;
  • an edit back to the stored value isn't either;
  • a field given a value is in set;
  • a text, number or choice emptied is a clear, in unset (clearing a field that holds nothing, null or "" changes nothing);
  • a list emptied is [], a value, in set unless the record holds [] already ([] over null is sent); a checkbox is true or false, and unchecked over nothing changes nothing;
  • update is the same as a MongoDB update ($set, $unset), for updateOne({ _id: change._id }, change.update). To keep null for a cleared field, set null for each name in unset. An Action takes set and unset as its input.
  • Nothing changed: onSave isn't called, and the dialog just closes.
  • Parts: a useFormSubmit part shown in the fields (another plugin's View) takes part in the save; what it hands up goes over the edits, compared with the record as an edit is (a part handing back the stored value writes nothing). The values are read when the save starts, after the parts, so what was typed while a part uploaded is saved. In a dialog View, call ctx.show in the View's body and put what it gives in the function.
  • While it saves, Save is busy, Cancel waits, and Escape and the backdrop do nothing; the fields are left as they are. Done, it says toast and closes (onClose, once). Cancel, Escape, the backdrop and × close it while nothing runs; closing it yourself (open={false}, or not drawing it) calls nothing. A session ends once and tells onClose once: it then takes no more saves. Its actions use the props it was last drawn with on the screen, never a render React didn't commit.
  • Each record is a session of its own (its _id, or a new one), and so is each time it opens: a draft or a refusal never shows on another record. A save runs to its end in the session it started in, with that record and its handlers. If the dialog moved to another record, closed or went meanwhile, the save still happens, calls no onClose and shows nothing: a toast says how it ended.
  • saveLabel, cancelLabel, description, size, placement (top by default) and id (the form's) are as their names say. Focus goes to the first field, and back to what opened it.

Known limits

The confirmations and the record dialog keep their guarantees on the common paths. These are the rarer ones they leave to the app:

  • What's typed while the save runs isn't in it; on success the dialog closes.
  • A part's value wins over an edit of the same field, even one typed while the part runs.
  • A field made invalid while a part runs isn't checked again; the schema refuses it.
  • A path through a list or a map that isn't there yet (lines.0.qty) makes an object: give it a value in defaults or the record, or set it whole with form.set.
  • Don't put a RecordDialog inside a form, or a form in its fields: a submit goes to every form around it.
  • Questions show one at a time: don't await another confirm() inside onConfirm.
  • Draw useConfirm's {dialog} once.
  • If a browser closes a busy confirmation anyway, its answer comes when the operation ends. If it closes a dialog just as its operation ends, the outcome may show in the closed dialog.
  • A ConfirmDialog given a new key while open gives the focus back to the page, not to the first opener.
  • An app's own Dialog closing still closes an app's own dialog or Drawer around it, as in rc.64, unless the outer one is an isolated Dialog.

Showing a refused field

A save the schema refuses names the field in detail.field (price, lines.0.qty), and an Action's failure can too (Object.assign(failure("invalid", "Give the name.", { public: true }), { detail: { field: "name" } })). Its words are for developers, so a form says each field's refusal its own way.

In a RecordDialog, give each Field its error={form.error(name)}, and errors the words by field. A refusal shows under the field that asks for it, or under a field that holds it (lines for lines.0.qty), in errors' words for it, else its own, and the focus goes to its control. A refusal no field asks for, or of no field, shows at the form's top. It goes when a new save starts, when its field is edited, and with the session.

With a plain Form, catch it in onSubmit: refusedField(error) reads the field, and anything else thrown again shows at the form's top.

TSX
const [refused, setRefused] = useState<{ field: string; words: string }>();
const errorOf = (field: string) => (refused?.field === field ? refused.words : undefined);

<Form
  onSubmit={async (_values, form) => {
    setRefused(undefined);
    try {
      await save(new FormData(form));
    } catch (error) {
      const field = refusedField(error);
      if (!field) throw error;
      setRefused({ field, words: SAYS[field] ?? (error as Error).message });
    }
  }}
>
  <Field label="Price" error={errorOf("price")}>
    {(control) => <Input {...control} name="price" inputMode="decimal" />}
  </Field>
</Form>;

Tables and their files

DataTable lists rows: a toolbar (the screen's actions at its start, then a search box, a column chooser and an export menu), headers that sort, a checkbox per row when there are actions, and pages under it. Columns are data:

TSX
const columns: Column<Item>[] = [
  { key: "id", title: "ID", numeric: true, width: "80px" },
  { key: "name", title: "Name" },
  { key: "price", title: "Price", align: "right", text: (i) => money(i.price) },
  { key: "edit", title: "", label: "Edit", render: (i) => <Button size="xs" href={`/items/${i.id}`}>Edit</Button> },
];
<DataTable columns={columns} rows={items} rowKey={(i) => i.id} exportName="items"
  actions={(ticked, clear) => <Button size="sm" icon="trash" disabled={!ticked.length} onClick={…}>Delete</Button>} />
  • A column titled "" holds links or buttons: it isn't sorted, searched, chosen or exported; its label names it for screen readers. text is what search, sorting and the files use; numeric sorts by number; hidden starts it hidden in the chooser.
  • Search finds every word typed in any titled column, whatever its case and accents ("zoe muller" finds "Zoë Müller"), 500 ms after the last key.
  • A click on a row ticks it (not on a link, button or field in it); the header's box ticks the page. actions(ticked, clear) gets the ticked rows' keys.
  • detail(row) opens a row under each, by a button with aria-expanded; detailOpen opens them all (true, with no button) or those a function picks.
  • Fields in cells fill their column and shrink with it. layout="fixed" keeps the columns at their widths.
  • search, chooseColumns, exports, toolbar and pagination set to false take each away; pageSizes sets the sizes (10, 25, 50, 100 by default).

Two modes. By default the table has every row, and searches, sorts and pages them itself. With a total, it shows the page it's given, and its state ({ search, sort, order, offset, limit }) is the View's to read its query with. tableAddress(where, 25) keeps that state in the page's address, so Back goes back a page:

TSX
const page = ctx.db.collection("item").query<{ rows: Item[]; total: number }>(
  "page",
  tableState(where, 25),
);
<DataTable
  {...tableAddress(where, 25)}
  total={page.value?.total ?? 0}
  rows={page.value?.rows ?? []}
  loading={page.status === "loading"}
  columns={columns}
  rowKey={(i) => i.id}
/>;

Fields in cells. A column's render may return fields: a click in a toolkit field, a link or a button is that control's, never a tick of the row, and the table handles no key of its own. Keep the edits per row and send a row with its Update button, or Enter in one of its fields; turn sorting off on the columns being edited (sortable: false), or rows move while someone types.

TSX
const field = (key: "cost" | "quantity", label: string) => (l: Line) => (
  <Input
    size="sm"
    aria-label={label}
    inputMode="decimal"
    value={String(draft(l)[key])}
    onChange={(e) => edit(l, { [key]: e.target.value })}
    onKeyDown={(e) => e.key === "Enter" && save(l)}
  />
);
<DataTable
  rows={lines}
  rowKey={(l) => l.id}
  toolbar={false}
  pagination={false}
  columns={[
    { key: "name", title: "Item", sortable: false },
    { key: "cost", title: "Cost", sortable: false, width: "110px", render: field("cost", "Cost") },
    {
      key: "quantity",
      title: "Quantity",
      sortable: false,
      width: "90px",
      render: field("quantity", "Quantity"),
    },
    {
      key: "update",
      title: "",
      label: "Update",
      render: (l) => <Button size="xs" onClick={() => save(l)}>Update</Button>,
    },
  ]}
/>;

tableQuery(where, state, extra) writes the address's query, keeping its other keys, and tableView(rows, columns, state) searches, sorts and pages a list as the table does (for a query that pages one in memory). Pagination is the pages on their own.

Exporting a table

The export menu saves the visible columns of the rows shown (every matching row, with exportAll) as <exportName>.<ext>; exports picks the formats (["csv", "xlsx", "pdf"] by default):

FormatFile
csvevery cell quoted, with a BOM so Excel reads accents (bom: false leaves it out)
xlsxa real workbook: numbers stay numbers, 007 stays text, never a formula
pdfHelvetica, A4 landscape, the header on every page; title, orientation, headerColor, headerText, stripeColor, fontSize; text outside Windows-1252 prints as "?"
jsonrecords by header (json: "table": { header, data })
xml, txt, sql<tabledata>; CSV again; one INSERT per row
excelan HTML table as .xls (Excel warns as it opens it)

CSV, TXT and .xls guard against formula injection: a cell starting =, +, - or @ gets a leading ' (plain numbers such as -12.5 don't; formulas: true turns it off). exportFile(format, sheet, name, options) gives { file, type, content }, on a server too (an e-mailed PDF); download(…) saves it in the browser.

A format has a label, extension, MIME type and serializer. The serializer receives a sheet of visible headers, keys, rows and footer rows, followed by the base name and the export options. Return text or bytes. Use a built-in name such as csv to replace its format. Put formats on a table, or put <TableExportFormats value={formats}> around the screens in the app's shell. A table's definitions win. The default menu adds the supplied formats to CSV, Excel and PDF. An explicit exports list selects built-ins. Use exportChoices to order a menu that includes custom names. Unknown names are omitted, with one render warning per table for newly encountered names.

TSX
import { DataTable, type TableExportFormat } from "copilotz/web";

const products = [{ name: "Coffee", units: 12 }];
const columns = [{ key: "name", title: "Product" }, { key: "units", title: "Units" }];
const formats = {
  jsonl: {
    label: "JSON Lines",
    extension: "jsonl",
    type: "application/x-ndjson",
    serialize: ({ headers, rows, footerRows = [] }) =>
      [...rows, ...footerRows].map((row) =>
        JSON.stringify(Object.fromEntries(headers.map((h, i) => [h, row[i]])))
      ).join("\n"),
  },
} satisfies Record<string, TableExportFormat>;

<DataTable
  rows={products}
  columns={columns}
  rowKey={(p) => p.name}
  footerRows={[{ name: "Total", units: 12 }]}
  formats={formats}
  exportChoices={["csv", "json", "sql", "pdf", "jsonl"]}
  exportName="stock"
  tableExportOptions={{
    values: "raw",
    json: "records",
    tableName: "products",
    csv: { quote: "needed", delimiter: ";", lineEnding: "\r\n", finalNewline: true, header: true },
  }}
/>;
  • Values. Files use each column's text(row) by default. Give a rendered cell a text function for its words. values: "raw" reads the fields by column key and preserves scalar values for typed formats. Untitled button columns stay on screen.
  • Totals. Give footerRows as records keyed by column. The same totals appear under the table and in every built-in file, even when someone hides a column. The app supplies totals for the desired range. The older footer slot draws any extra markup on screen.
  • CSV and TXT. The defaults are quote: "always", a comma (use any single delimiter character except a quote or line break), lineEnding: "\n", a header and no final newline. With quote: "needed", a quote, delimiter or line break in a field makes it quoted. Set header: false to start with the first data row. Set bom: false on tableExportOptions for a file without the byte-order mark.
  • JSON and SQL. json: "records" gives objects by header. json: "table" gives { header, data } with cells keyed by position. Its default is text and values: "raw" preserves their scalar types. tableName sets the SQL table independently of the file name. SQL quotes null and booleans by default. Use values: "raw" for NULL, TRUE and FALSE.
  • In an Action. Use exportFile for a built-in format with string and number cells. For custom format names or raw cells use exportTableFile from copilotz/web/export. Give it a sheet with { headers, rows, footerRows }, in column order, or use tableSheet(chosenColumns, rows, totalsByKey, "raw") to make one. A server-paged table can export the rows it has. For the whole list, the Action reads the matching rows as its caller.

Use tableExportOptions for the full set of file settings. When supplied, this prop takes the place of exportOptions. With values: "raw", XLSX stores strings as text cells and finite numbers as numeric cells. A single empty field with minimal CSV quoting is written as "".

To save the same file from a browser button, import downloadTableFile from copilotz/web. This button downloads the displayed rows and the supplied total as a semicolon-delimited CSV.

TSX
import {
  Button,
  downloadTableFile,
  type ExportCell,
  type TableExportOptions,
  type TableExportSheet,
  tableSheet,
} from "copilotz/web";

const totals: Record<string, ExportCell>[] = [{ name: "Total", units: 12 }];
const stock: TableExportSheet = tableSheet(columns, products, totals, "raw");
const options: TableExportOptions = { csv: { delimiter: ";", quote: "needed" }, values: "raw" };
<Button onClick={() => downloadTableFile("csv", stock, "stock", options)}>Download stock</Button>;

A toolbar of your own

Give toolbarContent a button or filter to put it beside the built-in controls. Use actions for buttons that take selected rows. showSinglePageSize keeps the page-size menu visible when one size fits.

TSX
<DataTable
  rows={products}
  columns={columns}
  rowKey={(p) => p.name}
  toolbarContent={<Button href="/products/new">New product</Button>}
  pageSize={25}
  pageSizes={[25]}
  showSinglePageSize
/>;

Printing a table

Use exportTableFile("pdf", sheet, name, { pdf }) in an Action for an attachment, or pass the same layout to DataTable in tableExportOptions.pdf. Named paper ("a4" or "letter") defaults to landscape. A [width, height] pair uses points (72 per inch). The first page holds the logo, titleLines and subtitle. Every page repeats the column headings. Totals print in bold after the last row.

TypeScript
import {
  exportTableFile,
  type PdfImage,
  pdfImage,
  type TablePdfOptions,
} from "copilotz/web/export";

export async function invoicePdf(logoBytes: Uint8Array) {
  const logo: PdfImage = await pdfImage(logoBytes);
  const pdf: TablePdfOptions = {
    size: "letter",
    orientation: "portrait",
    titleLines: ["Invoice 1042", "Customer 27"],
    subtitle: "November orders",
    headerImage: { image: logo, width: 60, height: 60 * logo.height / logo.width },
    columns: { qty: { width: 16 }, amount: { width: 90, align: "right" } },
  };
  return exportTableFile(
    "pdf",
    {
      keys: ["qty", "amount"],
      headers: ["Qty", "Amount"],
      rows: [[1, "1234.56"]],
      footerRows: [["", "1234.56"]],
    },
    "invoice-1042",
    { pdf },
  );
}

Use column keys for widths and alignment. In the example, amount keeps its 90-point width whenever it is visible. A DataTable supplies the keys automatically. On a hand-built sheet, give keys in header order, or use the header text as the key when keys is omitted. Fixed widths use points. Other columns share the remaining width. Alignment is "left", "center" or "right".

A positional array applies to the columns as exported on each download. These are the visible titled columns in display order. Initially hidden columns, columns hidden later in the chooser and untitled action columns consume no slots. For example, with Warehouse hidden and Qty and Amount visible, columns: [{ width: 16 }, { width: 90, align: "right" }] gives Amount 90 points. If Qty is then hidden, Amount takes the first slot.

Dates

Days are YYYY-MM-DD strings, in the app's time zone: todayIn("America/New_York") is the app's today, which every picker takes as today (never the browser's clock when given). format is a pattern (dd/MM/yyyy, d MMM yyyy; yyyy yy MMMM MMM MM M dd d EEEE EEE, and 'quoted words') or a function of the day; by default, the page language's short date. Month and weekday names are the page language's.

  • DateRangePicker: a field showing the range; open, the presets beside two months (stacked on a phone), with the range's From and To over the months as typed fields. A preset applies at once; the first day clicked starts a range and the second ends it; Apply takes it, Cancel or Escape keep the value, and both stay in view when the panel scrolls. From and To are written and read in the field's format, and what's typed is read when it's done: on leaving the field, on Enter, or on Apply. Then a day moves the range and the months shown; nothing moves while it's being typed (typing 2 on the way to 20 in To doesn't move From to the 2nd). Anything else (not a day, or outside min and max) stays as typed, marked, and Apply is off until it's put right. A field left empty is its end again, and the text a field shows for its end always reads as that end. Give format as a pattern where people type: a function can't be read back, so typed text is then read as the page language's short date or as YYYY-MM-DD. A long range opens on its start's months. presets is a list, true for the standard ones, or false; min and max bound what can be picked; separator sits between the days. From and To are the words toolkit.rangeFrom and toolkit.rangeTo.
  • DateRangePicker with time: each end has hours and minutes too, and the ends are YYYY-MM-DD HH:mm; a preset is its whole days, 00:00 to 23:59. On one day, the end is never before the start. A stored time with seconds sorts after its minute ("… 23:59:30" > "… 23:59"), so compare one with an end to the minute: at.slice(0, 16) <= range.end, or take the ends to the second (below).
  • DateRangePicker with seconds: each end to the second, typed whole in From and To (below).
  • rangePresets(today, { keys, fiscalYearStart, min, max }) builds presets by key, in the order given: today, yesterday, todayLastYear, last7Days, last30Days, thisMonth, sameMonthToDateLastYear, sameMonthLastYear, lastMonth, thisYear, lastYear, thisFiscalYear, lastFiscalYear, allTime (with a min). Their labels are words (toolkit.thisMonth), so an app renames them with its words.
  • DatePicker: one day, one month; picking closes it.
  • DateTimePicker: a day and a time of it, in the app's clock time with no zone (as LiveClock writes it): YYYY-MM-DD HH:mm, or YYYY-MM-DD HH:mm:ss. Opened, the month and the time's fields, each typed or stepped with the arrows (the minutes by minuteStep); Apply takes both. A value's seconds are kept until its time is changed, so a form that saves a record's time unchanged keeps them; changing the hours or minutes drops them, unless seconds shows them in a field of their own (the value then always has them, :00 when it had none). A format shows them with ss (dd/MM/yyyy HH:mm:ss); the default one shows them when the value has them. min and max are days or day-times; with no value it opens at the app's now (timeZone). name sends the value with a form.
  • TimeFields: a time of day's fields alone, the pickers' own: hours, minutes, and seconds if wanted; its value is a Clock, { hour, minute, second? }.
  • Calendar: one month's grid, alone: arrows move a day, Page Up and Page Down a month (a year with Shift), Home and End the week's ends, Enter or Space pick; each day is named by its full date.
  • LiveClock: now, in a format and a timeZone, ticking each second (each minute when the format shows no seconds); nothing on the server.
  • Helpers: isDay and isDayTime; partsOfDayTime ({ day, hour, minute, second? }); addDays and addMonths; clampDayTime(value, min, max); nowIn(timeZone, step, at, seconds), now (or the Date at) as the app's day-time; formatDay and parseDay, a day written in a picker's format and read back; formatDayTime; formatPattern, which takes a time's letters too (HH, hh, mm, ss, a), and parsePattern, which reads a day; parseDayTime, patternProblem, dayTimePattern and dateOfDayTime, a typed day-time read back and the moment it names (below).
TSX
<DateRangePicker
  value={range}
  onChange={setRange}
  today={today}
  format="dd/MM/yyyy"
  presets={rangePresets(today, { fiscalYearStart: 4, min: "2010-01-01", max: today })}
  min="2010-01-01"
  max={today}
/>;
// Shifts, each end with its time: { start: "2026-11-02 08:00", end: "2026-11-08 17:30" }
<DateRangePicker value={shifts} onChange={setShifts} today={today} format="dd/MM/yyyy" time />;
// A stored time, "2026-11-16 14:30:05": saved unchanged, it keeps its seconds.
<DateTimePicker
  label="Received"
  value={received}
  onChange={setReceived}
  format="dd/MM/yyyy HH:mm:ss"
  timeZone={zone}
  name="received_at"
/>;

Date ranges with seconds

DateRangePicker with seconds takes each end to the second, for a report filtered from 08:00:00 to 17:59:59. Its ends are always YYYY-MM-DD HH:mm:ss: an end given without seconds is at its :00, and one given as a day alone runs from 00:00:00 (From) or to 23:59:59 (To). A preset runs from 00:00:00 to 23:59:59, and shows as pressed only for whole days.

  • From and To are each one field holding the end's day and time, typed or pasted whole. There are no spin fields: the typed field is the end's one editor. Picking days in the months keeps each end's time.
  • What's shown is what's saved. An end that would come before the start is marked, and Apply is off until it's put right: To typed at a time before From's on From's day, or a To day before From's that moves From's day there (keeping its time) past To. The same goes for one day picked twice when To's time is before From's, and for a value given that ends before it starts.
  • One pattern writes the field, the foot, From and To, and reads what's typed, so whatever the picker shows reads back as the same end when pasted. The pattern is format when it can be read back (patternProblem). A day's pattern gets the page language's time after it: dd/MM/yyyy writes 02/11/2026 14:30:05 in Portuguese. A day-time pattern to the minute gets :ss after its minutes. Otherwise it's the page language's own (dayTimePattern(lang())): its order and separators, and a four-digit Gregorian year (02/11/2026 14:30:05 in Thai, not 2569). A function format, or a pattern that can't be read back, is set aside, and the console says why, once.
  • The clock is the language's. That is 12-hour with AM and PM where the language uses them: 11/02/2026 02:30:05 PM in American English. An app that wants 24 hours everywhere gives a format with HH.
  • Typing reads what parseDayTime reads: any case, any spaces, the language's digits, and seconds left out (they're :00). It also reads an end as the toolkit keeps it, 2026-11-02 14:30:05 or with a T, but not an instant with a zone (…Z).
  • What's typed is read when it's done: on leaving From or To, on Enter, or on Apply. Until then it's text, and nothing moves: typing 2 on the way to 20 in To doesn't move From to the 2nd. Text that isn't one real day and time within the bounds stays as typed, marked, and Apply is off until it's put right. Picking a day in the months, or opening the picker again, sets it aside.
  • Bounds. A typed end is kept within min and max, which are days and take all of them (00:00:00 to 23:59:59). On any side they don't bound, it's kept within 200 years of today. So a Buddhist year (2569) or a Persian one (1405), typed out of habit, is refused, not saved as a Gregorian year. An app that needs years further away gives min or max.
  • What it doesn't do is in the known limits below.
  • From and To are date-picker-end-time-width wide (15em).
TSX
// Sales from 08:00:00 on the 2nd to 17:59:59 on the 6th:
// { start: "2026-11-02 08:00:00", end: "2026-11-06 17:59:59" }
<DateRangePicker
  label="Sales"
  value={range}
  onChange={setRange}
  today={today}
  max={today}
  format="dd/MM/yyyy"
  seconds
/>;
// An English app on a 24-hour clock: 11/02/2026 08:00:00 – 11/06/2026 17:59:59
<DateRangePicker
  value={range}
  onChange={setRange}
  today={today}
  format="MM/dd/yyyy HH:mm:ss"
  seconds
/>;

To compare stored timestamps with the ends, turn each into a moment in the app's time zone with dateOfDayTime (below).

Reading typed dates and times

parseDayTime(text, pattern, locale) reads a day and a time typed in a pattern, the inverse of formatPattern: what a pattern writes reads back as the value it was written from, in any language. With no pattern it reads the language's own (dayTimePattern(locale)). locale is the language of the month, weekday and AM/PM words, and of the digits it reads besides ASCII (English by default; the page's is lang()). The value has seconds when the pattern writes them.

  • What it allows:
  • spaces of any kind and number where the pattern has spaces, and any at the text's edges;
  • letters in any case;
  • a month or weekday name without its final dot (nov or nov. in French);
  • AM and PM as the language writes them, its marks and all (Tibetan's ་), or their letters with or without dots (p.m., PM);
  • one digit where the pattern writes two and no digit follows;
  • the language's own digits (Arabic-Indic in ar-EG, Persian in fa-IR), one kind to a field;
  • invisible right-to-left marks;
  • seconds left out with the : before them, when the pattern writes them (they're :00).

Literal words in the pattern must be typed as written ('lot, 1' needs its comma).

  • What it refuses (undefined):
  • a day the month doesn't have (31/02 is refused, never moved to March);
  • 25:00, 13 PM;
  • a two-digit year where the pattern writes four. The century is never guessed, and yy patterns can't be read back at all;
  • a weekday that isn't the date's;
  • seconds the pattern doesn't write;
  • text that could be read as two day-times.
  • Days are Gregorian, whatever the language's calendar: a Thai Buddhist year is read as that Gregorian year. Years have four digits, from 0000 (1 BC, as ISO 8601 counts it) to 9999.
  • patternProblem(pattern, locale) says why a pattern can't be read back, or gives undefined when it can:
  • a two-digit year (yy);
  • month names of a calendar other than the Gregorian one (Persian, Thai, Japanese-era, Taiwanese): write MM;
  • a 12-hour hour without a;
  • a field missing or repeated.

Every text is refused with a pattern that has a problem. Check an app's patterns with it in a test.

  • dayTimePattern(locale, seconds) is the pattern a language's people type a day and a time in. It has the language's order and separators and its clock, with a four-digit year, two-digit fields and the Gregorian calendar: MM/dd/yyyy hh:mm:ss a in American English, dd/MM/yyyy HH:mm:ss in Brazilian Portuguese. formatPattern(value, dayTimePattern(locale), locale) writes in it. A language the runtime doesn't support (Intl.DateTimeFormat.supportedLocalesOf leaves it out, as it does zz-ZZ, and Deno does Dzongkha) gets yyyy-MM-dd HH:mm:ss.
  • dateOfDayTime(value, timeZone) is the moment a day-time (or a day, at its start) names in a time zone (the page's when none is given), as a Date. Where the clocks change, one rule, Temporal's "compatible":
  • a time they skip moves forward by the gap: 02:30 on the night New York springs forward is 03:30;
  • a time they repeat is its first pass.

It's what new Date(y, m - 1, d, h, mi, s) does in the page's zone, and a named zone follows it too. With no zone, the page's clock is read as Date reads it, so a zone set the POSIX way (TZ=GMT+3, three hours behind UTC) is the one Date uses.

TypeScript
import {
  dateOfDayTime,
  dayTimePattern,
  formatPattern,
  parseDayTime,
  patternProblem,
} from "copilotz/web";

parseDayTime("02/11/2026 14:30:05", "dd/MM/yyyy HH:mm:ss"); // "2026-11-02 14:30:05"
parseDayTime("11/2/2026 2:30 PM", "M/d/yyyy h:mm a"); // "2026-11-02 14:30"
parseDayTime("02/11/2026 14:30", "dd/MM/yyyy HH:mm:ss"); // "2026-11-02 14:30:00"
parseDayTime("31/02/2026 10:00", "dd/MM/yyyy HH:mm"); // undefined: February has no 31st
parseDayTime("11/2/99, 2:30 PM", "M/d/yyyy, h:mm a"); // undefined: the year needs four digits
patternProblem("dd/MM/yy HH:mm"); // "`yy` leaves out the century: write `yyyy`"

const typed = dayTimePattern("en-US"); // "MM'/'dd'/'yyyy hh':'mm':'ss' 'a"
formatPattern("2026-11-02 14:30:05", typed, "en-US"); // "11/02/2026 02:30:05 PM"
parseDayTime("11/02/2026 2:30:05 pm", typed, "en-US"); // "2026-11-02 14:30:05"

// A report's ends as moments in the app's zone, to compare stored timestamps with.
dateOfDayTime("2026-11-16 14:30", "America/Sao_Paulo")?.toISOString(); // "2026-11-16T17:30:00.000Z"
dateOfDayTime("2026-03-08 02:30", "America/New_York")?.toISOString(); // "2026-03-08T07:30:00.000Z"
dateOfDayTime("2026-11-01 01:30", "America/New_York")?.toISOString(); // "2026-11-01T05:30:00.000Z"

Known limits of dates and times

Each is a case an app avoids; nothing here guesses or saves a wrong day.

  • Fields of no fixed length run together (d, M, names: yyyy/dM) can't always be read back: 2026/211 is November 2nd and January 21st, and is refused. patternProblem doesn't say so: separate them (yyyy/d/M).
  • A year-first format in another order than the toolkit's (yyyy-dd-MM), with seconds: From and To also read an end as the toolkit keeps it (2026-11-02 14:30:05), and text the two read as different ends is refused. Use yyyy-MM-dd, or another separator.
  • Names typed in capitals may not read in Greek or Turkish (ΜΑΪΟΥ, MAYIS): those languages' capitals don't lower back to their names.
  • Spaces at a format's edges ("dd/MM/yyyy "): what it writes isn't read back.
  • today near the first or last year, with seconds: it's 200 years or more from 0000 and 9999 (0200 to 9799).
  • The format or the page's language changed while a range is open: what's being typed is read by the new one.
  • min and max given as times of day (max="2026-11-16 12:00:00") hold for typed ends, but not for picked days or presets: a day picked on the bound's day keeps its end's time (23:59:59), and a preset runs to the end of its day. It's the same with time.
  • The months' Next button goes past December 9999 without max, where the months can't be drawn.

Bars, tiles and toasts

For an app without the Copilotz shell:

  • AppBar: the brand (words or a Logo; with href, home), the places (items: { href, label, icon?, key? }), and anything at its end. The active place (by key or href) is raised and announced as the page; icons sit beside labels or over them (layout="stacked"); on a phone the places scroll sideways.
  • TopBar: a thin strip with start, center and end (a clock, the company, the person and Sign out).
  • TileGrid: a home page's places as tiles, each a large icon and its name; a tile's description is its tooltip and what screen readers say after the name.
TSX
<TopBar start={<LiveClock format="dd/MM/yyyy HH:mm:ss" timeZone={zone} />} center="Acme Salon" end={<a href="/me">Ana</a>} />
<AppBar brand="Acme" href="/" active="/visits" layout="stacked" items={[
  { href: "/visits", label: "Visits", icon: <Icon src="/assets/places/visits.png" /> },
  { href: "/customers", label: "Customers", icon: "users" },
]} />

Toasts. toast(message, tone) or toast(message, { tone, duration }), from anywhere, shows a few seconds' word over the page and gives back a function that dismisses it. Tones are neutral (the default), success, info, warning and destructive; duration is 5,000 ms unless given (0: until dismissed); it waits while hovered or focused. The shell shows them; an app without it renders <Toasts placement="bottom-end" /> once, and one given a placement takes over from the shell's, so a toast never shows twice.

Icons

Every piece that takes an icon takes one of the toolkit's by name or any element (IconLike): <Icon drawing={…} /> draws an app's own glyph (its paths in their box, rule: "evenodd" for holes drawn that way), and <Icon src="/assets/…png" /> an image file. Avatar shows a picture from https:, the app's own origin, or one picked but not yet sent (a blob: or image data: address); initial={false} draws an empty box when there's none.

TSX
const GLYPH = {
  viewBox: "0 0 16 16",
  paths: [{ d: "M8 1a3.5 3.5 0 1 1 0 7…", rule: "evenodd" as const }],
};
<Button icon={<Icon drawing={GLYPH} />}>New customer</Button>;

Shortcuts

useShortcuts({ "Alt+1": focusItems, "Mod+S": save, Escape: { run: cancel, inFields: true } }) binds keys to a screen's commands while it's shown. Mod is ⌘ on Apple's keyboards and Ctrl elsewhere; letters and digits match the key pressed, so Alt+1 works whatever it types. A shortcut waits while a modal dialog or a popover is open (unless the screen is in it: within), and while someone types in a field unless it says inFields; a handled key's default is prevented. The shell's own keys (⌘K, the palette) come first. shortcutLabel("Alt+1") says it as the keyboard does (⌥1, or Alt+1).

Printing

A printed page is the whole page, not its scrolling pane's screenful, and it leaves out what only works on a screen: the shell's sidebar and menu, the toolkit's bars, toolbars, toasts, pages, buttons, popovers, a Page's header (unless printHeader), and a table's toolbar and tick column. Links keep their words. NoPrint and PrintOnly mark an app's own parts. A printed document's own layout (a receipt's width, an invoice's margins) is the one place an app writes CSS: its @media print rules, beside the document.

TSX
<NoPrint><Button icon="file" onClick={() => print()}>Print</Button></NoPrint>
<PrintOnly><Text size="sm">Printed {today}</Text></PrintOnly>

PDFs on a server

documentPdf(pages, { size }) draws a document as a PDF with no dependency and no React, so it runs on a server (an e-mailed invoice): pages of things placed in points from each page's top left, text (a font of Helvetica's four, a size, a colour, wrapped and aligned within a width), lines, rectangles and vector barcodes. Use drawDocumentPdf for images and automatically sized barcodes. Sizes are a4, a4-landscape, letter, receipt (80 mm wide, as tall as what's on it), or given. textWidth and wrapText measure with Helvetica's widths, to lay out flowing text. Text outside Windows-1252 prints as "?". copilotz/web/export has it, the table files and the barcodes' bars, without React.

TypeScript
import { documentPdf } from "copilotz/web/export";
const receipt = documentPdf([[
  { text: "Acme", x: 12, y: 12, width: 203, align: "center", font: "bold", size: 12 },
  { line: [12, 32, 215, 32] },
  { text: "Total", x: 12, y: 38 },
  { text: "12.50", x: 12, y: 38, width: 203, align: "right" },
  { barcode: "POS 12", x: 12, y: 60, width: 200, height: 40 },
]], { size: "receipt" });

Barcodes

Barcode draws an SVG of whole-pixel bars. width sets the space available, height the bars' height, and caption shows the value beneath. Its quiet margins are on by default. Code 128 packs digit pairs where they fit (set="B" uses text throughout). Use ProductBarcode with format="code39", format="ean8" or format="ean13" for the other symbols.

Images and barcodes in a document

Prepare a logo once with await pdfImage(bytesOrDataUrl) and reuse it on any page. JPEG stays JPEG. PNG supports 8-bit RGB, RGBA, grayscale, grayscale with alpha and indexed colours, including interlaced images and packed 1-, 2- and 4-bit grayscale or palette samples. Transparency becomes a PDF soft mask. The dimensions of the prepared image are pixels. The position and size on the page are points.

TypeScript
import { barcodePng, drawDocumentPdf, pdfImage } from "copilotz/web/export";

export async function invoiceFiles(logoBytes: Uint8Array) {
  const logo = await pdfImage(logoBytes);
  const product = "5901234123457";
  const pdf = drawDocumentPdf([[
    { image: logo, x: 36, y: 36, width: 40, height: 40 * logo.height / logo.width },
    { text: "Invoice 1042", x: 92, y: 42, size: 16, font: "bold" },
    { barcode: product, format: "ean13", x: 36, y: 120, width: 240, height: 54, quiet: true },
  ]]);
  const label = await barcodePng(product, { format: "ean13", width: 300, height: 60 });
  return { pdf, label }; // application/pdf and image/png
}

EAN-8 takes seven digits and EAN-13 takes twelve, or give the complete number and its check digit is verified. Keep leading zeros by passing a string. Code 39 accepts uppercase letters, digits, space and -.$/+%. The encoders return alternating bar and space widths in modules. Use barcodeBars when a renderer needs each bar's position and width.

TypeScript
import {
  barcodeBars,
  type BarcodeOptions,
  code39,
  ean13,
  ean8,
  eanDigits,
} from "copilotz/web/export";

const product = eanDigits("590123412345", 13);
const options: BarcodeOptions = { format: "ean13", quiet: true };
const geometry = barcodeBars(product, 300, options);
const retail = [ean8("0123456"), ean13(product)];
const shelf = code39("SHELF-2", { check: true }); // Include the Mod 43 check character.

A product screen can print the complete EAN under its SVG:

TSX
import { ProductBarcode } from "copilotz/web";

<ProductBarcode format="ean13" value="590123412345" width={300} height={60} caption />;

Barcode widths grow to fit at least one whole unit per module, including the requested quiet margins. For example, Code 128 with SKU-12345 and quiet margins grows from a requested 120 units to 143. EAN-13 with quiet margins requires 113 pixels for PNG or 113 points for PDF. In drawDocumentPdf, omitting the barcode's width uses the space from its x position to the page edge. A width or height of zero or less raises a RangeError, as do printed bars extending beyond the page. Barcode heights must be at least one pixel in SVG and PNG, or 0.01 points in either PDF renderer. The blank quiet margins can extend beyond the page edges.

A route's own page

A route that answers a page of its own (an import screen before anyone signs in, a password reset) makes it with the toolkit too: routePage(runtime, { title, body, status, headers, lang }) from copilotz/web/server gives a Response whose head is the app page's (its theme, base, icons, colour and fonts) and whose body is React made on the server, with the app's words. No script runs on it, so its links and forms that post are what work. Its body is a Page, or a Screen when nothing titles it (a sign-in's card, above).

TSX
"/import": (request, { runtime }) => routePage(runtime, {
  title: "Import",
  body: <Page title="Import"><Stack as="form" method="post"><Field label="File" htmlFor="file"><Input id="file" type="file" name="file" /></Field><Button type="submit" variant="primary">Import</Button></Stack></Page>,
}),

Every piece's tokens

Each token is a CSS variable a theme sets without its --: sizes in tokens, colours in light and dark. The default is Copilotz's look; one that names another token follows it.

Spacing scale

TokenDefault
space-xs4px
space-sm8px
space-md12px
space-lg16px
space-xl24px
space-2xl32px

Stack and Divider

TokenDefault
divider-width1px
divider-colorvar(--border)

Toolbar

TokenDefault
toolbar-padding0
toolbar-radius0
toolbar-backgroundtransparent
toolbar-grow-basis200px

Split

TokenDefault
split-gap24px
split-aside-width-sm280px
split-aside-width340px
split-aside-width-lg420px
split-sticky-top16px

ListGroup

TokenDefault
list-group-border-width1px
list-group-radiusvar(--radius-lg)
list-group-row-height44px
list-group-padding10px 14px
list-group-font-size14px
list-group-font-weight560
list-group-end-padding14px

Screen

TokenDefault
screen-padding24px
screen-width420px
screen-gap24px

Text and Heading

TokenDefault
text-size-xs12px
text-size-sm13px
text-size-md14.5px
text-size-lg17px
heading-fontvar(--font-display)
heading-font-weight650
heading-letter-spacing-.015em
heading-size-128px
heading-size-221px
heading-size-317px
heading-size-415px

Page

TokenDefault
page-width820px
page-padding34px 24px 64px
page-width-lg1040px
page-title-fontvar(--font-display)
page-title-size28px
page-title-weight680
page-description-width560px
page-body-gap20px
page-padding-sm16px 16px 48px
page-title-size-sm22px

Card

TokenDefault
card-border-colorvar(--border)
card-radiusvar(--radius-xl)
card-shadowvar(--shadow-sm)
card-padding14px 16px
card-padding-sm8px 10px
card-head-padding10px 16px
card-head-border1px solid var(--border)
card-head-backgroundtransparent
card-head-foregroundinherit
card-head-icon-colorvar(--muted-foreground)
card-title-font-familyvar(--font-display)
card-title-font-size15px
card-title-font-weight600

Button

TokenDefault
button-hover-mixvar(--tone-toward)
button-hover-amountvar(--tone-amount)
button-shadowvar(--shadow-sm)
button-gap8px
button-height36px
button-padding0 14px
button-radiusvar(--radius-md)
button-border-width1px
button-font-size14px
button-font-weight560
button-line-height1
button-active-transformtranslateY(.5px)
button-active-shadowvar(--button-shadow, var(--shadow-sm))
button-disabled-opacity.5
button-disabled-cursordefault
button-height-xs26px
button-padding-xs0 8px
button-gap-xs5px
button-font-size-xs12px
button-radius-xsvar(--button-radius, var(--radius-md))
button-height-sm30px
button-padding-sm0 11px
button-gap-sm6px
button-font-size-sm13px
button-radius-smvar(--button-radius, var(--radius-md))
button-height-lg44px
button-padding-lg0 18px
button-font-size-lg15px
button-radius-lgvar(--button-radius, var(--radius-md))
button-outline-backgroundvar(--card)
button-outline-foregroundvar(--card-foreground)
button-outline-bordervar(--input)
button-outline-hover-backgroundvar(--muted)
button-outline-hover-foregroundvar(--button-outline-foreground, var(--card-foreground))
button-outline-hover-bordervar(--button-outline-border, var(--input))
button-link-padding0
button-link-foregroundvar(--primary-text)

IconButton

TokenDefault
icon-button-size34px
icon-button-radiusvar(--radius-md)
icon-button-size-sm28px
icon-button-radius-smvar(--radius-sm)
icon-button-size-lg38px

Input

TokenDefault
input-height40px
input-border-width1px
input-radiusvar(--radius-lg)
input-backgroundvar(--card)
input-focus-shadow0 0 0 4px color-mix(in oklab, var(--ring) 16%, transparent)
input-radius-smvar(--radius-md)
input-gap8px
input-padding0 12px
input-invalid-focus-shadow0 0 0 4px color-mix(in oklab, var(--destructive) 14%, transparent)
input-disabled-opacity.55
input-disabled-backgroundvar(--input-background, var(--card))
input-font-size14.5px
input-placeholdervar(--muted-foreground)
input-placeholder-opacity.85
input-height-sm36px
input-padding-sm0 3px 0 10px
input-font-size-sm14px
input-height-lg44px
input-padding-lg0 14px
input-radius-lg${RADIUS}
input-font-size-lg15px
input-addon-min-width36px
input-addon-padding0 10px
input-addon-border-widthvar(--input-border-width, 1px)
input-addon-backgroundvar(--muted)
input-addon-foregroundvar(--muted-foreground)
input-addon-font-size14px

Select

TokenDefault
select-min-width160px
select-heightvar(--input-height, 40px)
select-border-widthvar(--input-border-width, 1px)
select-radiusvar(--input-radius, var(--radius-lg))
select-backgroundvar(--input-background, var(--card))
select-font-sizevar(--input-font-size, 14.5px)
select-height-smvar(--input-height-sm, 36px)
select-font-size-smvar(--input-font-size-sm, 14px)
select-padding0 36px 0 12px
select-focus-shadowvar(--input-focus-shadow, 0 0 0 4px color-mix(in oklab, var(--ring) 16%, transparent))
select-disabled-opacityvar(--input-disabled-opacity, .55)
select-disabled-backgroundvar(--input-disabled-background, var(--select-background, var(--input-background, var(--card))))
select-radius-smvar(--input-radius-sm, var(--radius-md))
select-height-lgvar(--input-height-lg, 44px)
select-font-size-lgvar(--input-font-size-lg, 15px)

Textarea

TokenDefault
textarea-min-height84px
textarea-padding10px 12px
textarea-border-widthvar(--input-border-width, 1px)
textarea-radiusvar(--input-radius, var(--radius-lg))
textarea-backgroundvar(--input-background, var(--card))
textarea-font-sizevar(--input-font-size, 14.5px)
textarea-line-height1.5
textarea-focus-shadowvar(--input-focus-shadow, 0 0 0 4px color-mix(in oklab, var(--ring) 16%, transparent))
textarea-disabled-backgroundvar(--input-disabled-background, var(--textarea-background, var(--input-background, var(--card))))

Checkbox

TokenDefault
checkbox-gap9px
checkbox-font-size14px
checkbox-size16px
checkbox-border-width1.5px
checkbox-radiuscalc(var(--radius) / 3)

Radio

TokenDefault
radio-gap9px
radio-font-size14px
radio-size16px
radio-border-width1.5px

Field

TokenDefault
field-gap7px
field-label-font-size13.5px
field-label-font-weight600
field-label-colorvar(--foreground)
field-required-colorvar(--destructive-text)
field-note-font-size12.5px
field-row-label-width30%
field-row-control-width1fr
field-row-gap16px
field-row-label-offset0
field-row-label-alignstart

Switch

TokenDefault
switch-width36px
switch-height20px
switch-padding2px
switch-border-width0
switch-border-colortransparent
switch-radius9999px
switch-off-backgroundvar(--input)
switch-off-foregroundvar(--secondary-foreground)
switch-font-size12px
switch-font-weight650
switch-width-sm30px
switch-height-sm16px
switch-width-lg44px
switch-height-lg24px
switch-on-backgroundvar(--primary)
switch-on-foregroundvar(--primary-foreground)
switch-thumb-aspect1
switch-thumb-widthauto
switch-thumb-radius9999px
switch-thumb-backgroundvar(--background)
switch-thumb-shadowvar(--shadow-sm)
switch-word-padding7px
switch-disabled-opacity.5

TagsInput

TokenDefault
tags-input-gap6px
tags-input-min-heightvar(--input-height, 40px)
tags-input-padding5px 8px
tags-input-border-widthvar(--input-border-width, 1px)
tags-input-border-colorvar(--input)
tags-input-radiusvar(--input-radius, var(--radius-lg))
tags-input-backgroundvar(--input-background, var(--card))
tags-input-font-sizevar(--input-font-size, 14.5px)
tags-input-focus-border-colorvar(--ring)
tags-input-focus-shadowvar(--input-focus-shadow, 0 0 0 4px color-mix(in oklab, var(--ring) 16%, transparent))
tag-padding2px 4px 2px 9px
tag-radiusvar(--radius-full)
tag-backgroundvar(--secondary)
tag-foregroundvar(--secondary-foreground)
tag-font-size13px
tag-font-weight560

Picker and MultiPicker

TokenDefault
picker-min-widthvar(--select-min-width, 160px)
picker-heightvar(--select-height, var(--input-height, 40px))
picker-padding0 10px 0 12px
picker-border-widthvar(--select-border-width, var(--input-border-width, 1px))
picker-border-colorvar(--input)
picker-radiusvar(--select-radius, var(--input-radius, var(--radius-lg)))
picker-backgroundvar(--select-background, var(--input-background, var(--card)))
picker-foregroundvar(--foreground)
picker-font-sizevar(--select-font-size, var(--input-font-size, 14.5px))
picker-font-weight400
picker-hover-backgroundvar(--picker-background, var(--card))
picker-hover-foregroundvar(--picker-foreground, var(--foreground))
picker-open-border-colorvar(--ring)
picker-open-backgroundvar(--picker-background, var(--card))
picker-open-foregroundvar(--picker-foreground, var(--foreground))
picker-focus-shadowvar(--input-focus-shadow, 0 0 0 4px color-mix(in oklab, var(--ring) 16%, transparent))
picker-height-smvar(--select-height-sm, var(--input-height-sm, 36px))
picker-font-size-smvar(--select-font-size-sm, var(--input-font-size-sm, 14px))
picker-caret-colorvar(--muted-foreground)
picker-menu-min-width200px
picker-menu-max-width420px
picker-menu-padding5px
picker-item-font-size14px
picker-search-height34px
picker-item-radiusvar(--radius-md)
picker-list-max-height320px
picker-item-height34px
picker-item-padding6px 10px
picker-item-foregroundvar(--popover-foreground)
picker-item-hover-backgroundvar(--accent)
picker-item-hover-foregroundvar(--accent-foreground)
picker-item-chosen-backgroundtransparent
picker-item-chosen-foregroundvar(--picker-item-foreground, var(--popover-foreground))
picker-item-chosen-font-weight600
picker-item-chosen-hover-backgroundvar(--picker-item-hover-background, var(--accent))
picker-check-colorvar(--primary-text)

Dialog

TokenDefault
dialog-width520px
dialog-border-colorvar(--border)
dialog-radiusvar(--radius-2xl)
dialog-shadowvar(--shadow-lg)
dialog-width-sm400px
dialog-width-lg760px
dialog-topmin(12vh, 96px)
dialog-backdroprgb(8 8 14 / .55)
dialog-head-padding18px 14px 2px 22px
dialog-head-border0
dialog-head-backgroundtransparent
dialog-head-foregroundinherit
dialog-close-colorvar(--muted-foreground)
dialog-title-margin4px 0 0
dialog-title-font-familyvar(--font-display)
dialog-title-font-size17px
dialog-title-font-weight650
dialog-title-letter-spacing-.01em
dialog-body-padding14px 22px 22px
dialog-foot-gap8px
dialog-foot-padding14px 18px
dialog-foot-border1px solid var(--border)
dialog-foot-backgroundcolor-mix(in oklab, var(--muted) 45%, var(--popover))

Drawer

TokenDefault
drawer-width320px

Tabs

TokenDefault
tabs-tab-height34px
tabs-tab-padding0 12px
tabs-tab-radiusvar(--radius-md)
tabs-tab-colorvar(--muted-foreground)
tabs-tab-font-size13.5px
tabs-tab-font-weight560
tabs-tab-hover-colorvar(--foreground)
tabs-segmented-padding3px
tabs-segmented-radiusvar(--radius-lg)
tabs-segmented-backgroundvar(--muted)
tabs-segmented-shadowvar(--shadow-sm)
tabs-line-gap6px
tabs-line-tab-height40px
tabs-line-tab-padding0 6px
tabs-line-tab-radius0
tabs-line-tab-border-width0 0 2px
tabs-line-hover-backgroundtransparent
tabs-line-hover-border-colortransparent
tabs-selected-colorvar(--foreground)
tabs-line-selected-backgroundtransparent
tabs-line-selected-border-colortransparent transparent var(--primary)
TokenDefault
menu-min-width200px
menu-padding5px
menu-border-colorvar(--border)
menu-radiusvar(--radius-lg)
menu-shadowvar(--shadow-md)
menu-item-height34px
menu-item-padding6px 10px
menu-item-radiusvar(--radius-sm)
menu-item-colorinherit
menu-item-font-size14px
menu-item-hover-backgroundvar(--accent)
menu-item-hover-foregroundvar(--accent-foreground)
menu-item-hover-iconvar(--muted-foreground)

Popover

TokenDefault
popover-width300px
popover-padding6px
popover-border-colorvar(--border)
popover-radiusvar(--radius-xl)
popover-shadowvar(--shadow-lg)

Autocomplete

TokenDefault
autocomplete-width380px
autocomplete-padding5px
autocomplete-border-colorvar(--border)
autocomplete-radiusvar(--radius-xl)
autocomplete-shadowvar(--shadow-lg)
autocomplete-option-height40px
autocomplete-option-padding5px 9px
autocomplete-option-radiusvar(--radius-md)
autocomplete-active-backgroundvar(--accent)
autocomplete-active-foregroundvar(--accent-foreground)
autocomplete-option-font-size14px
autocomplete-option-font-weight560

Tooltip

TokenDefault
tooltip-max-width280px
tooltip-padding5px 9px
tooltip-radiusvar(--radius-sm)
tooltip-backgroundvar(--foreground)
tooltip-foregroundvar(--background)
tooltip-font-size12.5px

Avatar

TokenDefault
avatar-empty-backgroundvar(--muted)
avatar-empty-border-colorvar(--border)

Badge

TokenDefault
badge-min-width20px
badge-padding1px 7px
badge-radiusvar(--radius-full)
badge-font-size11.5px
badge-font-weight600

Chip

TokenDefault
chip-height30px
chip-radiusvar(--radius-full)
chip-font-size13px

Notice

TokenDefault
notice-padding10px 12px
notice-radiusvar(--radius-lg)
notice-font-size14px

EmptyState

TokenDefault
empty-state-icon-size56px
empty-state-icon-radiusvar(--radius-2xl)
empty-state-title-size20px

DetailList

TokenDefault
detail-list-radiusvar(--radius-xl)
detail-list-font-size14px
detail-list-label-widthclamp(7rem, 30%, 13rem)
detail-list-padding11px 16px

DataTable

TokenDefault
table-cell-padding10px 12px
table-border-colorvar(--border)
table-font-size14px
table-toolbar-gap8px
table-toolbar-margin12px
table-search-width220px
table-radiusvar(--radius-lg)
table-backgroundvar(--card)
table-row-border-width1px
table-column-border-width0px
table-head-backgroundcolor-mix(in oklab, var(--muted) 70%, var(--card))
table-head-foregroundvar(--muted-foreground)
table-head-font-size12.5px
table-head-font-weight600
table-stripetransparent
table-hovercolor-mix(in oklab, var(--muted) 55%, transparent)
table-selectedvar(--primary-soft)
table-detail-padding12px 16px
table-empty-padding32px 12px

Pagination

TokenDefault
pagination-margin12px
pagination-font-size13px
pagination-gap2px
pagination-link-size32px
pagination-link-radiusvar(--radius-md)
pagination-link-font-weight560
pagination-current-backgroundvar(--primary)
pagination-current-foregroundvar(--primary-foreground)

Calendar

TokenDefault
calendar-gap20px
calendar-font-size13px
calendar-head-gap4px
calendar-title-fontvar(--font-display)
calendar-title-size14px
calendar-title-weight650
calendar-day-size34px
calendar-day-radiusvar(--radius-md)
calendar-nav-colorvar(--muted-foreground)
calendar-hover-backgroundvar(--accent)
calendar-hover-foregroundvar(--accent-foreground)
calendar-row-gap2px
calendar-weekday-colorvar(--muted-foreground)
calendar-weekday-size11.5px
calendar-today-ringvar(--border)
calendar-range-radius0
calendar-range-backgroundvar(--primary-soft)
calendar-range-foregroundvar(--primary-text)
calendar-selected-backgroundvar(--primary)
calendar-selected-foregroundvar(--primary-foreground)
calendar-day-size-touch40px

DatePicker and DateRangePicker

TokenDefault
date-picker-width0
date-picker-height40px
date-picker-padding0 12px
date-picker-border-width1px
date-picker-bordervar(--input)
date-picker-radiusvar(--radius-lg)
date-picker-backgroundvar(--card)
date-picker-foregroundvar(--foreground)
date-picker-font-size14.5px
date-picker-focus-bordervar(--ring)
date-picker-focus-shadow0 0 0 4px color-mix(in oklab, var(--ring) 16%, transparent)
date-picker-panel-padding12px
date-picker-panel-font-size13px
date-picker-panel-gap16px
date-picker-preset-gap2px
date-picker-presets-width180px
date-picker-preset-height32px
date-picker-preset-padding0 10px
date-picker-preset-radiusvar(--radius-md)
date-picker-preset-font-size13.5px
date-picker-preset-active-backgroundvar(--primary-soft)
date-picker-preset-active-foregroundvar(--primary-text)
date-picker-foot-gap12px
date-picker-fields-gap10px
date-picker-end-width9.5em
date-picker-end-time-width15em
date-picker-height-touch44px
date-picker-preset-height-touch40px

DateTimePicker

TokenDefault
date-time-picker-gap6px
date-time-picker-spin-width3.6em

LiveClock

TokenDefault
live-clock-numerictabular-nums

FileInput

TokenDefault
file-input-gap10px
file-input-padding4px 6px 4px 4px
file-input-font-size14px
file-input-drop-border-colorvar(--primary)
file-input-drop-backgroundvar(--primary-soft)
file-input-button-height30px
file-input-button-padding0 11px
file-input-button-radiusvar(--radius-md)
file-input-button-backgroundvar(--secondary)
file-input-button-foregroundvar(--secondary-foreground)
file-input-button-font-weight560

RowsEditor

TokenDefault
rows-editor-gap12px
rows-editor-label-width88px
rows-editor-column-gap12px
rows-editor-label-font-size13.5px
rows-editor-label-font-weight600
rows-editor-label-colorvar(--foreground)
rows-editor-actions-offset6px
rows-editor-error-font-size12.5px

AppBar

TokenDefault
appbar-backgroundvar(--background)
appbar-foregroundvar(--foreground)
appbar-border-width1px
appbar-border-colorvar(--border)
appbar-shadownone
appbar-gap16px
appbar-max-widthnone
appbar-height56px
appbar-padding-x16px
appbar-brand-colorcurrentColor
appbar-brand-fontvar(--font-display)
appbar-brand-font-size17px
appbar-brand-font-weight650
appbar-brand-hover-colorvar(--appbar-brand-color, currentColor)
appbar-items-justifyflex-start
appbar-items-gap4px
appbar-item-gap8px
appbar-item-height36px
appbar-item-padding0 12px
appbar-item-radiusvar(--radius-md)
appbar-item-colorvar(--muted-foreground)
appbar-item-font-size14px
appbar-item-font-weight560
appbar-item-hover-backgroundvar(--accent)
appbar-item-hover-colorvar(--accent-foreground)
appbar-item-active-border-colorvar(--border)
appbar-item-active-backgroundvar(--card)
appbar-item-active-colorvar(--card-foreground)
appbar-item-active-shadowvar(--shadow-sm)
appbar-item-active-font-weight620
appbar-icon-size18px
appbar-icon-colorvar(--primary-text)
appbar-stacked-gap2px
appbar-stacked-padding6px 10px
appbar-stacked-font-size12px

TopBar

TokenDefault
topbar-backgroundvar(--muted)
topbar-foregroundvar(--muted-foreground)
topbar-font-size12.5px
topbar-border-width1px
topbar-border-colorvar(--border)
topbar-gap12px
topbar-max-widthnone
topbar-height28px
topbar-padding-y2px
topbar-padding-x16px
topbar-center-font-weight620
topbar-center-colorvar(--foreground)
topbar-link-colorvar(--primary-text)

TileGrid

TokenDefault
tile-justifyflex-start
tile-gap12px
tile-label-gap10px
tile-width132px
tile-padding16px 10px 14px
tile-border-width1px
tile-border-colorvar(--border)
tile-radiusvar(--radius-xl)
tile-backgroundvar(--card)
tile-colorvar(--card-foreground)
tile-shadowvar(--shadow-sm)
tile-font-size14px
tile-font-weight560
tile-hover-backgroundvar(--muted)
tile-hover-colorvar(--tile-color, var(--card-foreground))
tile-hover-decorationnone
tile-icon-size40px
tile-icon-radius0
tile-icon-colorvar(--primary-text)

Toasts

TokenDefault
toast-gap8px
toast-width360px
toast-offset16px
toast-icon-gap10px
toast-padding12px 12px 12px 14px
toast-border-width1px
toast-radiusvar(--radius-lg)
toast-shadowvar(--shadow-md)
toast-font-size14px
toast-font-weight520
toast-line-height1.45
toast-icon-displayinline-block
toast-close-opacity.7
toast-neutral-backgroundvar(--popover)
toast-neutral-foregroundvar(--popover-foreground)
toast-neutral-bordervar(--border)
toast-neutral-iconvar(--muted-foreground)
toast-success-backgroundvar(--success-soft)
toast-success-foregroundvar(--success-text)
toast-success-bordervar(--success-border)
toast-success-iconvar(--success)
toast-info-backgroundvar(--info-soft)
toast-info-foregroundvar(--info-text)
toast-info-bordervar(--info-border)
toast-info-iconvar(--info)
toast-warning-backgroundvar(--warning-soft)
toast-warning-foregroundvar(--warning-text)
toast-warning-bordervar(--warning-border)
toast-warning-iconvar(--warning)
toast-destructive-backgroundvar(--destructive-soft)
toast-destructive-foregroundvar(--destructive-text)
toast-destructive-bordervar(--destructive-border)
toast-destructive-iconvar(--destructive)

Barcode

TokenDefault
barcode-caption-gap2px
barcode-padding0
barcode-background#fff
barcode-color#000
barcode-radius0
barcode-fontvar(--font-mono)
barcode-font-size12px
barcode-letter-spacing.08em