Theming

The Solid registry's color tokens, dark mode, the event color palette, and the files that hold each control's look.

The package ships no CSS. The Solid registry's files style themselves with Tailwind classes, and those classes read their colors and sizes from CSS variables. Two items of the registry at https://time.molten.sh/r/solid hold the variables:

ItemWhat it adds
calendar-themeThe calendar's tokens, its event color palette, and components/calendar/event-colors.ts
base-tokensshadcn/ui's neutral tokens, such as --background, --primary and --border, for light and dark

Every view brings calendar-theme. You add base-tokens yourself, once, unless your app already has a shadcn/ui-style theme that defines those tokens. UI source has the commands.

To see a change before you write it, use the Theme builder. It gives you the CSS to paste.

What the items write

shadcn add writes both items into the stylesheet that components.json names, src/app.css in UI source:

  • An @theme inline block that gives Tailwind a color for each token, so bg-calendar-today and border-calendar-grid are classes.
  • The tokens' light values on :root and their dark values on .dark, inside @layer base.
  • In the same layer, the event palette, a [data-color] rule for each color, and the look of the preview a drag shows.
  • A prefers-reduced-motion block, which stills that preview and the view transitions.

The CLI writes those blocks again on each shadcn add. Keep your changes in rules of your own, as Changing tokens shows.

Tokens

The calendar's tokens, and the files of the Solid registry that read each one today:

VariableUsed forTailwind classRead by
--calendar-gridLines between days and hoursborder-calendar-gridThe month, the agenda, the week and day, the scrolling week and day, the resource columns, the timeline
--calendar-todayToday's date markerbg-calendar-todayThe month, the year, the agenda, the week and day, the resource columns, the mini month, the timeline
--calendar-today-foregroundText on today's markertext-calendar-today-foregroundThe month, the year, the agenda, the week and day, the mini month, the timeline
--calendar-selectionSelected days and ranges, and the dates in viewbg-calendar-selectionThe month, the week and day, the scrolling week and day, the resource columns, the mini month, the timeline
--calendar-eventEvent backgroundbg-calendar-eventThe month, the agenda, the event chip
--calendar-event-foregroundEvent texttext-calendar-event-foregroundThe month, the agenda, the event chip
--calendar-event-borderEvent accent edge, and an event's color dotborder-calendar-event-borderThe month, the year, the agenda, the event chip
--calendar-closedClosed days in a month or a yearbg-calendar-closedThe month, the year
--calendar-busyA resource status's busy dotbg-calendar-busyThe resource status
--calendar-freeA resource status's free dotbg-calendar-freeThe resource status
--calendar-invalidA preview the policies would rejectoutline-calendar-invalidThe event chip, the previews' classes
--calendar-warningA preview the policies would flagoutline-calendar-warningThe event chip, the previews' classes
--calendar-surfaceBehind sticky headers, between eventsbg-calendar-surfaceThe week and day, the scrolling week and day, the resource columns, the scrolling month, the timeline
--calendar-axisHour and weekday labelstext-calendar-axisThe week and day, the scrolling week and day, the resource columns, the timeline
--calendar-nowThe current-time linebg-calendar-nowThe week and day, the resource columns, the timeline
--calendar-weekendWeekend backgroundbg-calendar-weekendThe timeline
--calendar-unavailableClosed time in time grids and timelinesbg-calendar-unavailableThe week and day, the resource columns, the timeline
--calendar-hour-heightHeight of one hour in time grids (3rem)h-(--calendar-hour-height)The week and day, the scrolling week and day, the resource columns
--calendar-event-padding-xPadding at the sides of time-grid events (0.375rem)px-(--calendar-event-padding-x)The week and day, the resource columns
--calendar-event-padding-yPadding above and below time-grid events (0.25rem)py-(--calendar-event-padding-y)The week and day, the resource columns

