Skip to content

Themes

Themes

@thaparoyal/calendar-core ships a single CSS file that provides 12 ready-made color themes, each with a light and dark variant. The same themes work across React, Vue, Svelte, and Vanilla JS.

Importing the CSS

In a bundler (ESM)

import '@thaparoyal/calendar-core/themes/themes.css';

In CSS

@import '@thaparoyal/calendar-core/themes/themes.css';

Via CDN

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@thaparoyal/calendar-core/themes/themes.css" />

Applying a Theme

Set the data-theme attribute on the calendar wrapper element:

<div data-theme="ocean">
<!-- calendar content -->
</div>

In Vanilla JS, pass the theme option:

import { render } from '@thaparoyal/calendar-vanilla';
render('#calendar', {
config: { calendarType: 'BS', locale: 'en' },
theme: 'ocean',
});

In React, Vue, and Svelte, wrap the calendar in a container with data-theme:

<div class="trc-calendar" data-theme="ocean">
<!-- framework calendar components -->
</div>

Available Themes

ThemeDescriptionDark Variant
defaultIndigo primary on whitedark
oceanBlue tones, sea-inspiredocean-dark
forestGreen tones, nature-inspiredforest-dark
sunsetWarm orange and ambersunset-dark
lavenderSoft purple toneslavender-dark
midnightDeep blue-graymidnight-dark
rosePink and rose tonesrose-dark
mintFresh green-tealmint-dark
amberGolden amber tonesamber-dark
slateNeutral grayslate-dark
coralWarm coral-redcoral-dark
indigoDeep indigo-violetindigo-dark

Light and Dark Variants

Every theme has a light (default) and dark variant. Add -dark to the theme name:

<!-- Light -->
<div data-theme="ocean">...</div>
<!-- Dark -->
<div data-theme="ocean-dark">...</div>

The base dark theme is the dark variant of the default theme:

<div data-theme="dark">...</div>

System Preference Toggle

Switch themes based on prefers-color-scheme:

const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const theme = prefersDark ? 'ocean-dark' : 'ocean';
render('#calendar', {
config: { calendarType: 'BS', locale: 'en' },
theme,
});

CSS Custom Properties

All themes are built on CSS custom properties with the --trc- prefix. Override these to customize any theme.

Color Properties

PropertyDescription
--trc-primaryPrimary accent color (selected state, active)
--trc-primary-hoverPrimary color on hover
--trc-primary-foregroundText color on primary background
--trc-primary-mutedSubtle primary tint (selection range)
--trc-backgroundMain background
--trc-background-secondarySecondary background (hover states)
--trc-background-tertiaryTertiary background (subtle areas)
--trc-background-elevatedElevated surface (popups, dropdowns)
--trc-foregroundPrimary text
--trc-foreground-secondarySecondary text
--trc-foreground-mutedMuted / disabled text
--trc-borderDefault border
--trc-border-hoverBorder on hover
--trc-ringFocus ring color

Layout Properties

PropertyDescription
--trc-radius-smSmall border radius (6px)
--trc-radiusDefault border radius (8px)
--trc-radius-lgLarge border radius (12px)
--trc-radius-xlExtra large border radius (16px)
--trc-shadow-smSmall shadow
--trc-shadowDefault shadow
--trc-shadow-lgLarge shadow
--trc-shadow-xlExtra large shadow
--trc-transition-fastFast transition (150ms)
--trc-transitionDefault transition (200ms)
--trc-transition-slowSlow transition (300ms)

Creating a Custom Theme

Define a new [data-theme] block that overrides the CSS custom properties:

[data-theme="my-brand"] {
--trc-primary: #e11d48;
--trc-primary-hover: #be123c;
--trc-primary-foreground: #ffffff;
--trc-primary-muted: rgba(225, 29, 72, 0.12);
--trc-background: #fff1f2;
--trc-background-secondary: #ffe4e6;
--trc-background-tertiary: #fecdd3;
--trc-background-elevated: #ffffff;
--trc-foreground: #1c1917;
--trc-foreground-secondary: #44403c;
--trc-foreground-muted: #a8a29e;
--trc-border: #fda4af;
--trc-border-hover: #fb7185;
--trc-ring: rgba(225, 29, 72, 0.4);
}
/* Dark variant */
[data-theme="my-brand-dark"] {
--trc-primary: #fb7185;
--trc-primary-hover: #fda4af;
--trc-primary-foreground: #1c1917;
--trc-primary-muted: rgba(251, 113, 133, 0.15);
--trc-background: #0c0a09;
--trc-background-secondary: #1c1917;
--trc-background-tertiary: #292524;
--trc-background-elevated: #44403c;
--trc-foreground: #fafaf9;
--trc-foreground-secondary: #d6d3d1;
--trc-foreground-muted: #78716c;
--trc-border: #44403c;
--trc-border-hover: #57534e;
--trc-ring: rgba(251, 113, 133, 0.4);
}

Then apply it:

<div data-theme="my-brand">...</div>

CSS Classes

The calendar components use trc-* prefixed classes that map to the custom properties. The main classes are:

ClassElement
trc-calendarRoot container
trc-calendar-headerHeader (nav + title)
trc-calendar-nav-buttonPrev/next navigation buttons
trc-calendar-titleMonth/year title
trc-calendar-gridDay grid table
trc-calendar-grid-headWeekday header row
trc-calendar-weekdayIndividual weekday label
trc-calendar-weekTable row of days
trc-calendar-cellDay cell
trc-calendar-cell-todayToday indicator
trc-calendar-cell-selectedSelected date
trc-calendar-cell-disabledDisabled date
trc-calendar-cell-outsideDay outside current month
trc-calendar-cell-range-startRange start
trc-calendar-cell-range-endRange end
trc-calendar-cell-range-middleDate within range
trc-calendar-dayDay button inside cell

Runtime Theme Switching

Vanilla JS

const cal = render('#calendar', { theme: 'default', /* ... */ });
cal.setTheme('ocean-dark');

React / Vue / Svelte

Update the data-theme attribute on the wrapper element dynamically. For example in Vue:

<template>
<div class="trc-calendar" :data-theme="currentTheme">...</div>
</template>