Light themes
Dark themes

Make your own

Styles and behaviour

The system ships as three files and needs no framework and no build step.

Loading

HTML
<html lang="en" data-theme="light">
<link rel="stylesheet" href="tokens.css">
<link rel="stylesheet" href="components/bundle.css">
<script src="components/bundle.js" defer></script>

tokens.css declares every token as a custom property (--ink, --radius-card, --space-4) and a class per type style (.display, .body). bundle.css holds the tray- classes and loads after it. bundle.js is one classic script that assigns window.TrayUI, injects the icon sprite and wires up behaviours; it loads nothing from the network.

Switch themes by setting data-theme="dark" on <html>. Follow the system setting until the person chooses, then remember their choice.

Behaviours

A behaviour is attached with data-tray="name" on the element named below. Call TrayUI.init(root) after adding markup to the page. Most components need none: buttons, cards, fields, checkboxes, radios, switches, accordion, table and tabs-as-links are plain HTML and CSS.

data-trayOnDoes
togglea button with aria-pressedflips the pressed state
steppera button group with two data-step buttons and an <output>counts between data-min and data-max
otpthe row of one-character inputsadvances, steps back, takes a pasted code
slider<input type="range">fills the track, writes the value
counta textarea with maxlengthshows the character count
reveala button in a password groupshows and hides the password
selectthe anchor of a custom selectopens the list, sets the value
comboboxthe anchor of a comboboxfilters the list as you type
calendaran empty elementdraws a month grid; single date or range
datepickerthe anchor of a date fieldties a calendar to a trigger
tabsthe wrapper of a tablist and its panelsswitches panels, arrow keys
stripa tab strip that may overflowfades its end while it scrolls
menuthe anchor of a dropdown menuopens, arrow keys, check and radio items
menubara strip of menusmoves between menus
contextmenua region holding a menuopens it where the region is right-clicked
popoverthe anchor of a popoveropens a panel, moves focus in and back
hovercardthe anchor around a linkopens a preview on hover or focus
tooltipan anchor around one control, with data-tipnames the control on hover and focus
dialoga <dialog> (dialog, alert dialog, sheet, drawer)data-close buttons, closing on the veil (a press and a release both on it, so a selection dragged out does not close it)
opena button with data-targetopens that dialog
sidebar-togglea button with aria-controlscollapses the sidebar to a rail
sidebar-sheetthe tray-app__menu button, with aria-controlsopens that sidebar in a sheet on a small screen
commandthe command panelfilters and runs options
splita resizable pair of panesdrags the handle, arrow keys
carousela carouselprevious, next and the count
datatablethe wrapper of a tablefilter, sort, select, page
charta figure with data-chart JSONdraws the chart
scrollera message scrollerfollows new messages, offers "Latest"
reactiona reaction buttontoggles it and its count
morea "Show more" buttonopens a clamped bubble
questionnairethe questionnaire formone question at a time
copya button with data-targetcopies that text, or a field's value; says Copied or Copy failed on the button and through a status beside it
dismissa button inside a block with data-dismissablehides that block
sparkan element with data-pointsdraws a small trend line
uptimean element with data-days and data-incidentsdraws a bar per day
pricingthe wrapper of a billing-period switchshows the price of the chosen period
maskan input with data-maskgroups a card number, writes an expiry date
secretthe wrapper of a masked keyshows, hides and copies the key
taginputthe tray of a tag inputturns typed values into chips
dropzonethe tray of a file uploadtakes dropped or chosen files and lists them
checklistan onboarding checklistopens the next task, fills the progress
tourthe area a tour runs inshows one step at a time beside its target
feedbacka feedback formopens the follow-up, then the thanks
consenta cookie consent panelcloses it and reports the choice
noticesa notification panelmarks as read, counts the unread
filterbara filter barkeeps the chips and the menu items in step

Events

Behaviours report with bubbling custom events on their own element: tray:change (a value, a selection, a page, a size), tray:select (a menu or command item), tray:open and tray:close (a floating panel), tray:complete (a one-time code, a questionnaire). The value is in event.detail.

Functions

FunctionUse
TrayUI.init(root)Wire up behaviours under root after adding markup.
TrayUI.chart(el, config)Draw a chart into a <figure class="tray-chart">. Returns { update(config) }.
TrayUI.calendar(el, options)Draw a calendar. Returns { value(), set(value) }.
TrayUI.toast(options)Show a toast. Returns { dismiss() }.
TrayUI.formatDate(value, locale)"14 Nov 2026", or a range.
TrayUI.icon(name, className)The markup of an icon.
TrayUI.register(name, fn)Add your own data-tray behaviour.
TrayUI.upgrade(selector, fn)Run fn once for every element that matches, with no data-tray of its own (the system gives every .tray-seg and .tray-tabs its sliding pill this way).

Motion

Things come in by CSS alone (@starting-style); the behaviours help them go away. A panel the behaviours close (a menu, a popover, a listbox, a tooltip, a hover card) is hidden with its exit transition; a dialog the behaviours close leaves first and closes when it has left, Escape included, also where the browser cannot keep it in the top layer while it leaves (there data-closing runs the exit first). A toast sinks out and is then taken away. Hiding or closing from your own script works as before, and the panel then goes away at once.

The pill of a segmented control follows its radios' change event: after setting a radio from script, dispatch new Event('change') on its .tray-seg. A strip of tabs or links follows aria-selected and aria-current by itself.

Naming

Classes are tray-block, tray-block__part, tray-block--variant. State is in attributes, never in classes: aria-pressed, aria-selected, aria-current, aria-invalid, aria-busy, open, hidden, disabled, and data- attributes for what ARIA has no word for. Local custom properties start with --tray-.

↑↓ to moveEnter to openEsc to close