The color tokens work with any Tailwind color utility, so text-calendar-today and ring-calendar-now are classes too. Most calendar tokens derive from the base tokens: --calendar-grid is your --border, and the default event colors mix your --primary into --background. The controls read the base tokens directly: a button's fill is --primary, a tooltip's and the toast's are --foreground, a dialog's is --popover, and the focus ring is --ring.

Changing tokens

Every token is declared inside @layer base, so a plain rule in your own CSS wins without !important. Set the light values on :root and the dark values on .dark, below the imports:

src/app.css
:root {
  --calendar-today: oklch(0.55 0.17 150);
  --primary: oklch(0.45 0.2 264);
}

.dark {
  --calendar-today: oklch(0.72 0.15 150);
  --primary: oklch(0.7 0.16 264);
}

An app with its own shadcn/ui-style theme changes nothing here: the calendar follows the base tokens the app already defines.

Dark mode

The dark values apply when an ancestor of the calendar has the dark class. Put it on <html> from your app's theme setting:

theme-toggle.tsx
import { createSignal, onCleanup } from "solid-js";

import { Button } from "@/components/calendar/ui/button";

/** Switches the theme: the tokens' dark values apply under an element with the `dark` class. */
export function ThemeToggle() {
  const root = document.documentElement;
  const [dark, setDark] = createSignal(root.classList.contains("dark"));
  // Other code may change the class too, such as a setting elsewhere in the app, so follow it.
  const observer = new MutationObserver(() => setDark(root.classList.contains("dark")));
  observer.observe(root, { attributeFilter: ["class"] });
  onCleanup(() => observer.disconnect());
  const toggle = () => root.classList.toggle("dark", !dark());
  return (
    <Button aria-pressed={dark() ? "true" : "false"} onClick={toggle} variant="outline">
      Dark theme
    </Button>
  );
}

The files' own dark: classes must follow the same class. The stylesheet in UI source has the line that makes them: @custom-variant dark (&:is(.dark *));. Without it, Tailwind's dark: follows the system's theme, and the two can disagree.

Event colors

The theme has a palette of nine event colors: blue, green, red, orange, yellow, purple, pink, teal, and gray. A data-color attribute switches that element's three event tokens to the color, in light and dark. EventChip, in components/calendar/event-chip.tsx, sets the attribute from its color prop:

event-palette.tsx
import { For } from "solid-js";

import { EventChip } from "@/components/calendar/event-chip";
import { calendarEventColors } from "@/components/calendar/event-colors";

/** A chip on the default event tokens, and one for each color of the palette. */
export function Palette() {
  return (
    <div class="flex flex-wrap gap-2">
      <EventChip>default</EventChip>
      <For each={calendarEventColors}>
        {(color) => <EventChip color={color}>{color}</EventChip>}
      </For>
    </div>
  );
}
Live. The switch changes this example alone.

The names come from event-colors.ts as calendarEventColors, with the type CalendarEventColor.

Choosing a color per event

The week and day, the month, the year, the agenda, the resource columns and the resource timeline each take a getEventColor option: a function from your event to a color name. Pass it when you create the view:

calendar-page.tsx
import {
  createCalendar,
  createCanonicalEventAdapter,
  type CalendarEvent,
} from "@moltenship/calendar-solid";

import type { CalendarEventColor } from "@/components/calendar/event-colors";
import { createAgendaView } from "@/components/calendar/list-view/agenda-view";

export type Event = CalendarEvent<{ readonly color: CalendarEventColor }>;

export const Calendar = createCalendar<Event>()({
  eventAdapter: createCanonicalEventAdapter<{ readonly color: CalendarEventColor }>(),
  views: [createAgendaView<Event>({ getEventColor: (event) => event.data.color })],
});

Without getEventColor, events use the default event tokens. To set it for one calendar, pass it in viewOptions on Root, as Options shows for the agenda's other options. The month's options, the resource columns' options and the timeline's options work the same way.

Adding a color

