# The kit, E to Z

shadcn/ui's components from Empty to Typography, as Mote's. They live in
`kit/more.mote` (new) and `kit/kit.mote` (the ones that were there, reworked:
what they took before they still take). The gallery is `examples/kit/more.mote`,
its test `tests/kit_more.real.mjs`.

## How parts are written in Mote

- **No triggers, no `asChild`, no `render`.** What floats is written under the
  element that opens it, as Menu and Popover always were. So there is no
  PopoverTrigger, HoverCardTrigger, TooltipTrigger, TooltipProvider,
  SheetTrigger, SelectTrigger-as-wrapper, NavigationMenuViewport: each
  component below says what stands in.
- **`of=`: the shared value.** A part cannot see the part around it. Where
  the original shares a value through context, each part that needs it takes
  it as `of=`: `TabsTrigger value="a" of=tab`, `TabsContent value="a" of=tab`,
  `RadioGroupItem value="a" of=plan`, `SelectItem value="a" of=fruit`,
  `ToggleGroupItem value="a" of=marks`, `MenubarRadioItem value="a" of=who`.
  A part writes `of` back when it is picked.
- **Short forms stay.** `Select value= options=`, `Radio value= options=`,
  `Tabs value= options=`, `Pagination page= pages=`, `Sheet open= title=`
  work as before, with the new look.
- **What is not a prop goes on the first element** (id, class, styles,
  events), as everywhere in the kit. `invalid` is a prop (it sets
  `aria-invalid` and the red look), because a component cannot read an
  attribute it was not given as a prop.
- **Hidden buttons with fixed ids** (`mote-menu-close`, `mote-menu-next`,
  `mote-menu-prev`, `mote-row-first`, `mote-row-last`, `mote-row-<letter>`,
  `mote-sub-trigger`, `mote-sheet-close`, `mote-sidebar-toggle`,
  `mote-sidebar-mobile`) are how an inner part reaches the outer one: do not
  use those ids. They exist only while the list, sheet or sidebar they
  belong to is open or on the page.

## Empty

    Empty
      EmptyHeader
        EmptyMedia variant="icon"          variant: default | icon
          icon "folder-code"
        EmptyTitle "No Projects Yet"
        EmptyDescription "You haven't created any projects yet."
      EmptyContent
        Button "Create Project"

`Empty` has a dashed edge with no colour: give it one (`border-color=line`)
or a fill (`background=card`), as the original's `border` / `bg-muted` classes.

## Field

    FieldSet
      FieldLegend "Profile" variant="legend"       variant: legend | label
      FieldDescription "…"
      FieldGroup
        Field orientation="vertical" invalid=bad   orientation: vertical | horizontal | responsive
          FieldLabel "Email" for="email"
          Input value=email id="email" invalid=bad
          FieldDescription "…"
          FieldError "Enter a valid email address."
        FieldSeparator "Or continue with"          (or bare: a line)
        Field orientation="horizontal"
          FieldContent
            FieldTitle "Newsletter"
            FieldDescription "…"
          Switch on=news

