Views

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.

FileWhat the views use it for
button.tsxThe 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.tsxA resource's status
tooltip.tsxThe 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.tsxThe view switcher
popover.tsxThe month's "+N more" and a day of the year, each with the day's events, and an annotation's details
dialog.tsxThe recurring-event dialog
toast.tsxThe undo toast
icons.tsxThe 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:

refresh.tsx
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.

Live. Save stays pending while its promise settles, and the tooltip waits 400 ms.
controls.tsx
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:

ui/button.tsx
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:

FileThe views importWhat the views pass
button.tsxButtonvariant (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.tsxBadgevariant="outline", class, title, and data-slot="resource-status" with data-state, which colours the status dot inside it
tooltip.tsxTooltip, TooltipTrigger, TooltipContent, createTooltipHandleTooltip: 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.tsxSelect, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectItemSelect: 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.tsxPopover, PopoverTrigger, PopoverContent, PopoverTitle, PopoverClose, createPopoverHandlePopoverTrigger: 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:

FileThe items importWhat they pass
dialog.tsxDialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogCloseDialog: 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.tsxcreateToastManager, ToastViewport, Toast, ToastTitle, ToastDescription, ToastAction, ToastClosecreateToastManager() 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 setView action.
  • 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.

On this page