Each palette entry sets a hue and a chroma, and the [data-color] rule turns them into the three event tokens for light and dark. To add a color, add its name to calendarEventColors in event-colors.ts and give it a hue and a chroma in your CSS:

src/app.css
[data-color="brand"] {
  --calendar-event-hue: 285;
  --calendar-event-chroma: 0.2;
}

A control's look

Tokens change colors. The shape of a control, its sizes and its states are Tailwind classes, and each control keeps them in a .styles.ts file beside it, apart from its behaviour:

FileWhat it holds
ui/button.styles.tsbuttonVariants: the button's base classes, its six variants and its eight sizes
ui/badge.styles.tsbadgeVariants: the badge's base classes and its four variants
ui/tooltip.styles.tsThe bubble's and the arrow's classes, and tooltipDefaults: the delay and the offset
ui/select.styles.tsA class list for each part of the select, and selectDefaults: where the list opens
ui/popover.styles.tsThe panel's and the title's classes, and popoverDefaults: the gap to the trigger
calendar-toolbar.styles.tsThe toolbar's layout, its title, and the view switcher's trigger
mini-month.styles.tsThe mini month's grid, its days, today and the band of dates in view
event-chip.styles.tsThe event chip, in every state
resource-status.styles.tsA resource's status badge and its dot
preview-state.styles.tsThe outline of a draft the policies would reject or flag
unavailable-time.styles.tsWhere the shading of closed time sits, behind the events
month-view/month.styles.tsThe month's grid, its days and dates, its events, and the "+N more" list
list-view/agenda.styles.tsThe agenda's days and rows, and the scrolling agenda's empty state
time-grid-view/time-grid.styles.tsThe week and day: the header, the all-day row, the hours, the columns, events, drafts and the now line
year-view/year.styles.tsThe year's months, their days and dates, the closed days' shading, the dots, and the day popover's list
resource-timeline-view/resource-timeline.styles.tsThe timeline's grid, header, rows and cells, its events, and the keyboard's cursor
ui/dialog.styles.tsThe backdrop's, the panel's, and its header's, footer's, title's and description's classes
ui/toast.styles.tsThe region's, the toast's and its parts' classes, and toastRegionDefaults: one toast at a time, at the bottom
recurrence-scope-dialog/recurrence-scope-dialog.styles.tsThe recurring-event dialog's list of scopes and each choice
calendar-history-toast/history-toast.styles.tsThe undo toast's hint, which a screen reader hears after the title and the screen doesn't show
scrolling-axis.styles.tsThe scrolling views' snap points, where a swipe comes to rest
scrolling-month-view/scrolling-month.styles.tsThe scrolling month's viewport, its canvas of weeks, and a week that shows every lane
scrolling-time-grid-view/scrolling-time-grid.styles.tsThe scrolling week and day: the viewport, the sticky header, the rows that follow the days, the days' canvas, and a dragged bar's copy
resource-columns-view/resource-columns.styles.tsThe resource columns' header and its group bands, the dates row, the all-day row, and the columns' tracks
resource-time.styles.tsA resource's local time and UTC offset, in the columns' header and beside a timeline row's name

The paths are from components/calendar/. These files are plain TypeScript: strings of classes, with no JSX and no import from Solid. To change a look, edit the file, and every view that draws the control follows. Round icon buttons, and tooltips that open sooner:

components/calendar/ui/button.styles.ts
-        icon: "size-8",
+        icon: "size-8 rounded-full",
components/calendar/ui/tooltip.styles.ts
-export const tooltipDefaults = { delay: 400, sideOffset: 4 } as const;
+export const tooltipDefaults = { delay: 150, sideOffset: 4 } as const;

For one control in one place, pass class instead. The kit merges it over its own classes, so <Button class="rounded-full"> rounds that button alone.

A file you edited is yours to merge: shadcn add asks before it replaces it, as UI source describes. React's registry installs the same .styles.ts files, so a team with an app in each framework keeps one copy of a look.

To replace a control with a component of your own, see Use your own controls.

On this page