`FieldError errors=["…", "…"]` shows one message plain and several as a list.
`Field disabled=true` dims it. Differs: `responsive` turns at the phone
breakpoint (640px of the window), not at a container's width; `invalid` is
said on the Field and on the control (no `data-invalid` reaching inwards
except the label's colour).

## Hover Card

    link "@nextjs" href="…"
      HoverCard data-delay=100 data-close-delay=150
        text "The React Framework"
    Button "…"
      HoverCardContent side="top" align="start"     side: top | bottom | left | right · align: start | center | end

`HoverCard` and `HoverCardContent` are the same panel (a `popover on="hover"`).
There is no HoverCardTrigger. The delays are `data-delay` and
`data-close-delay`, in milliseconds (150 and 200 unless said).

## Input

    Input value=name placeholder="…" type="email" size="sm" invalid=bad disabled=off
    Input type="file" change=picked

size: sm (32) | default (36) | lg (40). `type="file"` is the browser's file
field under a face like the others (its name is shown once chosen; `change`
is given the path the browser reports); it takes no `value`. `value` may be
left out for a field the page does not follow.

## Input Group

    InputGroup
      InputGroupInput value=q placeholder="Search…"
      InputGroupAddon                                align: inline-start | inline-end | block-start | block-end
        icon "search"
      InputGroupAddon align="inline-end"
        InputGroupText "12 results"
        InputGroupButton "Search" variant="secondary" size="xs"
    InputGroup
      InputGroupTextarea value=note rows=3
      InputGroupAddon align="block-end"
        InputGroupButton "Send" variant="default" size="sm"

InputGroupButton: variant as Button's (ghost unless said), size xs | sm |
icon-xs | icon-sm. InputGroupInput and InputGroupTextarea take `invalid`.
The group draws the edge; the field is bare and, with the keyboard in it,
draws the ring around the whole group (so a group holds one field).

## Input OTP

    InputOTP value=code maxLength=6 pattern="digits" change=done      pattern: digits | alphanumeric | any
      InputOTPGroup
        InputOTPSlot index=0 value=code
        InputOTPSlot index=1 value=code
        InputOTPSlot index=2 value=code
      InputOTPSeparator
      InputOTPGroup
        InputOTPSlot index=3 value=code
        …

One real field lies over the boxes (`autocomplete="one-time-code"`, numeric
keyboard), so typing, Backspace, paste, the arrow keys, Home and End are the
browser's own. `value` is written back, filtered by `pattern`; `change` is
called with the code when it becomes complete. Each slot takes the code
(`value=`) to show its character. Differs: typing in the middle of a code
that is not full inserts rather than overwrites; `pattern` is one of three
words, not a regular expression.

## Item

    ItemGroup
      Item variant="outline" size="sm" href="/profile"     variant: default | outline | muted · size: default | sm | xs
        ItemHeader
        ItemMedia variant="icon"                           variant: default | icon | image
          icon "shield-alert"
        ItemContent
          ItemTitle "Security Alert"
          ItemDescription "New login detected."
        ItemActions
          Button "Review" size="sm"
        ItemFooter
      ItemSeparator

With `href` an Item is a link (instead of `asChild` around an `a`).

## Kbd, Label

    Kbd "⌘K"
    KbdGroup
      Kbd "Ctrl"
      Kbd "B"
    Label "Email" for="email"

## Menubar

    state menu = -1
    state share = false
    Menubar
      MenubarMenu label="File" index=0 count=2 open=menu
        MenubarItem press=newTab textValue="New Tab"
          text "New Tab"
          MenubarShortcut "⌘T"
        MenubarItem "Print" disabled=true
        MenubarSeparator
        MenubarSub
          MenubarSubTrigger "Share" open=share textValue="Share"
            MenubarSubContent open=share
              MenubarItem "Email link" press=mail
      MenubarMenu label="View" index=1 count=2 open=menu
        MenubarLabel "Appearance" inset=true
        MenubarCheckboxItem "Show Bookmarks" checked=bookmarks
        MenubarRadioGroup value=who
          MenubarRadioItem "Andy" value="andy" of=who
        MenubarGroup
          MenubarItem "Delete" variant="destructive" inset=true

The page holds which menu is open (`menu`, -1 for none), and each
MenubarMenu takes its place (`index`) and how many there are (`count`): that
is what lets the pointer, ArrowLeft and ArrowRight move between menus once
one is open. A MenubarMenu is the trigger and the content in one (`label` is
its name); `MenubarTrigger` and `MenubarContent` exist on their own for a
menu that is not in a bar (`MenubarTrigger "More"`, a `MenubarContent` under
it). A submenu's trigger and content share a bool the page holds.
Keys: ArrowDown/Up move (and wrap), Home goes to the first item, a letter to
the first item whose `textValue` begins with it, Enter and Space pick,
Escape closes, ArrowRight opens a submenu, ArrowLeft shuts it.
Differs: typeahead needs `textValue` on the item (a component cannot read
its own words) and matches one letter; End needs `last=true` on the last
item of a list (Select's short forms set it; a Menubar's items do not take
it); ArrowLeft/Right on a closed bar open the neighbour rather than only
moving the focus; a submenu stays open while the pointer goes to other items.

## Native Select

    NativeSelect value=status size="sm" invalid=bad disabled=off change=picked
      NativeSelectOption "Todo" value="todo"
      NativeSelectOptGroup label="Europe"
        NativeSelectOption "Greenwich" value="gmt"

Differs: Mote has no `optgroup` tag, so NativeSelectOptGroup is a line that
cannot be picked, followed by its options.

## Navigation Menu

    NavigationMenu
      NavigationMenuList
        NavigationMenuItem
          NavigationMenuTrigger "Getting started"
            NavigationMenuContent width=420
              NavigationMenuIndicator
              NavigationMenuLink href="/docs" active=true
                text "Introduction" font-weight=500
                text "Re-usable components." color=dim
        NavigationMenuItem
          NavigationMenuLink "Docs" href="/docs"

A panel opens while the pointer or the keyboard is on its trigger (a
`popover on="hover"`), and closes a moment after both have left.
Differs: each panel is its own floating box (there is no shared
NavigationMenuViewport that changes size between panels);
NavigationMenuIndicator is the small arrow on a panel's edge, written first
inside the content; a link with no `href` is a button.

## Pagination

    Pagination page=p pages=9                    the short form
    Pagination
      PaginationContent
        PaginationItem
          PaginationPrevious href="?p=1"         (or press=…, disabled=…)
        PaginationItem
          PaginationLink "2" isActive=true href="?p=2" size="icon"     size: icon | default
        PaginationItem
          PaginationEllipsis
        PaginationItem
          PaginationNext press=next

A link with no `href` is a button. Previous and Next drop their words on a
phone.

## Popover

    Button "Open"
      Popover side="top" align="start"           side: top | bottom | left | right · align: start | center | end
        PopoverHeader
          PopoverTitle "Dimensions"
          PopoverDescription "Set the dimensions for the layer."

No PopoverTrigger or PopoverContent: the Popover is the content, under what
opens it. With neither `side` nor `align` it sits as it always did (under,
in line with the start).

## Progress, Skeleton, Spinner, Separator

    Progress value=40                    of 100, or `max=`
    Skeleton width="60%" height="16px"
    Spinner size=16
    Separator                            orientation="vertical" (or the old `vertical`), decorative=true

Differs: Spinner has no `role="status"` (pages find the built-in toast by
that role).

## Radio Group

    RadioGroup value=plan orientation="vertical"       orientation: vertical | horizontal
      row gap=12 align-items=center
        RadioGroupItem value="free" of=plan id="free"
        Label "Free" for="free"
    Radio value=plan options=["free", "pro"]           the short form

RadioGroupItem is the circle alone, a real radio button drawn as a dot of
our own (`disabled`, `invalid`). The arrow keys move among a group's items
and pick, as the browser does for radio buttons.

## Resizable

    state left = 30
    ResizablePanelGroup orientation="horizontal"       orientation: horizontal | vertical
      ResizablePanel size=left minSize=15 maxSize=70 collapsible=true collapsedSize=0
        …
      ResizableHandle size=left withHandle=true
      ResizablePanel                                   (no size: it takes the room that is left)
        …

Sizes are percents of the group. The page holds the size of each panel that
can change; the panel takes it (`size=`) and so does the handle beside it,
which a drag or the arrow keys change (5 a press, or `step=`; Home and End
go to the limits). The panel keeps it within minSize and maxSize, and with
`collapsible` shuts to `collapsedSize` when let go under half of minSize. A
handle after the flexible panel sizes the panel that follows it:
`ResizableHandle size=right reverse=true`. Groups nest (a group inside a
panel). Differs: one panel of each group has no size and takes the rest
(sizes are not shared out among neighbours); `defaultSize=` is a fixed share
that no handle moves; sizes are numbers, not "25%".

## Scroll Area

    ScrollArea height=200 orientation="vertical"       orientation: vertical | horizontal | both
      …

Differs: the bars are the browser's own, thin; `ScrollBar orientation=` is
there for the name and draws nothing (a page cannot read how far a box has
scrolled, so it cannot draw a bar of its own).

## Select

    Select value=fruit options=["Apple", "Pear"]                         the short form
    Select value=city items=[{value: "lis", label: "Lisbon"}]            values with names
    Select value=fruit placeholder="Select a fruit" size="sm" width=180  rows written out   size: sm | default
      SelectGroup
        SelectLabel "Fruits"
        SelectItem "Apple" value="apple" of=fruit
        SelectItem "Pear" value="pear" of=fruit disabled=true
      SelectSeparator
      SelectItem "Leek" value="leek" of=fruit last=true
    SelectTrigger size="sm"                                               all its parts
      SelectValue value=fruit placeholder="…"
      SelectContent
        SelectItem "Apple" value="apple" of=fruit

`Select` is the trigger, the value and the content in one; its rows go under
it. It is a list of its own, not the browser's: a press, Enter or Space
opens it with the keyboard on the row that is picked; ArrowDown/Up move (and
wrap, over disabled rows), Home and End go to the ends, a letter to the
first row that begins with it (`textValue`, or the value), Enter, Space or a
press picks, Escape closes. `disabled`, `invalid`.
Differs: the list opens under the trigger (not laid over it with the picked
row aligned); typeahead matches one letter; End needs `last=true` on the
last row when rows are written out (the short forms set it); SelectValue
shows the value itself unless `items` gives it a label; the trigger says
`aria-haspopup="true"` and is not `role="combobox"`. The short form keeps a
hidden native select inside it, which scripts and forms can still set.
With `options` or `items` the rows are drawn only while in view ([long
lists](../markup.md#long-lists)): 64 or fewer are drawn whole, as before; a
longer list opens at its top, the arrows, Home and End go through all of
it, and a letter goes to the first drawn row that begins with it.

## Sheet

    Sheet open=menu title="Menu" side="left"             the short form   side: right | left | top | bottom
    SheetContent open=editing side="top"                 written out
      SheetHeader
        SheetTitle "Edit profile"
        SheetDescription "…"
      …
      SheetFooter
        Button "Save" press=save
        SheetClose
          Button "Close" variant="outline"

Written out, a sheet starts at SheetContent, which is the window and takes
`open` (there is no Sheet around it and no SheetTrigger: the page sets the
state). SheetClose closes the sheet on a press on anything inside it.

## Sidebar

    state open = true persist
    SidebarProvider open=open
      Sidebar open=open collapsible="icon" side="left" variant="sidebar"
        SidebarHeader
        SidebarContent
          SidebarGroup
            SidebarGroupLabel "Platform"
            SidebarGroupAction title="Add" press=add
            SidebarGroupContent
              SidebarMenu
                SidebarMenuItem
                  SidebarMenuButton isActive=true tooltip="Inbox" press=go size="default" variant="default"
                    icon "inbox" size=16
                    text "Inbox"
                  SidebarMenuAction title="More"
                  SidebarMenuBadge "24"
                  SidebarMenuSub
                    SidebarMenuSubItem
                      SidebarMenuSubButton "Drafts" href="/drafts" isActive=true size="sm"
                SidebarMenuItem
                  SidebarMenuSkeleton showIcon=true
          SidebarSeparator
        SidebarFooter
        SidebarRail
      SidebarInset
        SidebarTrigger

side: left | right. variant: sidebar | floating | inset. collapsible:
offcanvas | icon | none. SidebarMenuButton size: default | sm | lg, variant:
default | outline; with `href` it is a link. SidebarInput value= placeholder=.
The page holds `open` and gives it to the provider and the sidebar;
`persist` keeps it across visits. SidebarTrigger and a press or a drag on
SidebarRail toggle it; so do ⌘B and Ctrl+B. Down to its icons, the labels,
badges, actions, inner menus and the input fold away and a button's
`tooltip` shows beside it. On a phone the sidebar is a modal sheet that the
trigger opens (`Sidebar openMobile=flag` follows it, if the page wants to).
Differs: `open` goes to both SidebarProvider and Sidebar; `openMobile` is
the Sidebar's; SidebarInset takes `variant="inset"` when the Sidebar does;
SidebarRail takes `side="right"` on a right sidebar; ⌘B is heard once the
keyboard is somewhere inside the provider (after a press in it); a page with
several providers gives each SidebarTrigger and SidebarRail its own state
(`SidebarTrigger open=open2 openMobile=m2`); there is no `useSidebar`, no
cookie (`persist` is localStorage), and SidebarMenuButton's tooltip is words
only.

## Slider

    Slider value=volume min=0 max=100 step=1
    Slider values=range step=5                        a range: two numbers, two thumbs
    Slider value=temp orientation="vertical" height=160

A track and thumbs of our own over the browser's range fields (one a thumb,
kept for the keyboard and screen readers): a press or a drag on the track
moves the nearer thumb; the arrow keys, Home, End, PageUp and PageDown move
the one the keyboard is on. A range's thumbs do not cross. `disabled`;
`change` is called when a change is done: after each step by keyboard, and
when a drag ends (not on every move of it).
Differs: a single value is `value` (a number) and a range is `values`.

## Sonner

    state toasts: {id: string, title: string, type: string?, description: string?, action: string?, duration: number?}[] = []
    action saved
      toasts.push({id: uid(), type: "success", title: "Saved", description: "All changes are kept."})
    Toaster toasts=toasts position="bottom-right" press=undo

`toast("Saved")` is still built in for the simple case. For the rest the
page holds a list and adds to it; the Toaster shows it and takes each toast
off it when its time is up (`duration` on the toast or the Toaster, 4000),
when it is swiped away, or when its action button is pressed (`press` is
then called with the toast's id). type: default | success | info | warning |
error | loading (a loading toast stays until the page changes its type, in
place: `t.type = "success"`). position: top-left | top-center | top-right |
bottom-left | bottom-center | bottom-right. `expand=true` keeps the pile
spread; `richColors=true` tints by type; `closeButton=true` gives each a ✕.
The newest is in front with up to three behind it; under the pointer the
pile spreads out and the clocks stop.
Differs: components cannot expose functions, so there is no `toast.success()`
or `toast.promise()`: the page pushes records; titles and descriptions are
one line each (the pile's layout is worked out from that); a toast leaves
without an exit animation; it is not drawn over a modal dialog.

## Switch, Toggle, Toggle Group

    Switch on=wifi size="sm"                                   size: sm | default
    Toggle on=bold variant="outline" size="lg" title="Bold"    variant: default | outline · size: sm | default | lg
    Switch value=row.muted change={mute(row.id, it)}           driven: shows `value`, tells `change`, writes nothing
    Toggle value=row.pinned change={pin(row.id, it)}           (so with `Checkbox value= change=`; ../kit.md#driven-switches)
    ToggleGroup type="multiple" value=marks variant="outline" spacing=0
      ToggleGroupItem value="bold" of=marks variant="outline" title="Bold"
    ToggleGroup type="single" value=align
      ToggleGroupItem value="left" of=align

Single: `of` is the value that is on, or "". Multiple: `of` is a list.
spacing 0 (as it comes) joins the items into one; more sets them apart.
Differs: `variant` and `size` are said on each item as well as the group;
Tab moves between a group's items (no roving arrow keys).

## Table

    Table
      TableCaption "A list of your recent invoices."
      TableHeader
        TableRow
          TableHead "Invoice"
      TableBody
        TableRow selected=(picked == inv.id)
          TableCell inv.id
      TableFooter
        TableRow
          TableCell "Total" colspan=3

It scrolls sideways in the box it is given. Differs: TableCaption is a last
row across the table, not a `caption` (Mote has no `caption-side`). Its rows
are the page's: for a long table write `for inv in invoices key=inv.id
virtual` under `TableBody`, in a `Table` given a `height` and
`overflow=auto` ([long lists](../markup.md#tables-and-wide-grids)).

## Tabs

    Tabs value=tab options=["Account", "Password"]        the short form: the page shows what belongs to `tab`
    Tabs value=tab orientation="horizontal"               orientation: horizontal | vertical
      TabsList variant="line"                             variant: default | line
        TabsTrigger "Account" value="account" of=tab
        TabsTrigger "Password" value="password" of=tab disabled=true
      TabsContent value="account" of=tab
        …

The arrow keys move between the triggers and open the tab they land on (and
Home and End in the short form). Differs: every TabsContent is in the page
and only the open one is shown.

## Textarea

    Textarea value=bio rows=4 placeholder="…" invalid=bad disabled=off

## Tooltip

    Button "Save"
      Tooltip "Save changes" side="bottom" delay=400       side: top | bottom | left | right
    Button "Print"
      Tooltip
        TooltipContent
          text "Print"
          Kbd "⌘P"

No TooltipTrigger or TooltipProvider. Differs: no arrow; `align` is not
taken.

## Typography

    Typeset
      TypographyH1 "…"   TypographyH2   TypographyH3   TypographyH4
      TypographyLead "…"
      TypographyP
        text "Run "
        TypographyInlineCode "mote build"
      TypographyBlockquote "…"
      TypographyList
        li "…"
      TypographyTable
        thead
          TypographyTr
            TypographyTh "…"
        tbody
          TypographyTr even=true
            TypographyTd "…"
      TypographyLarge "…"   TypographySmall "…"   TypographyMuted "…"

Differs: Typeset sets the size, the leading and the room between its parts,
but it cannot style plain `h1`, `p` or `table` written inside it (Mote has
no rules that reach into children): use the Typography parts.
