Skip to main content

Theming

Vajra UI's theme system is built around semantic design tokens: colors, spacing, border radius, and typography. Every component prop reads from these tokens instead of raw values, so the whole library reflects one consistent theme. This page shows the default theme as it actually renders. To override tokens, add your own, or switch themes at runtime, see Custom Theme.

createVajraTheme

The entry point for setting up your theme. Wrap your app in VajraProvider with the result.

import { createVajraTheme } from '@devraj-labs/vajra-ui';

export const theme = createVajraTheme({
colorScheme: 'light', // 'light' | 'dark', defaults to 'light'
fonts: myFonts, // required
});
<VajraProvider theme={theme}>
<YourApp />
</VajraProvider>

useVajraTheme

Access the resolved theme anywhere inside VajraProvider.

import { useVajraTheme } from '@devraj-labs/vajra-ui';

const { colors, spacing, rounded, typography, fontSizes, lineHeights, fonts } = useVajraTheme();
PropertyTypeDescription
colorsRecord<TVajraColors, string>All color tokens, resolved to hex strings
spacingRecord<TSpacingToken, number>All spacing tokens, resolved to numbers
roundedRecord<TRoundedToken, number>All border radius tokens, resolved to numbers
typographyRecord<TFontVariant, TFontVariantProps>Font size, line height, weight per variant
fontSizesRecord<TFontSizeToken, number>All font size tokens, resolved to numbers
lineHeightsRecord<string, number>All line height tokens, resolved to numbers
fontsyour font mapCustom font families

Colors

The default theme's brand, text, surface, border, and feedback scales, rendered with their live resolved hex values. Switch the site's color mode to see the dark theme's values.

Brand

primary
#14B8A6
primaryEmphasis
#0D9488
primaryMuted
#2DD4BF
primarySubtle
#F0FDFA
secondary
#E5193A
secondaryEmphasis
#C0102C
secondaryMuted
#F04060
secondarySubtle
#FFF0F2

Text

text
#111111
textSubtle
#4B5563
textMuted
#6B7280
textDisabled
#9CA3AF
textInverse
#FFFFFF
textInverseMuted
#D1D5DB

Background & surface

background
#FFFFFF
backgroundSunken
#F9FAFB
backgroundRaised
#F3F4F6
surface
#F3F4F6
surfaceSunken
#F9FAFB
surfaceRaised
#E5E7EB
surfaceOverlay
#D1D5DB

Border

border
#E5E7EB
borderSubtle
#F3F4F6
borderStrong
#9CA3AF
borderFocus
#2DD4BF

Feedback

error
#EF4444
errorMuted
#FEE2E2
errorSubtle
#FFF5F5
success
#22C55E
successMuted
#DCFCE7
successSubtle
#F0FDF4
warning
#F59E0B
warningMuted
#FEF3C7
warningSubtle
#FFFBEB
info
#3385FF
infoMuted
#DBEAFE
infoSubtle
#EFF6FF

Overlay

overlayLight
rgba(0,0,0,0.2)
overlay
#00000066
overlayStrong
rgba(0,0,0,0.7)

Plus transparent, resolving to CSS transparent.

Spacing, TSpacingToken

TokenValue (px)
s-00
s-14
s-28
s-312
s-416
s-520
s-624
s-832
s-1040
s-1248
s-1664

Border Radius, TRoundedToken

TokenValue (px)
r-00
r-14
r-28
r-312
r-416
r-520
r-624
r-728
r-832
r-936
r-1040
r-full9999

Font Sizes, TFontSizeToken

TokenValue (px)
f-112
f-1.514
f-216
f-2.518
f-320
f-424
f-528
f-632

Typography, TFontVariant

VariantFont SizeLine HeightWeightUse
display3236700Hero text
h12832700Page title
h22428600Section title
h32024600Sub-section title
subheading2024500Section label
body1620400Default body copy
bodyMedium1620500Emphasized body
bodySmall1418400Secondary body copy
button1620600Button labels
label1216400Small UI labels
labelMedium1216500Medium weight label
caption1418400Helper text, timestamps