Skip to main content

Theme Customization Guide

ThemeContext exposes all 25+ customisation dimensions through useThemeContext(). Changes are persisted to localStorage automatically.

Reading and writing theme settings

import { useThemeContext } from "@xocialive/ui-components/contexts";

function ThemeSwitcher() {
const {
mode,
setMode,
colorTheme,
setColorTheme,
fontFamily,
setFontFamily,
fontSize,
setFontSize,
borderRadius,
setBorderRadius,
scrollbarStyle,
setScrollbarStyle,
} = useThemeContext();

return (
<>
<Switch checked={mode === "dark"} onChange={(e) => setMode(e.target.checked ? "dark" : "light")} />
<Select value={colorTheme} onChange={(e) => setColorTheme(e.target.value)}>
<MenuItem value="aurora">Aurora</MenuItem>
<MenuItem value="ocean">Ocean</MenuItem>
</Select>
</>
);
}

Customization dimensions reference

DimensionSetterType
Colour modesetMode"light" | "dark"
Colour palettesetColorThemeThemePaletteName (9 options)
Font sizesetFontSize"small" | "medium" | "large"
Font familysetFontFamilystring (5 fonts)
Border radiussetBorderRadius"sharp" | "rounded" | "extra-round"
Table paddingsetTablePaddingnumber (0–10)
Table text alignsetTableTextAlign"left" | "center" | "right"
Scrollbar stylesetScrollbarStyleScrollbarStyle
Shadow intensitysetShadowIntensityShadowIntensity
Glass intensitysetGlassIntensityGlassIntensity
Animation speedsetAnimationSpeedAnimationSpeed
Gradient stylesetGradientStyleGradientStyle
Surface stylesetSurfaceStyleSurfaceStyle
Button stylesetButtonStyleButtonStyle
Border widthsetBorderWidthBorderWidth
Table header stylesetTableHeaderStyleTableHeaderStyle
Icon stylesetIconStyleIconStyle
Input stylesetInputStyleInputStyle

Adding a new theme dimension

Follow this four-step pattern (see CLAUDE.md for the full annotated pattern):

  1. ThemeContext.tsx — add state + setter + loadSetting() call
  2. ThemeBuildConfig (themes/utils/index.ts) — add the new property to the interface
  3. buildTheme() (themes/utils/index.ts) — apply the value as a MUI component override or palette property
  4. ThemeCustomizationDrawer.tsx — add a UI control for the new dimension

Resetting to defaults

const { resetToDefaults } = useThemeContext();

<Button onClick={resetToDefaults}>Reset theme</Button>;