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:
| Item | What it adds |
|---|---|
calendar-theme | The calendar's tokens, its event color palette, and components/calendar/event-colors.ts |
base-tokens | shadcn/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 inlineblock that gives Tailwind a color for each token, sobg-calendar-todayandborder-calendar-gridare classes. - The tokens' light values on
:rootand 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-motionblock, 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:
| Variable | Used for | Tailwind class | Read by |
|---|---|---|---|
--calendar-grid | Lines between days and hours | border-calendar-grid | The month, the agenda, the week and day, the scrolling week and day, the resource columns, the timeline |
--calendar-today | Today's date marker | bg-calendar-today | The month, the year, the agenda, the week and day, the resource columns, the mini month, the timeline |
--calendar-today-foreground | Text on today's marker | text-calendar-today-foreground | The month, the year, the agenda, the week and day, the mini month, the timeline |
--calendar-selection | Selected days and ranges, and the dates in view | bg-calendar-selection | The month, the week and day, the scrolling week and day, the resource columns, the mini month, the timeline |
--calendar-event | Event background | bg-calendar-event | The month, the agenda, the event chip |
--calendar-event-foreground | Event text | text-calendar-event-foreground | The month, the agenda, the event chip |
--calendar-event-border | Event accent edge, and an event's color dot | border-calendar-event-border | The month, the year, the agenda, the event chip |
--calendar-closed | Closed days in a month or a year | bg-calendar-closed | The month, the year |
--calendar-busy | A resource status's busy dot | bg-calendar-busy | The resource status |
--calendar-free | A resource status's free dot | bg-calendar-free | The resource status |
--calendar-invalid | A preview the policies would reject | outline-calendar-invalid | The event chip, the previews' classes |
--calendar-warning | A preview the policies would flag | outline-calendar-warning | The event chip, the previews' classes |
--calendar-surface | Behind sticky headers, between events | bg-calendar-surface | The week and day, the scrolling week and day, the resource columns, the scrolling month, the timeline |
--calendar-axis | Hour and weekday labels | text-calendar-axis | The week and day, the scrolling week and day, the resource columns, the timeline |
--calendar-now | The current-time line | bg-calendar-now | The week and day, the resource columns, the timeline |
--calendar-weekend | Weekend background | bg-calendar-weekend | The timeline |
--calendar-unavailable | Closed time in time grids and timelines | bg-calendar-unavailable | The week and day, the resource columns, the timeline |
--calendar-hour-height | Height 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-x | Padding at the sides of time-grid events (0.375rem) | px-(--calendar-event-padding-x) | The week and day, the resource columns |
--calendar-event-padding-y | Padding 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:
: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:
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:
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>
);
}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:
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:
[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:
| File | What it holds |
|---|---|
ui/button.styles.ts | buttonVariants: the button's base classes, its six variants and its eight sizes |
ui/badge.styles.ts | badgeVariants: the badge's base classes and its four variants |
ui/tooltip.styles.ts | The bubble's and the arrow's classes, and tooltipDefaults: the delay and the offset |
ui/select.styles.ts | A class list for each part of the select, and selectDefaults: where the list opens |
ui/popover.styles.ts | The panel's and the title's classes, and popoverDefaults: the gap to the trigger |
calendar-toolbar.styles.ts | The toolbar's layout, its title, and the view switcher's trigger |
mini-month.styles.ts | The mini month's grid, its days, today and the band of dates in view |
event-chip.styles.ts | The event chip, in every state |
resource-status.styles.ts | A resource's status badge and its dot |
preview-state.styles.ts | The outline of a draft the policies would reject or flag |
unavailable-time.styles.ts | Where the shading of closed time sits, behind the events |
month-view/month.styles.ts | The month's grid, its days and dates, its events, and the "+N more" list |
list-view/agenda.styles.ts | The agenda's days and rows, and the scrolling agenda's empty state |
time-grid-view/time-grid.styles.ts | The week and day: the header, the all-day row, the hours, the columns, events, drafts and the now line |
year-view/year.styles.ts | The 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.ts | The timeline's grid, header, rows and cells, its events, and the keyboard's cursor |
ui/dialog.styles.ts | The backdrop's, the panel's, and its header's, footer's, title's and description's classes |
ui/toast.styles.ts | The 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.ts | The recurring-event dialog's list of scopes and each choice |
calendar-history-toast/history-toast.styles.ts | The undo toast's hint, which a screen reader hears after the title and the screen doesn't show |
scrolling-axis.styles.ts | The scrolling views' snap points, where a swipe comes to rest |
scrolling-month-view/scrolling-month.styles.ts | The scrolling month's viewport, its canvas of weeks, and a week that shows every lane |
scrolling-time-grid-view/scrolling-time-grid.styles.ts | The 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.ts | The resource columns' header and its group bands, the dates row, the all-day row, and the columns' tracks |
resource-time.styles.ts | A 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:
- icon: "size-8",
+ icon: "size-8 rounded-full",-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.