Skip to main content

Overview

Kuest provides a comprehensive theming system that allows you to customize colors, corner radius, and visual appearance. All theme settings are managed through the Admin Panel under Theme.

Theme Presets

Kuest includes four built-in color presets:
PresetDescriptionUse Case
DefaultStandard color paletteGeneral purpose
MidnightCool blue-purple tonesDiscord-inspired dark theme
LimeHigh-energy green accentBold, energetic branding
AmberWarm amber paletteBinance-inspired warm theme
  1. Navigate to AdminTheme
  2. Select a preset from the Preset dropdown
  3. Click Save settings
  4. Preview with Preview Light and Preview Dark buttons

Color Tokens

Kuest uses a token-based color system with separate values for light and dark modes.

Core Surface Tokens

TokenDescription
backgroundMain background color
foregroundPrimary text color
cardCard background color
card-foregroundCard text color
popoverPopover background
popover-foregroundPopover text
mutedMuted background
muted-foregroundMuted text

Brand and Accent Tokens

TokenDescription
primaryPrimary brand color
primary-foregroundText on primary
secondarySecondary brand color
secondary-foregroundText on secondary
accentAccent highlights
accent-foregroundText on accent

Outcome and Alert Tokens

TokenDescription
yes”Yes” outcome color
yes-foregroundText on yes
no”No” outcome color
no-foregroundText on no
destructiveError/warning color
destructive-foregroundText on destructive

Input and Border Tokens

TokenDescription
borderBorder color
inputInput field border
ringFocus ring color

Chart Tokens

TokenDescription
chart-1 through chart-5Chart palette colors

Custom Color Overrides

  1. Navigate to AdminTheme
  2. Scroll to Theme tokens section
  3. Customize individual tokens for light/dark modes
  4. Enter colors in supported formats
  5. Click Save settings
Use the color picker or enter values manually. The reset icon restores the preset default.

Corner Radius

Adjust the roundness of UI elements (buttons, cards, inputs).
PresetValueDescription
Default(empty)Uses theme default
Sharp0No rounding
Soft0.5remSubtle rounding
Round1remFull rounding

Theme Configuration Files

theme-settings.ts

Manages theme settings and database integration:
src/lib/theme-settings.ts
// Load current theme configuration
export async function loadRuntimeThemeState(): Promise<RuntimeThemeState>

// Get theme form state for admin panel
export function getThemeSettingsFormState(allSettings?: SettingsMap)

// Validate theme input
export function validateThemeSettingsInput(params: {...})

theme.ts

Core theme logic and color token handling:
src/lib/theme.ts
// Available color tokens
export const THEME_TOKENS = [
  'yes', 'yes-foreground',
  'no', 'no-foreground',
  'background', 'foreground',
  // ... 28 total tokens
]

// Build resolved theme config
export function buildResolvedThemeConfig(
  presetId: ThemePresetId,
  lightOverrides?: ThemeOverrides,
  darkOverrides?: ThemeOverrides,
  radius?: ThemeRadius | null,
)

// Generate CSS text for theme
export function buildThemeCssText(
  light: ThemeOverrides,
  dark: ThemeOverrides,
  radius?: ThemeRadius | null
)

Settings Storage

Theme settings are stored in the settings table:
GroupKeyDescription
themepresetTheme preset ID
themeradiusCorner radius value
themelight_jsonLight mode color overrides (JSON)
themedark_jsonDark mode color overrides (JSON)

Database Access

import { loadRuntimeThemeState } from '@/lib/theme-settings'

const runtimeTheme = await loadRuntimeThemeState()

console.log(runtimeTheme.theme.presetId)  // 'default'
console.log(runtimeTheme.theme.light)    // Light color overrides
console.log(runtimeTheme.theme.dark)     // Dark color overrides
console.log(runtimeTheme.theme.radius)   // Corner radius
console.log(runtimeTheme.theme.cssText)  // Generated CSS

CSS Integration

The theme system generates CSS custom properties:
:root {
  --radius: 0.5rem;
  --background: #ffffff;
  --foreground: #0a0a0a;
  --primary: #3b82f6;
  /* ... other tokens */
}

.dark,
[data-theme-mode='dark'] {
  --background: #0a0a0a;
  --foreground: #fafafa;
  --primary: #60a5fa;
  /* ... other tokens */
}

Using Theme Variables

In your components, reference theme variables:
// Tailwind classes
<div className="bg-background text-foreground">
  <button className="bg-primary text-primary-foreground rounded-[var(--radius)]">
    Button
  </button>
</div>

// Direct CSS
<div style={{ backgroundColor: 'hsl(var(--background))' }}>
  Content
</div>

Admin Theme Panel

The admin theme panel provides visual theme editing: Location: Admin → Theme Features:
  • Preset selector with descriptions
  • Corner radius slider/input
  • Live preview cards showing:
    • Market cards
    • Primary/secondary buttons
    • Input fields
    • Popovers
    • Chart colors
  • Separate light/dark mode token editors
  • Color pickers with hex/OKLCH support
  • JSON editor for advanced customization
  • Reset buttons to restore defaults
Changes take effect immediately after saving. Users may need to refresh to see updates.

Best Practices

  • Maintain sufficient contrast ratios (WCAG AA: 4.5:1 for text)
  • Test colors in both light and dark modes
  • Use OKLCH for perceptually uniform color scales
  • Keep brand colors consistent across themes
  • Don’t invert colors directly; adjust lightness
  • Reduce saturation slightly in dark mode
  • Ensure readability with proper contrast
  • Test with actual dark backgrounds, not pure black
  • Use semantic color tokens (primary, destructive, etc.)
  • Don’t rely solely on color to convey meaning
  • Test with color blindness simulators
  • Ensure focus indicators are visible
  • Minimize the number of custom overrides
  • Use presets as a base when possible
  • Test theme loading on slow connections
  • Cache theme configuration appropriately

Troubleshooting

  • Clear browser cache and hard refresh (Ctrl+Shift+R)
  • Check if settings were saved successfully
  • Verify color format is valid (hex or OKLCH)
  • Ensure no CSS is overriding theme variables
  • Only hex (#fff, #ffffff) and OKLCH are supported
  • RGB/HSL must be converted to hex or OKLCH
  • Remove any invalid characters or spaces
  • Check JSON syntax if editing directly
  • Check database connection
  • Verify admin permissions
  • Look for errors in server logs
  • Ensure settings table has correct schema

Branding

Customize logos, site name, and identity

Localization

Multi-language theme labels

Admin Panel

Access the theme configuration panel

Build docs developers (and LLMs) love