Controls
The Solid registry's controls kit, the buttons, badges, tooltips and selects the views are built from, and how to use your own in their place.
The registry's views and the toolbar don't import a component library. They
take their buttons, badges, tooltips, popovers, the view select, the dialog and the toast from the files the calendar-ui item adds
to components/calendar/ui/. That's the kit: a default built on ui-sdk's Solid components, which
gives them their keyboard, focus and ARIA. It's your code once you add it, to edit or replace.
| File | What the views use it for |
|---|---|
button.tsx | The toolbar's Today and step buttons, the mini month's arrows, the chevron that expands the week's all-day row, and the close button of an annotation's popover |
badge.tsx | A resource's status |
tooltip.tsx | The names of the toolbar's step buttons, shown after 400 ms, a week or day event's title when it doesn't fit, and what an annotation's mark is |
select.tsx | The view switcher |
popover.tsx | The month's "+N more" and a day of the year, each with the day's events, and an annotation's details |
dialog.tsx | The recurring-event dialog |
toast.tsx | The undo toast |
icons.tsx | The chevrons and the other icons, drawn inline |
A team with an app in each framework finds the same files in React's kit, with the same exports,
props and .styles.ts files, in each framework's form: a dialog's initialFocus and a close
button's render are functions in Solid. The registry's tests check that the two kits render the
same elements and attributes.
Add it
The calendar item brings calendar-ui, so adding a view adds the kit too, as
UI source describes. It installs @ui-sdk/core and
@ui-sdk/solid if your app doesn't have them.
ui-sdk adds a little CSS of its own to the page, in a layer named ui-sdk. The stylesheet in
UI source names that layer before Tailwind, so your styles
and Tailwind's win over it. The select's list, the tooltips and the popovers open in the browser's top layer,
through the Popover API: Chrome and Edge 114, Safari 17 and Firefox 125 or later.
Tooltips wait 400 ms. Change tooltipDefaults in components/calendar/ui/tooltip.styles.ts, or
pass delay to one Tooltip. Each control keeps its classes in such a .styles.ts file, and
A control's look shows how to change them.
In your own components, use the kit's controls as you would any other:
import { Button } from "@/components/calendar/ui/button";
/** The kit's button, in a control of the app's own. */
function Refresh(props: { readonly onRefresh: () => Promise<void> }) {
// A click that returns a promise marks the button pending until it settles.
return (
<Button onClick={() => props.onRefresh()} size="sm" variant="outline">
Refresh
</Button>
);
}Here is each control once: two buttons, an icon button with a tooltip, a select and a badge.
import { createSignal, For } from "solid-js";
import { Badge } from "@/components/calendar/ui/badge";
import { Button } from "@/components/calendar/ui/button";
import { ChevronRightIcon } from "@/components/calendar/ui/icons";
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/calendar/ui/select";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/calendar/ui/tooltip";
const rooms = [
{ label: "Room A", value: "a" },
{ label: "Room B", value: "b" },
{ label: "Room C", value: "c" },
];
export function Controls() {
const [room, setRoom] = createSignal("a");
return (
<div class="flex flex-wrap items-center gap-3 p-4">
{/* A click that returns a promise marks the button pending until it settles. */}
<Button onClick={() => new Promise((resolve) => setTimeout(resolve, 800))}>Save</Button>
<Button variant="outline">Cancel</Button>
<Tooltip>
<TooltipTrigger
render={(trigger) => (
<Button {...trigger} aria-label="Next week" size="icon" variant="ghost" />
)}
>
<ChevronRightIcon />
</TooltipTrigger>
<TooltipContent>Next week</TooltipContent>
</Tooltip>
<Select items={rooms} onValueChange={setRoom} value={room()}>
<SelectTrigger aria-label="Room">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<For each={rooms} keyed={(option) => option.value}>
{(option) => (
<SelectItem label={option().label} value={option().value}>
{option().label}
</SelectItem>
)}
</For>
</SelectGroup>
</SelectContent>
</Select>
<Badge variant="outline">Booked</Badge>
</div>
);
}Use your own controls
To use a control of your own, replace the body of its file. Keep the file's name, the names it exports and the props below, and render your component. The views stay as they are, since they import nothing else from it.
A plain <button>, with no ui-sdk, in place of the kit's:
import type { JSX } from "@solidjs/web";
import { merge, omit } from "solid-js";
export interface ButtonProps extends Omit<JSX.ButtonHTMLAttributes<HTMLButtonElement>, "class"> {
readonly class?: string;
readonly size?: "default" | "icon" | "icon-sm" | "icon-xs" | "lg" | "sm" | "xs";
readonly variant?: "default" | "ghost" | "outline";
/** Renders a calendar trigger in place of the `<button>`, with the props to spread on it. */
readonly render?: (props: Record<string, unknown>, state: object) => JSX.Element;
}
const looks = {
default: "bg-primary text-primary-foreground",
ghost: "hover:bg-muted",
outline: "border bg-background",
};
export function Button(props: ButtonProps) {
const own = merge(omit(props, "class", "render", "size", "variant"), {
get class() {
return `inline-flex min-h-8 items-center gap-1 rounded-md px-2 ${looks[props.variant ?? "default"]} ${props.class ?? ""}`;
},
get type() {
return props.type ?? "button";
},
});
return props.render === undefined ? <button {...own} /> : props.render(own, {});
}Pass on every other prop, aria-* and data-* included, to the element your control renders,
around its children. The views set them, and their CSS and tests read some of them. When the views
pass render, they want one of the calendar's own triggers, such as Today, drawn as your button:
call it with the props you'd have spread on your element, and render what it returns instead.
What the views import from each file, and what they pass:
| File | The views import | What the views pass |
|---|---|---|
button.tsx | Button | variant (outline, ghost), size (icon, icon-sm, or none), class, onClick, aria-label, and render. The chevron that expands the all-day row also gets aria-expanded and tabindex={-1} |
badge.tsx | Badge | variant="outline", class, title, and data-slot="resource-status" with data-state, which colours the status dot inside it |
tooltip.tsx | Tooltip, TooltipTrigger, TooltipContent, createTooltipHandle | Tooltip: its trigger and content. TooltipTrigger: render, the button it shows on. TooltipContent: the text. The week and day share one tooltip among their events, through the handle createTooltipHandle() returns: Tooltip gets handle, delay, onOpenChange and, as its child, a function of the open trigger's payload; each TooltipTrigger gets handle, payload and render; TooltipContent gets aria-label. The annotations' tooltip also gets trackCursorAxis on Tooltip, and side, sideOffset and class on TooltipContent |
select.tsx | Select, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectItem | Select: items ({ label, value }), value and onValueChange, which gets the new value. SelectTrigger: aria-label and class. SelectContent: align and alignItemWithTrigger. SelectItem: value, label, and the label with its shortcut as children |
popover.tsx | Popover, PopoverTrigger, PopoverContent, PopoverTitle, PopoverClose, createPopoverHandle | PopoverTrigger: aria-label, class, style and tabIndex={-1}, since the grid keeps one tab stop, and its text as children. PopoverContent: align, aria-label, which names the popover, and class. The year shares one popover among its days, through the handle createPopoverHandle() returns: Popover gets handle and, as its child, a function of the open trigger's payload; each PopoverTrigger gets handle, payload, id and onMouseDown; PopoverContent gets ref, and initialFocus and finalFocus, functions that return the element to focus. The annotations' popover is shared the same way: Popover also gets modal and onOpenChange, PopoverTrigger gets render, PopoverContent gets side and sideOffset, PopoverTitle gets class, and PopoverClose gets render, the close button |
The dialog and the toast have more parts:
| File | The items import | What they pass |
|---|---|---|
dialog.tsx | Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose | Dialog: open, onOpenChange, and onOpenChangeComplete, once it has closed and focus is back. DialogContent: initialFocus, a function that returns the button to focus first. DialogClose: render, the Cancel button. The others: their text, and class |
toast.tsx | createToastManager, ToastViewport, Toast, ToastTitle, ToastDescription, ToastAction, ToastClose | createToastManager() returns add and close; add takes id, title, description, timeout and actionProps (children and onClick, which gets the input that pressed it). ToastViewport: manager, aria-label and class, around one Toast with the other parts. ToastClose: aria-label and the icon. ToastDescription: class |
Props take Solid's names, such as class. React's kit takes the same props under React's names,
so a control you write for both frameworks has one set of props.
What changes when you swap a control:
- Keyboard, focus and ARIA become your component's. The calendar's own keys, such as the mini month's arrows, still work, since the views handle them.
- What an agent sees. An agent bridge lists ui-sdk's components. It reads
your control only as far as your component tells it. The calendar stays on the bridge, so an
agent can still change the view with its
setViewaction. - The same control in React and Solid. ui-sdk has the same components in both frameworks, so the kit's controls behave alike in both. Yours behave as your components do.