# The kit, A to D

shadcn/ui's components from Accordion to Dropdown Menu (ui.shadcn.com/docs/components, the Base UI
set), as Mote components: `kit/base.mote`, and the parts that `kit/kit.mote`'s Button, Badge, Card,
Checkbox, Avatar, Alert, Accordion, Dialog and Combobox gained. Everything that worked before still
does: the one-line forms (`Card title=`, `Dialog open= title=`, `Accordion title=`, `Alert title=`,
`Avatar name=`, `Combobox value= options=`) are unchanged.

The gallery is `examples/kit/base.mote` (a section each, every variant); `tests/kit_base.real.mjs`
drives it:

    mote dev examples/kit/base.mote --port 5011 &
    node tests/real.mjs http://localhost:5011/ tests/kit_base.real.mjs

Four things hold for all of them, and are where they differ from the original:

- **No Trigger parts, no `asChild` / `render`.** What opens a thing is the element it is written under
  (menus, popovers, date pickers), or a flag the page holds (`open=flag`: dialogs, drawers, the command
  dialog), written back when it closes.
- **No context between parts.** Where the original's parts share something, the page holds it and each
  part is given it: a flag (`Collapsible open=more`, and the same on its trigger and content), a value
  (`AccordionTrigger value= open=faq`), or one `json` value the parts keep their own notes in
  (`state m: json = {}` and `nav=m` on a menu and each of its items; `api=car` on a carousel's parts).
- **Children cannot be read or styled by a parent.** So an item repeats its words as `label=` where the
  keyboard needs them, a group that sizes its members is told the size as they are, and the larger
  things (Calendar, Data Table, the charts, Combobox) take data rather than parts.
- **A flag is not the first word after a component's name.** There a lone word is read as its text
  (`BreadcrumbSeparator plain` is refused, `Button disabled size="sm"` is silently not disabled): write
  `plain=true`, or put the flag after another attribute (`Button "Save" size="sm" disabled`).

## Accordion

    Accordion title="What is in the box?"          one item that opens by itself (as before); `open` to start open
      text "…"

    state faq = "ship"                             what is open: a string for one at a time,
                                                   or `state faq: string[] = []` for several
    Accordion type="single" collapsible=true
      AccordionItem
        AccordionTrigger "Shipping" value="ship" open=faq collapsible=true
        AccordionContent value="ship" open=faq
          text "…"

- `AccordionTrigger value= open= type= collapsible= disabled=`: type "single" (as it comes) | "multiple".
  `open` is the page's value, written back: the item's `value` (single; "" when a collapsible one is
  closed) or the list of open values (multiple, or whenever the page's value is a list).
- `AccordionContent value= open=`: its height runs open and shut; closed, it is `inert`. role=region.
- `AccordionItem`: the line under each. `Accordion`: the frame; with `title=` it is the old one-line item.
- Keyboard: the trigger is a button (Tab, Enter, Space) with `aria-expanded`.

Differs: no context, so `value` and `open` are said on both the trigger and the content, and `type` /
`collapsible` on the trigger (on `Accordion` they are accepted and only recorded as data attributes).
No arrow keys between triggers (Base UI's roving focus): Tab moves between them. `Accordion title=` is
the browser's `details`, which does not animate.

## Alert

    Alert title="Heads up"                         one line, as before; variant="destructive"
      text "…"
    Alert variant="destructive" icon=false
      AlertTitle "Your session has expired"
      AlertDescription
        text "Sign in again."
      AlertAction
        Button "Sign in" size="sm" variant="outline"

- `Alert title= variant= icon=`: variant "default" | "destructive". role=alert.
- `AlertTitle`, `AlertDescription`, `AlertAction` (at the far side, centred on the alert's height).

Differs: the icon is Alert's own (info, or circle-alert when destructive) rather than a child, since a
child's place cannot be told from its kind; `icon=false` removes it (put another inside `AlertTitle`).

## Alert Dialog

    state asking = false
    Button "Delete" press={asking = true}
    AlertDialog open=asking
      AlertDialogContent size="sm"
        AlertDialogHeader
          AlertDialogMedia
            icon "trash-2"
          AlertDialogTitle "Delete the chat?"
          AlertDialogDescription "It is gone for good."
        AlertDialogFooter
          AlertDialogCancel "Cancel"
          AlertDialogAction "Delete" variant="destructive" press=remove

- `AlertDialog open=`: a modal `dialog` with role=alertdialog. Escape closes it; a click outside does not.
  `open` is written back.
- `AlertDialogContent size=`: "default" (512 wide) | "sm" (320, centred words).
- `AlertDialogAction press= variant= disabled=`, `AlertDialogCancel press= variant=`: kit Buttons (default
  and outline). Each closes the dialog after its `press`.
- `AlertDialogHeader`, `AlertDialogTitle`, `AlertDialogDescription`, `AlertDialogMedia`, `AlertDialogFooter`
  (a column, last first, on a phone).

Differs: no `AlertDialogTrigger`: it opens by a value, `open=flag`. Action and Cancel always close (they
are the buttons of a `form method=dialog`); an action that must keep it open sets the flag true again.
With `size="sm"` the footer does not turn into two equal columns (it cannot know its content's size):
give it `justify-content=center`.

## Aspect Ratio

    AspectRatio ratio=(16 / 9) border-radius=10
      image "photo.jpg" width=100% height=100% object-fit=cover

- `AspectRatio ratio=`: a number, width over height; left out it is 1. The box is as wide as it is let
  be and clips what is inside.

Differs: the child is not stretched for you: give it `width=100% height=100%`.

## Avatar

    Avatar name="Ada Lovelace" src=url              one line, as before: the picture, or the initials
    Avatar size="lg"
      AvatarImage src=url alt="Ada"
      AvatarFallback "AL"
      AvatarBadge                                   a dot; an icon inside it if wanted; background=… to recolour
    AvatarGroup size="sm"
      Avatar size="sm" name="Ada Lovelace" ring=true
      Avatar size="sm" name="Grace Hopper" ring=true
      AvatarGroupCount "+3" size="sm"

- `Avatar name= src= size= ring=`: size "sm" (24) | "default" (32) | "lg" (40), or a number of pixels.
  Left out it is 40, as it always was. `ring`: a rim in the page's colour.
  A circle unless it is given a corner: `Avatar src=url border-radius=10` (or `"30%"`) is a
  rounded square, and the picture (its own, or an `AvatarImage` inside) has the same corner.
- `AvatarImage src= alt=`: shown once it has loaded; one that never loads leaves the fallback seen.
- `AvatarFallback`, `AvatarBadge`, `AvatarGroup size=` (each overlaps the one before by 8),
  `AvatarGroupCount size=`.

Differs: `AvatarGroup` cannot reach into its avatars, so the group and its avatars are each told the
size, and each avatar its `ring`. No `delay` on the fallback.

## Badge

    Badge "New" variant="secondary"

- variant: "default" | "secondary" | "destructive" | "outline" | "ghost" | "link". Children may be an icon
  and text.

Differs: no `asChild` / `render` (a badge that is a link: put a `link` inside, or `variant="link"`).

## Breadcrumb

    Breadcrumb
      BreadcrumbList
        BreadcrumbItem
          BreadcrumbLink "Home" href="/"
        BreadcrumbSeparator
        BreadcrumbItem
          BreadcrumbEllipsis
        BreadcrumbSeparator plain=true              the page's own mark instead of the chevron
          icon "slash" size=14
        BreadcrumbItem
          BreadcrumbPage "Breadcrumb"

- `Breadcrumb` (a `nav` labelled breadcrumb), `BreadcrumbList` (`ol`), `BreadcrumbItem` (`li`),
  `BreadcrumbLink href=`, `BreadcrumbPage` (aria-current="page"), `BreadcrumbSeparator plain=`,
  `BreadcrumbEllipsis`.

Differs: no `asChild` on the link (it is an `a`; a route's address works as `href`). A collapsed middle
that opens a menu: write a `DropdownMenu` under a Button holding `BreadcrumbEllipsis`. Under `dir="rtl"`
the chevron is not turned round (a component cannot read the direction): use `plain=true` with
`icon "chevron-left"`.

## Button

    Button "Save" press=save variant="outline" size="sm" disabled=busy
    Button size="icon" title="Like"
      icon "heart"

- variant: "default" | "secondary" | "outline" | "ghost" | "destructive" | "link".
- size: "xs" (24 high) | "sm" (32) | "default" or "md" (36) | "lg" (40) | "icon" (36 square) |
  "icon-xs" (24) | "icon-sm" (32) | "icon-lg" (40).
- `press`, `disabled`, `type` ("button" as it comes; "submit"), `title`.

Differs: no `asChild` / `render` (a link that looks like a button: style the `link`). A disabled button
is not pressed wherever in it the press lands.

## Button Group

    ButtonGroup orientation="vertical"
      Button "Archive" variant="outline"
      Button "Report" variant="outline"
    ButtonGroup
      ButtonGroupText "https://"
      Button "Copy" variant="secondary"
      ButtonGroupSeparator
      Button "Paste" variant="secondary"

- `ButtonGroup orientation=`: "horizontal" | "vertical". role=group. Its Buttons share one 1px line
  between neighbours and only the group's ends have corners.
- `ButtonGroupSeparator orientation=`: a line between buttons that have no border ("vertical", as it
  comes, for a horizontal group; "horizontal" for a vertical one).
- `ButtonGroupText`: words in the group that are not a button.

Differs: a component cannot style its children, so the group tells its Buttons through the line height
it sets (0 or 1px), which a Button measures its corners and borders in. Two things follow: only kit
`Button`s join (an `Input` or `Select` in a group keeps its own corners); and a `Menu`, `Popover` or `tip`
written under a grouped button inherits that line height and needs `line-height=normal` (the
DropdownMenu, Combobox and date pickers of this file already say it). Nested groups are not spaced apart
for you: put two groups in a `row gap=8`.

## Calendar

    Calendar selected=day                                     a string, "" for none
    Calendar mode="multiple" selected=days                    a list of strings
    Calendar mode="range" selected=stay numberOfMonths=2      {from, to}, "" where not yet picked
    Calendar selected=day month=shown captionLayout="dropdown" weekStartsOn=1 min="2025-06-03" max="2025-07-18" disabled=["2025-06-11"] disabledWeekdays=[0, 6] showOutsideDays=false change=picked

Dates are "YYYY-MM-DD" strings everywhere. One component; day-picker's parts (Month, Caption, Nav, Weekdays, Day…) are not separate components.

| prop | words | |
|---|---|---|
| `mode` | `"single"` (as it comes) · `"multiple"` · `"range"` | what `selected` is: a string, a list (kept in order), `{from, to}` |
| `selected` | | written back on every pick |
| `month` | `"YYYY-MM"` | the first month shown; written back as it is turned, followed if the page changes it. Left out: the month of what is selected, else this month |
| `captionLayout` | `"label"` (as it comes) · `"dropdown"` | dropdown: a month and a year `select`; years `fromYear` to `toYear` (else min's year to max's, else 100 back and 10 on) |
| `weekStartsOn` | 0 (Sunday) to 6 | |
| `min` `max` | a date | days outside cannot be picked; the month buttons stop there |
| `disabled` | a list of dates | |
| `disabledWeekdays` | a list of 0 to 6 | day-picker's `{dayOfWeek: […]}` |
| `showOutsideDays` | `true` (as it comes) · `false` | |
| `numberOfMonths` | 1 · 2 (any number works) | they wrap under one another on a phone |
| `autofocus` | bool | puts the keyboard on the current day when it is built (the pickers use it) |
| `change` | a handler | called with the new `selected` after each pick |

Children of `Calendar` are shown under the months (the pickers put their presets there).

Keys, with a day in focus: arrows by day and by week, PageUp / PageDown by month (the same day, or the month's last), Home / End to the ends of the week, Enter or Space picks. A day that cannot be picked is stepped over; past `min` / `max` the focus stays. One day is in the tab order (a roving tabindex). The month shown follows the focus.

ARIA: each month is `role=grid` named by month and year, weeks `role=row`, headings `role=columnheader`, days `role=gridcell` with `aria-selected`, `aria-current="date"` on today, a spoken date as `aria-label`, and `disabled`. Each day also carries `data-date`, and `data-outside` when it belongs to the month before or after.

What differs from shadcn (react-day-picker):
- Month and weekday names are the reader's own but short ("Feb 2024", "Su Mo Tu"): they are recovered from `time.date`; long names need `Intl` (see "needed").
- Range: with a whole range picked, a press starts a new one (day-picker moves the nearer end). A second press before the first swaps the ends. No `min`/`max` nights, no `excludeDisabled`.
- Single: a press on the picked day unpicks it (day-picker's default, no `required`).
- `disabled` takes a list of dates plus `disabledWeekdays` and `min`/`max`; not day-picker's matcher functions or `{before, after}` objects.
- No Shift+PageUp/PageDown (a year): `key` hands over the key's name only. In right-to-left pages ArrowLeft / ArrowRight are not swapped (a component cannot read the direction).
- No `modifiers` / custom day content, no week numbers, no `fixedWeeks`, no `timeZone`, no `locale` prop (the browser's is used), no `captionLayout="dropdown-months"` / `"dropdown-years"`.
- Today is read from the browser's clock when the calendar is built.

## Card

    Card title="Names" description="Who is here"   one line, as before
      text "…"
    Card size="sm"
      CardHeader
        CardTitle "Login"
        CardDescription "Enter your email."
        CardAction
          Button "Sign up" variant="link"
      CardContent
        …
      CardFooter
        Button "Login"

- `Card title= description= size=`: size "default" (padded 24) | "sm" (16).
- `CardHeader` (title and description at the start, the action at the far side), `CardTitle`,
  `CardDescription`, `CardAction`, `CardContent`, `CardFooter`.

Differs: nothing of note; `size` is on the Card only (its parts do not shrink their text).

## Carousel

    state car: json = {}
    Carousel api=car loop=true                      orientation="vertical"
      CarouselContent api=car                       height=200 for a vertical one
        for p in photos key=p.id
          CarouselItem basis="1/3" api=car
            image p.src …
      CarouselPrevious api=car
      CarouselNext api=car
    text `Slide ${(car.index ?? 0) + 1} of ${car.pages ?? 0}`
    Button "The last" press={car.index = car.pages - 1}

- `Carousel api= orientation= loop=`: "horizontal" | "vertical". role=region, described as a carousel
  (give it an `aria-label`). While the keyboard is in it, the arrow keys turn it (ArrowUp and ArrowDown a
  vertical one), and Home and End go to its ends. Keys typed in a field inside are the field's. `loop`:
  past the end is the start.
- `CarouselContent api=`: the strip. It follows a finger, a mouse or a pen, can be caught as it glides, and
  comes to rest on a screenful: the next one when flicked (or drawn 40 pixels by a mouse), else the nearest. Past an end it gives way by a
  third. A finger the other way scrolls the page. Two fingers along it on a trackpad turn it one.
- `CarouselItem basis= api=`: "100%" (as it comes), "50%", "1/3"… and it may change (`basis=(screen.phone ?
  "100%" : "1/3")`). Slides are 16px apart. Links, buttons and fields inside are pressed as ever; what
  follows the pointer itself (a chart, a canvas) keeps its drags.
- `CarouselPrevious api=`, `CarouselNext api=`: disabled at the ends unless `loop`.
- **`car.index`** is which screenful, from 0 (which slide, when one is in view at a time). Read it: it
  changes once, when a finger lets go (to where the strip is going) or a key or a button turns it. Set it:
  the strip glides there. Past an end it is brought to that end (with `loop`, round: `car.index + 1` at
  the last is the first); what is no number is 0. `state car: json = {index: 2}` opens there, at once. Set
  in the action that adds the slide, it goes to the new slide.
- `car.progress` is the same while nothing moves; under a finger it follows (1.4 is on the way from the second
  to the third), for dots that follow. `car.pages`, `car.count` (the slides) are there to read.
- **What keeps its place.** Where the strip stands is written in percent of itself, so a window that is
  resized or turned, and a carousel that was put away and shown, stand on the same slide, with nothing
  measured. A slide that comes or goes before the one shown moves the index and not the picture, under a
  finger too; when the one shown goes, what came after it stands there. The slides put in another order: the
  same one stays in front. The index follows in each case.
- **Several in view.** A turn moves a screenful, and the last one stands at the end of the strip (of seven by
  three: 1-3, 4-6, 5-7). "Current" is then every slide wholly in view. A slide that shows in part (a
  `basis="75%"`) is not.
- **The keyboard and screen readers** reach only the slides that are current: the others are `inert` (seen
  as they are drawn by, not reached, not pressed). When the slide the keyboard is in is turned away, the
  carousel itself has it. A slide is named by its place ("2 / 5"); say an `aria-label` for another name.
- In a page read from right to left the strip runs from the right, and the keys, the buttons and the finger
  with it. With less motion wanted it goes at once.

Differs (Embla): the parts share `api=` for want of context (it is also what `setApi` gives in the
original). A turn moves a screenful, not one slide, when several show at once. `loop` goes back to the
start rather than running on for ever. No plugins (autoplay), no `opts`. A CarouselItem with no `api=` is
counted by the room it takes, and is reached by Tab wherever it is.

Why it is moved by `translate` and not by scrolling. A scroller gives momentum and snapping for nothing, and
`scroll=` with `el.scrollLeft` and `el.scrollTo` would do to read and set one. But where a scroller stands
is then the browser's: it moves it when the window turns, when slides come and go, when it has been put away,
and says so in the same event as a finger does, later, in pixels of a size that may have changed. Here where it
stands *is* the index, and there is nothing to tell apart. What is lost: the browser's find-in-page does not
reach a slide out of view (it is `inert`), and a strip does not coast past the next screenful.

## Chart

The charts are their own page now: **[charts.md](../charts.md)** (a component
for each kind people use, `Chart` with marks written as children, large data,
zoom and brush, the keyboard, theming). They are drawn on a canvas from the
plot battery's numbers (`kit/charts.mote`, `runtime/page/chart.mote`).

The six that were here take the props they took, and are drawn that way now:

    BarChart config=cfg data=rows x="month"              orientation="vertical" | "horizontal" · stacked · labels
    LineChart config=cfg data=rows x="month"             curve="linear" | "smooth" | "step" · dots · labels
    AreaChart config=cfg data=rows x="month"             curve=… · stacked · gradient · dots
      all three: tooltip=false · indicator="dot" | "line" | "dashed" · legend · grid=false ·
      yAxis=false · xChars=3 (category labels cut to so many letters) · height=220 · label="…" (aria)
    PieChart config=cfg data=rows value="visitors" name="browser"
      donut · innerRadius=60 (percent of the radius) · labels · tooltip=false · indicator=… · legend ·
      size=250 (its largest width) · label="…". Children are written in the middle (a donut's centre label).
    RadarChart config=cfg data=rows x="month"            grid="polygon" | "circle" · dots · tooltip=false · indicator=… · legend · size · label
    RadialChart config=cfg data=rows value="visitors" name="browser"
      max=300 (a full turn; as it comes, the largest value) · innerRadius=30 · track=false · tooltip=false ·
      indicator=… · legend · size · label. Children are written in the middle.
    ChartCartesian kind="bar" | "line" | "area" …        what Bar, Line and Area share

`config`: `[{key, label, color}]`, one per series (bar, line, area, radar:
`key` is the rows' field) or one per row (pie, radial: `key` is the row's
name). `color` is any CSS colour, or `"chart-1"` … `"chart-8"`; left out, they
are taken in order, from `--chart-1` … `--chart-8` where the page sets them,
else the palette's own light and dark steps. What looks different from
before: [charts.md](../charts.md#the-older-charts).

These stay as parts for a chart of your own made of boxes and text:

    ChartContainer label="Visitors"                      a frame (role=group) for a chart and what goes with it
    ChartTooltip title="January" items=[{label, value, color}] indicator="dot"    the card alone; with x= y= (and flip) it floats there
    ChartLegend config=cfg                               the swatches and labels alone (role=list)
    ChartLayer svg=text color="…"                        one layer: a box in a colour, cut out by an SVG mask
    ChartDataTable caption="…" head=[…] rows=[[…]]       the table a screen reader is given (takes no room)

## Checkbox

    Checkbox "I agree" checked=ok
    Checkbox checked=all indeterminate=(some && !all) invalid=wrong disabled=busy
      text "Select all"

- `checked` (written back), `disabled`, `indeterminate` (a dash, while not checked), `invalid` (the
  danger colour and `aria-invalid`). The label is its children.
- It is the browser's checkbox with the kit's drawing (16px box, 4px corners, a tick): Space toggles,
  a press on the label toggles, forms and readers see a checkbox.

Differs: `aria-invalid` is the `invalid` prop (an attribute written on a component goes to its first
element, the label). `indeterminate` is drawn and said as `aria-checked="mixed"`, but the input's own
`indeterminate` property cannot be set from Mote.

## Collapsible

    state more = false
    Collapsible open=more
      CollapsibleTrigger open=more
        icon "chevrons-up-down"
      CollapsibleContent open=more
        text "…"

- `Collapsible open=` (a column, `data-state`), `CollapsibleTrigger open= disabled=` (a bare button with
  `aria-expanded`; it flips the flag), `CollapsibleContent open=` (its height runs open and shut; closed,
  it is `inert`).

Differs: each part is given the flag. Any Button may flip it instead of the trigger (`press={more = !more}`).

## Combobox

A button that opens a list with a field to narrow it.

    Combobox value=city options=["Lisbon", "London"] placeholder="A city…"          as before
    Combobox value=fw items=[{value: "next", label: "Next.js"}, …] showClear=true autoHighlight=true
    Combobox value=zone items=[{label: "Europe", items: [{value: "lon", label: "London"}, "Paris"]}, …]
    Combobox multiple=true values=stack items=[…] placeholder="Select frameworks"

- `value` (written back) and `options` (words) are as they were. New: `items` (words, {value, label}, or
  groups {label, items}; `value` holds the item's value and the button shows its label), `multiple` with
  `values` (a `string[]`, written back; shown as chips), `showClear` (a × that empties it), `autoHighlight`
  (the first match is active as it is typed, so Enter picks it), `disabled`, `searchPlaceholder`, `empty`
  (the words of the empty line; "Nothing by that name." if not said).
- Parts, used by `Combobox` itself and there by name: `ComboboxItem label= selected= active= press=`,
  `ComboboxGroup label=`, `ComboboxLabel`, `ComboboxSeparator`, `ComboboxEmpty`, `ComboboxChips`,
  `ComboboxChip label= remove=`.
- Keyboard: Enter / Space on the button opens it and the keyboard goes to the field; type to narrow;
  ArrowDown / ArrowUp move the active option (round the ends; kept in view); Enter picks it (with `multiple`
  it adds or drops it and the list stays open); Backspace in an empty field drops the last chip; Escape closes.
- Styles and `id` written on it now go on the box around the button (it was the button): the button
  (`role=combobox`) fills that box, and the list is still its next sibling.

What differs from shadcn (Base UI):
- It is driven by data (`items`), not composed from parts: there is no `ComboboxInput`, `ComboboxContent`,
  `ComboboxList`, `ComboboxTrigger`, `ComboboxValue`, `ComboboxCollection`, `ComboboxChipsInput` to write,
  and an item cannot hold custom markup (no context between parts to carry the filter and the active item).
- The field is inside the list, under a button (shadcn's older popover + command look), not the trigger itself.
- The choices are drawn only while in view ([long lists](../markup.md#long-lists)): a list of thousands of
  cities opens and filters as fast as one of ten; the arrows move through all of them, each brought into view.
- Filtering is "contains", without regard to case; no `filter`, `itemToStringValue`, `onInputValueChange`.

## Command

A list found by typing, ranked as cmdk ranks it. The parts share one value the page holds.

    state c: json = {}
    Command
      CommandInput nav=c placeholder="Type a command or search…"
      CommandList
        CommandEmpty "No results found." nav=c
        CommandGroup nav=c heading="Suggestions"
          CommandItem nav=c value="Calendar" group="Suggestions" select={go("/calendar")}
            icon "calendar"
            text "Calendar"
          CommandItem "Calculator" nav=c value="Calculator" group="Suggestions" disabled=true
        CommandSeparator nav=c
        CommandGroup nav=c heading="Settings"
          CommandItem nav=c value="Profile" keywords=["account", "user"] group="Settings" select={…}
            text "Profile"
            CommandShortcut "⌘P"
    CommandDialog open=palette          the same in a modal dialog; no `Command` inside it
      CommandInput nav=p
      CommandList
        …

- `Command`: the frame. `CommandDialog open= width=`: a modal dialog holding a `Command`; Escape and a press
  outside close it, `open` is written back.
- `CommandInput nav= placeholder=`: the field. `c.q` is what is typed (the page may read or set it).
- `CommandList`: scrolls (300px at most; `max-height=` falls through).
- `CommandEmpty nav=`: shown when something is typed and nothing matches.
- `CommandGroup nav= heading=`: hidden when none of its items match.
- `CommandItem nav= value= keywords= group= disabled= select=`: `value` is what typing looks for, `keywords`
  other words for it; `group` is its group's `heading`. Write `select` as a block: `select={run("x")}`.
- `CommandSeparator nav=` (hidden while something is typed, as cmdk's; without `nav` it always shows),
  `CommandShortcut`.
- `CommandItems nav= items= select=`: a long list of commands given as data, `[{value, label?, keywords?,
  disabled?}]`, ranked with the rest and drawn only while in view ([long lists](../markup.md#long-lists)):
  thousands cost what a screenful does. `select` is told the item: `select=run` with `action run(it:
  json)`. Its items are in no group and hold words only.
- Ranking: the whole value; then a match at its start; at the start of a word; inside a word; the first
  letters of its words; its letters in order, the closer the better. A keyword's match counts nine tenths.
  Items are ordered within their group, and groups by their best item.
- Keyboard (in the field): ArrowDown / ArrowUp across groups (round the ends, past disabled items), Home /
  End, Enter runs the active item's `select`. The list scrolls to keep the active item in view. The first
  item is active to begin with, and the best match after each key.

What differs from shadcn (cmdk):
- No context: `nav=` on the input, groups, items and the empty line; an item names its group (`group=`).
- cmdk's scoring is rebuilt as the tiers above, not copied; the order within a tier may differ from cmdk's.
- Each `CommandItem` is drawn to be ranked (it registers itself, and the order is CSS `order`): a few hundred
  are fine; for more, `CommandItems` (above), which ranks the data and draws what shows.
- `shouldFilter`, `filter`, `loop`, `onValueChange`, `CommandLoading` are left out. `value` is required
  (cmdk can take it from the item's text; a component here cannot read its children).
- A shortcut such as ⌘K is the page's to wire, and `key=` hands over the key's name only (no ⌘ / Ctrl flag,
  and only while the keyboard is inside the element that listens). What works today: keep whether ⌘ / Ctrl
  is down from `key` and `keyup`, on an element the keyboard is inside:

      state mod = false
      column key=down keyup=lift
      action down(k: string)
        if k == "Meta" || k == "Control"
          mod = true
        else if k == "k" && mod
          palette = true
          mod = false
      action lift(k: string)
        if k == "Meta" || k == "Control"
          mod = false

  The browser's own use of the shortcut cannot be stopped (Ctrl+K in some browsers goes to the address bar).
- An item that goes away stays in the list of items (as in the menus): hide with `disabled=`, or keep them fixed.

## Context Menu

The same menu, opened at the pointer by the other mouse button (or a long press) on the element it is
written under. Every part is its Dropdown Menu twin under the Context name, with the same props.

    state m: json = {}
    view height=150 border="1px dashed"
      text "Right click here"
      ContextMenu nav=m
        ContextMenuContent width=208
          ContextMenuItem nav=m label="Back" inset=true press=back
            text "Back"
            ContextMenuShortcut "⌘["
          ContextMenuSeparator
          ContextMenuCheckboxItem "Show Bookmarks" nav=m label="Show Bookmarks" checked=bookmarks
          ContextMenuLabel "People" inset=true
          ContextMenuRadioGroup
            ContextMenuRadioItem "Pedro Duarte" nav=m label="Pedro Duarte" value="pedro" group=person
          ContextMenuSub
            ContextMenuSubTrigger "More Tools" nav=m sub=s label="More Tools" inset=true
            ContextMenuSubContent nav=m sub=s
              ContextMenuItem "Delete" nav=s label="Delete" variant="destructive" press=…

- Parts: `ContextMenu nav=`, `ContextMenuContent`, `ContextMenuGroup`, `ContextMenuItem` (variant
  "destructive", inset), `ContextMenuCheckboxItem`, `ContextMenuRadioGroup`, `ContextMenuRadioItem`,
  `ContextMenuLabel`, `ContextMenuSeparator`, `ContextMenuShortcut`, `ContextMenuSub`,
  `ContextMenuSubTrigger`, `ContextMenuSubContent`. Keyboard as the Dropdown Menu's.

What differs: no `ContextMenuTrigger` (the element it is written under is the area); the rest as above.
`ContextMenu` adds one empty, sizeless element to the area (it is how the menu is closed after Enter).

## Data Table

    DataTable columns=cols rows=payments
    DataTable columns=cols rows=payments filter=["email"] filterPlaceholder="Filter emails…" viewOptions=true selectable=true selected=ids pageSize=10 pageSizes=[10, 20, 50] rowAction=did
    DataTable columns=cols rows=people pagination=false height="320px" multiSort=true empty="No people yet."

    DataTableColumnHeader title="Email" column="email" sort=sort sortable=true      sort: the page's [{key, dir}]
    DataTableViewOptions columns=cols hidden=hidden                                  hidden: the page's list of keys
    DataTablePagination page=page pageSize=size total=rows.length selected=ids.length

`DataTable` is the whole table and keeps its own sort, hidden columns, filter text and page; the three parts are what it is made of, and can be used alone over the page's own state (there is no `table` object to share: each part takes the state it changes as props, written back).

A column is `{key, header, type, sortable, align, width, hideable}`:

| field | words | |
|---|---|---|
| `key` | | the row's field |
| `header` | | the heading (the key if left out) |
| `type` | `"text"` (as it comes) · `"number"` · `"badge"` · `"date"` · `"actions"` | number: set to the end, tabular figures, grouped as the reader's place writes them; with `format: "currency"` (and `currency: "EUR"`, USD if not said) as money. badge: a `Badge`, its variant from `variants: {failed: "destructive"}` (else outline). date: a "YYYY-MM-DD…" string shown as "Mar 14, 2025" (sorted by the string). actions: a "…" button opening a `Menu` of `actions: [{label, value, variant: "destructive"}]`; an item calls `rowAction` with `{action, row}` |
| `sortable` | bool | the heading becomes a button |
| `align` | `"left"` · `"center"` · `"right"` | logical: left is the start (numbers are right unless said) |
| `width` | a CSS width, `"140px"` | |
| `hideable` | `false` keeps it out of the Columns menu | |

| prop | | |
|---|---|---|
| `rows` | json | a list of records |
| `rowKey` | | the field that tells rows apart (`"id"` if not said) |
| `filter` | a list of keys | shows the filter box; it searches those columns, any case |
| `filterPlaceholder` | | |
| `viewOptions` | bool | shows the Columns button |
| `selectable` | bool | a box per row and one in the header |
| `selected` | a list of row keys | written back (kept inside if left out) |
| `pageSize` `pageSizes` | 10, [10, 20, 30, 40, 50] | |
| `pagination` | `false` shows every row | |
| `multiSort` | bool | every press on a heading adds to the sort |
| `height` | a CSS length | the most the table's box grows to; the rows scroll under the header, which stays |
| `empty` | | the words when there are no rows ("No results.") |
| `caption` | | a table caption |
| `rowAction` | a handler | `action did(e: json)` gets `{action, row}` |

Behaviour:
- Sort: a press on a heading sorts ascending, again descending, again not at all; `aria-sort` on the `th`, an arrow in the button (up, down, or the two chevrons). Numbers sort as numbers, the rest as text in the reader's order. Shift held while pressing adds the column to the sort instead of replacing it (see below); each heading then shows its place in the order.
- Filter, sort, then pages: the filter and the sort work on every row, not the page's.
- Select: the header box ticks or unticks the rows of the page, and is `aria-checked="mixed"` when only some are; with a page all ticked and more rows elsewhere a line offers "Select all N rows" (and then "Clear selection"). Ticked rows are `aria-selected`.
- Pages: rows per page, "Page x of y", first / previous / next / last, disabled at the ends. Changing the size or the filter goes to page 1.
- The table scrolls sideways inside its own box on a narrow screen.
- Rows are drawn only while in view ([long lists](../markup.md#long-lists)): with `pagination=false` a table of 100,000 rows draws the thirty that show, with `height` in its own box, without it as the window scrolls. A page of rows (64 or fewer) is drawn whole, as before. Rows say `aria-rowindex`, the table `aria-rowcount` (the head row and the rows drawn or not).

What differs from shadcn (a guide over TanStack Table):
- Cells are drawn by column `type`, not by a `cell` render function: there is no way to hand a table a component per column. For anything else, build the table from the parts.
- `DataTableColumnHeader` is a button that cycles the sort, not a dropdown with Asc / Desc / Hide (hiding is in `DataTableViewOptions`).
- Shift for multi-sort is heard through `key` / `keyup` on the table, so it is known only while the keyboard is inside the table (after a first press on a heading, say); `multiSort=true` makes every press add instead.
- One filter box over the named columns; no per-column or faceted filters, no column pinning, resizing, reordering or row expanding, no server-side (manual) sorting or pages. (Rows are virtual; columns are not: a grid of hundreds of columns is a table of your own with `for … virtual` across its rows, [long lists](../markup.md#tables-and-wide-grids).)
- `aria-rowcount` is the head row and the rows of the page, which the table holds (it was the filtered count before).
- The checkboxes are `DataTableCheck checked="true" | "false" | "mixed" press=…` (a small part of its own, since the header box has three states and is not toggled by itself).

## Date Picker

    DatePicker value=day                                      a button showing the date; opens a Calendar under it
    DatePicker value=born placeholder="Select date" captionLayout="dropdown" fromYear=1950 toYear=2026
    DatePicker value=day presets=[{label: "Tomorrow", days: 1}, {label: "New Year", value: "2030-01-01"}]
    DateRangePicker value=stay                                {from, to}; two months
    DateRangePicker value=stay numberOfMonths=1 presets=[{label: "Last 7 days", days: -7}, {label: "Q1", from: "2025-01-01", to: "2025-03-31"}]
    DatePickerInput value=day placeholder="June 12, 2025"     a field that reads typed dates, with a calendar button

There is no Popover / PopoverTrigger / PopoverContent to write: each is the trigger and its popover in one (the kit's idiom: the popover is written under what opens it). What is not a prop (id, width, …) goes on the button (on the row, for `DatePickerInput`).

| prop | on | |
|---|---|---|
| `value` | all | written back: a date string, or `{from, to}` for the range |
| `placeholder` | all | shown while empty |
| `presets` | DatePicker, DateRangePicker | buttons under the calendar. A date: `{label, value}` or `{label, days}` (from today). A range: `{label, from, to}` or `{label, days}` (negative: the last n days up to today; positive: today and the next n) |
| `captionLayout` `weekStartsOn` `min` `max` `disabled` `disabledWeekdays` | all | handed to the Calendar |
| `fromYear` `toYear` | DatePicker | for `captionLayout="dropdown"` |
| `numberOfMonths` | DateRangePicker | 2 unless said |
| `off` | all | disabled (`disabled` is the Calendar's list of days) |
| `change` | all | called with the new value |

Behaviour: a press opens it with the keyboard on the picked day (or today); picking a day closes `DatePicker` and `DatePickerInput`; `DateRangePicker` stays open until a press outside or Escape (a preset closes it). The button shows "Jun 12, 2025" (the reader's month name; a range as "Jan 1, 2025 – Mar 31, 2025").

`DatePickerInput` reads, as it is typed: `2025-06-12`, `6/12/2025` and `6-12-25` (month first), `June 12, 2025`, `Jun 12th 2025`, `12 June 2025`, month names in English or the reader's own short form, and `today` / `tomorrow` / `yesterday`. A date writes `value`; anything else sets `aria-invalid="true"` (a red border) and leaves `value` as it was; an empty field writes "". Leaving the field rewrites a good date in the shown form.

What differs from shadcn:
- shadcn's date pickers are recipes (Popover + Calendar + Button, date-fns to format); here they are three components.
- The shown form is fixed ("Jun 12, 2025", month first): no date-fns `format` strings.
- Numeric dates are read month first; there is no natural-language reading beyond the three words above (shadcn's example uses chrono-node), and no time picker.
- Because the field is read as it is typed, a longer date passes through shorter ones ("2023-02-2" is 2 February on the way to the 29th).

## Dialog

    Dialog open=asking title="Save?" description="…"     one line, as before (a cross, then the children)
    Dialog open=editing width=440
      DialogContent showCloseButton=false
        DialogHeader
          DialogTitle "Edit profile"
          DialogDescription "Save when you are done."
        Input value=name
        DialogFooter
          DialogClose "Cancel"
          DialogClose "Save" variant="default" press=save

- `Dialog open= title= description= width=`: the browser's modal dialog. Escape and a click outside
  close it; `open` is written back. With neither title nor description it draws only its children.
- `DialogContent showCloseButton=`: the cross at the far top corner (true as it comes).
- `DialogHeader`, `DialogTitle`, `DialogDescription`, `DialogFooter`.
- `DialogClose variant= size= press=`: a kit Button (outline as it comes) that closes the dialog after
  its `press`.

Differs: no `DialogTrigger` (it opens by `open=flag`). `DialogClose` is itself the button rather than a
wrapper round one. `Dialog` is both Root and the window; `DialogContent` is what is laid out inside it.

## Direction

    DirectionProvider dir="rtl"
      …

- `dir`: "ltr" | "rtl", set on a box around its children. The components of this file lay out by start
  and end (logical properties), so alerts, cards, button groups, checkboxes, menus and tables follow.

Differs: there is no `useDirection`; a component cannot read the direction, so the few things that are
mirrored by script in the original are not: ArrowLeft / ArrowRight in menus and the calendar, the
breadcrumb's chevron.

## Drawer

    state open = false
    Drawer open=open direction="bottom"            snapPoints=[0.45, "600px", 1] · snap=at · handle=false
      DrawerHeader
        DrawerTitle "Move goal"
        DrawerDescription "Set your daily goal."
      DrawerContent
        …
      DrawerFooter
        Button "Submit" press=submit
        DrawerClose "Cancel"

- `Drawer open= direction= snapPoints= snap= handle=`: direction "bottom" | "top" | "left" | "right". A modal
  dialog that slides in from that edge. Escape and a click outside close it; `open` is written back.
  `snapPoints`: how much of it shows at each rest: a number is a fraction of it, a string a length
  (`[0.45, 1]`, `["320px", 1]`). It opens at the first. `snap`: which rest it is at, from 0, to read and to set.
- **Drawn.** A finger anywhere on it draws it: by its handle, its header, or its contents when they have been
  scrolled to their top (until then they scroll). A mouse draws it by the handle or the DrawerHeader, and
  chooses words in the rest. Buttons, links and fields in it are pressed as ever. It follows the finger, can
  be caught as it moves, and goes to the next rest (or closes) when it is flicked, or drawn 60 px;
  otherwise to the nearest.
- In a page that goes to the screen's edges it keeps clear of the notch and the bar.
- `DrawerContent` (scrolls if it is long), `DrawerHeader`, `DrawerTitle`, `DrawerDescription`,
  `DrawerFooter`, `DrawerClose variant= press=` (a kit Button that closes the modal one).

### A drawer that stays on the page

    state open = false
    column padding=16 padding-bottom="calc(64px + env(safe-area-inset-bottom, 0px))"
      …the page…
    Drawer modal=false snapPoints=["64px", 0.86] open=open label="Parts"       snap=at for which rest
      DrawerHeader
        row justify-content=space-between align-items=center
          DrawerTitle "Parts"
          Button "Add" press=add
      DrawerContent
        for p in parts key=p.id
          …

- `modal=false`: not a dialog. It is on the page for as long as it is written there, at the foot of the window
  (`position=fixed`: write it at the end of the page, not in something with a `transform`, a `filter` or
  `glass`, which what is fixed stands in instead of the window), and the page behind it is neither covered nor
  inert. It is a `role=region` named by `label=` (or an `aria-label` of its own).
- **`snapPoints`**: the first is its **peek**, what always shows; the others where it opens to. A string is a
  length (`"64px"`, `"4rem"`), a number a fraction of the window. Unsaid: `["64px", 0.86]`. The
  peek must have room for the header. In a page that goes to the screen's edges
  ([`edges=cover`](../markup.md#the-screens-edges)) the sheet stands above the phone's bar, so that
  much shows above it, with its ground going on under the bar, and it goes no higher than the notch.
- **`open`** is whether it is above its peek: read it, or set it (true goes to the second snap point, or to
  `snap` if that says a higher one). **`snap`** is which of the snap points it is at, 0 being the peek: read it,
  or set it (past the last is the last). Say either or both; they keep in step.
- **The header comes first, beside the DrawerContent and not in it**: it is what shows at the peek. A press
  on it opens the sheet, and shuts it again; buttons in it are pressed themselves. For the keyboard and for a
  screen reader it is the handle that opens it: a real button, named by `label`, with `aria-expanded`
  (`handle=false` draws none; the button is there all the same, and shows when it has the keyboard).
- **Drawn** as above, and to the peek by a finger down from the top of its list. It goes no lower than its peek.
- **Escape** takes it to its peek when the keyboard is in it (it is, once it was opened by a press), unless
  a popover or a dialog in it takes the key first. Elsewhere Escape is the page's.
- **At the peek** what is below the header is out of the Tab order and not told to a screen reader. If the
  keyboard was in it as it shut, the handle has it.
- Its contents are laid out for what shows: at a middle rest the list ends at the foot of the window.
- **Turned or resized** it stands at the same rest: nothing of it is measured but while it is drawn.
  **A keyboard on the screen** stands over the foot of the window, and so over the peek; the browser brings the
  field being typed in into view, and the DrawerContent grows by the keyboard's height
  ([`screen.keyboard`](../markup.md#conditional-styles)), so that its end can be scrolled up from under it.
- **Leave it room**: what is last on the page is behind the peek unless the page has as much padding at its end
  (the `padding-bottom` above).
- Styles written on it go on the sheet: `max-width=480 margin="0 auto"` for one that is not the width of
  a wide window. `modal` is what it was when it was made.

Differs (vaul): no `DrawerTrigger`. Left and right drawers have a slim handle on their inner edge. The page
behind is not scaled back (`shouldScaleBackground`): nothing in a component can reach the page around it.
Flicked hard it goes one rest on, not several.

## Dropdown Menu

A menu written under the element that opens it (no Trigger part, no `asChild`). Its parts share one value
the page holds, given to the menu and to every item as `nav=`; a submenu has a value of its own.

    state m: json = {}
    state s: json = {}
    Button "Open"
      DropdownMenu nav=m                      align="end" puts its right edge on the button's
        DropdownMenuContent width=224         the list (role=menu); styles fall through
          DropdownMenuLabel "My Account"      inset=true
          DropdownMenuGroup
            DropdownMenuItem nav=m label="Profile" press=profile
              text "Profile"
              DropdownMenuShortcut "⇧⌘P"
            DropdownMenuItem "Delete" nav=m label="Delete" variant="destructive" inset=true disabled=false press=…
          DropdownMenuSeparator
          DropdownMenuCheckboxItem "Status Bar" nav=m label="Status Bar" checked=bar
          DropdownMenuRadioGroup
            DropdownMenuRadioItem "Top" nav=m label="Top" value="top" group=position
          DropdownMenuSub
            DropdownMenuSubTrigger "Invite users" nav=m sub=s label="Invite users"
            DropdownMenuSubContent nav=m sub=s
              DropdownMenuItem "Email" nav=s label="Email" press=…

- `DropdownMenu nav= align=`: align "start" (as it comes) | "end". `m.open` is whether it is open (the page may set it).
- `DropdownMenuItem nav= label= press= disabled= variant= inset=`: variant "default" | "destructive".
  `label` is what typing a letter looks for (Base UI's `label`); what is shown is its children.
- `DropdownMenuCheckboxItem nav= checked= label= disabled=`: `checked` is written back; the menu stays open.
- `DropdownMenuRadioItem nav= value= group= label= disabled=`: `group` is the page's value for the whole
  group, written back with this item's `value`; the menu stays open. `DropdownMenuRadioGroup` only groups them.
- `DropdownMenuSubTrigger nav= sub= label= disabled= inset=`, `DropdownMenuSubContent nav= sub=`: `nav` is the
  menu they are in, `sub` the submenu's own value; the items inside take `nav=` the submenu's value.
- `DropdownMenuLabel inset=`, `DropdownMenuSeparator`, `DropdownMenuShortcut`, `DropdownMenuGroup`, `DropdownMenuContent`.
- Keyboard: ArrowDown / ArrowUp (round the ends, past disabled items), Home / End, letters (the same letter
  again goes on to the next; several letters typed quickly are a prefix), Enter or Space runs the item,
  ArrowRight opens a submenu, ArrowLeft closes it, Escape or Tab closes the menu. The page does not scroll.
- The older `Menu`, `MenuItem`, `MenuLabel`, `MenuSeparator` are unchanged (pointer and Tab only).

What differs from shadcn (Base UI):
- No `DropdownMenuTrigger`: write the menu under the element that opens it.
- No context between parts: every item (and submenu part) is given `nav=`; the radio group's value is given
  to each radio item as `group=`; `label=` repeats the item's words for typeahead (a component cannot read
  its children).
- The keyboard is kept in a hidden field inside the menu (`aria-activedescendant` names the active item);
  the items are not focused themselves. This is what stops the arrow keys scrolling the page.
- `side`, `sideOffset`, `alignOffset` are left out (a popover's `placement` cannot be a prop); only `align`.
- Escape closes the whole menu, also from inside a submenu. ArrowLeft / ArrowRight are not mirrored in RTL
  (the layout is: logical padding and margins).
- An item that goes away (under an `if` or a changing `for`) stays in the menu's list of items: keep the
  items of a menu fixed, and use `disabled=` for the ones that come and go.
- Items are told `disabled` when built; a `disabled` that changes later is drawn, but the arrow keys still
  stop on it. Opened by a press, no item is active until a key is pressed.

## What these needed from outside their files

None of it was changed; each has the workaround named, and would be simpler with the thing itself.

| Needed | For | Done instead |
|---|---|---|
| SVG elements (`svg path rect circle line polygon`) | ChartLayer | a box in a colour with an SVG data-URI `mask`, written in percentages (the charts themselves are drawn on a canvas now: [charts.md](../charts.md)) |
| `--name=value` on an element (custom properties can be read, not set) | a ButtonGroup telling its Buttons | ButtonGroup sets `line-height` (0 / 1px) and Button measures its corners and borders in `lh` |
| `preventDefault` on `key`, and its modifiers (shift, meta) | menus, Command, Combobox, Calendar, Data Table's shift-sort, ⌘K | the keyboard is kept in a field (arrows there do not scroll the page), or under `overflow=auto overscroll-behavior=contain`; Enter and Space act on key-up; Shift and Meta are tracked from `key` / `keyup`; ⌘K is heard only while the keyboard is inside the listening element |
| `new Date`, `Intl` | Calendar, date pickers | the date sums are written out; month and weekday names come from comparing `time.date` of two days, so they are the short ones |
| `encodeURIComponent` | ChartLayer | `%` and `#` replaced by hand |
| the `indeterminate` property of a checkbox | Checkbox, Data Table | drawn, and said as `aria-checked="mixed"` |
| a prop that is a function returning a value | Calendar matchers, Data Table cell renderers | column types, lists of days |
| fns shared between kit components | date sums (five components) | repeated inside each |
| `placement=` as a prop or a computed value | DropdownMenu `side`, Data Table's row menu | `align="end"` is two popovers under an `if` |
| `PS` (a popover's `open=`) for `on="context"` | ContextMenu closing from a key | a second, empty popover shown for a moment light-dismisses it |
| `th scope=` | Data Table's header cells | left out |

One thing in the runtime that the test steps round, and a page may meet:

- A context popover with rounded corners closes as the other mouse button is let go, the pointer being
  on its very corner and so outside its shape: ContextMenu sits 5px up and left of the pointer.
