Interface Package
Theming CSS custom property theming system with full variable reference.
forceCalendar uses CSS custom properties (CSS variables) for theming. All variables use the --fc- prefix. Because components use Shadow DOM, theme variables must be set on the host element or inherited from a parent.
forcecal-main {
--fc-primary-color : #1a73e8 ;
--fc-background : #ffffff ;
--fc-text-color : #202124 ;
--fc-font-family : 'Inter' , sans-serif ;
}
The StyleUtils class provides programmatic access to the theming system.
import { StyleUtils } from '@forcecalendar/interface' ;
Set multiple CSS variables on an element. element defaults to document.documentElement.
StyleUtils. setCSSVariables ({
'--fc-primary-color' : '#1a73e8' ,
'--fc-background' : '#1e1e1e' ,
'--fc-text-color' : '#e0e0e0' ,
}, calendarEl);
Read a CSS variable value. element defaults to document.documentElement.
const primary = StyleUtils. getCSSVariable ( '--fc-primary-color' , calendarEl);
StyleUtils. darken ( '#4285f4' , 0.2 ); // Darken by 20%
StyleUtils. lighten ( '#4285f4' , 0.2 ); // Lighten by 20%
StyleUtils. getContrastColor ( '#4285f4' ); // Returns '#ffffff' or '#000000'
StyleUtils. hexToRgba ( '#4285f4' , 0.5 ); // 'rgba(66, 133, 244, 0.5)'
Validates and sanitizes a CSS color value to prevent CSS injection. Accepts hex colors, var(--*) references, rgb()/rgba() with numeric components, and a whitelist of safe color keywords. Invalid input returns the fallback value, which defaults to 'var(--fc-primary-color)'.
StyleUtils. sanitizeColor ( '#4285f4' ); // '#4285f4'
StyleUtils. sanitizeColor ( 'url(evil)' ); // 'var(--fc-primary-color)' (rejected)
StyleUtils. sanitizeColor ( 'red; background: url(evil)' ); // 'var(--fc-primary-color)' (rejected)
StyleUtils. sanitizeColor ( 'bad-value' , '#000000' ); // '#000000' (custom fallback)
Variable Default Description --fc-primary-color#2563EBPrimary accent color --fc-primary-hover#1D4ED8Primary hover state --fc-primary-light#EFF6FFLight primary for backgrounds --fc-background#FFFFFFMain background --fc-background-alt#FAFAFAAlternate background --fc-background-hover#F3F4F6Hover background --fc-background-active#E5E7EBActive/pressed background --fc-text-color#111827Primary text color --fc-text-secondary#6B7280Secondary text --fc-text-light#9CA3AFLight/muted text --fc-border-color#E5E7EBBorder color --fc-border-color-hover#D1D5DBBorder hover color --fc-accent-color#F59E0BAccent color --fc-danger-color#EF4444Danger/error color --fc-success-color#10B981Success color
Variable Default Description --fc-font-familyInter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serifFont family --fc-font-size-xs11pxExtra small text --fc-font-size-sm12pxSmall text --fc-font-size-base13pxBase text --fc-font-size-lg15pxLarge text --fc-font-size-xl18pxExtra large --fc-font-size-2xl24pxDouble extra large --fc-font-weight-normal400Normal weight --fc-font-weight-medium500Medium weight --fc-font-weight-semibold600Semibold weight --fc-font-weight-bold700Bold weight --fc-line-height1.4Line height
Variable Default Description --fc-spacing-xs2pxExtra small --fc-spacing-sm6pxSmall --fc-spacing-md10pxMedium --fc-spacing-lg14pxLarge --fc-spacing-xl20pxExtra large --fc-spacing-2xl28pxDouble extra large
Variable Default Description --fc-border-width1pxBorder width --fc-border-radius-sm3pxSmall radius --fc-border-radius5pxStandard radius --fc-border-radius-lg8pxLarge radius --fc-border-radius-full9999pxFully rounded
Variable Default Description --fc-shadow-sm0 1px 1px rgba(0,0,0,0.05)Small shadow --fc-shadow0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06)Standard shadow --fc-shadow-md0 4px 6px -1px rgba(0, 0, 0, 0.1)Medium shadow --fc-shadow-lg0 10px 15px -3px rgba(0, 0, 0, 0.1)Large shadow
Variable Default Description --fc-transition-fast100ms ease-outFast transition --fc-transition150ms ease-outStandard transition --fc-transition-slow250ms ease-outSlow transition
Variable Default Description --fc-z-dropdown1000Dropdowns --fc-z-modal2000Modals --fc-z-tooltip3000Tooltips
forcecal-main .dark {
--fc-background : #1e1e1e ;
--fc-background-alt : #2d2d2d ;
--fc-background-hover : #3d3d3d ;
--fc-background-active : #1a3a5c ;
--fc-text-color : #e0e0e0 ;
--fc-text-secondary : #a0a0a0 ;
--fc-text-light : #666666 ;
--fc-border-color : #404040 ;
--fc-border-color-hover : #555555 ;
--fc-primary-light : #1a3a5c ;
--fc-shadow-sm : 0 1 px 2 px rgba ( 0 , 0 , 0 , 0.3 );
--fc-shadow-md : 0 2 px 4 px rgba ( 0 , 0 , 0 , 0.4 );
}
@media ( max-width : 768 px ) {
forcecal-main {
--fc-font-size-base : 12 px ;
--fc-spacing-md : 8 px ;
--fc-spacing-lg : 12 px ;
}
}
StyleUtils also provides functions for generating base styles used by components:
Function Description getBaseStyles()Core layout and typography styles getButtonStyles()Button component styles getGridStyles()Month/week/day grid styles getAnimations()Keyframe animation definitions mediaQuery(breakpoint, styles)Wrap styles in a min-width media query for the named breakpoint