Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Theming

txKit uses CSS custom properties with the --tx-* prefix. No CSS-in-JS, no Tailwind - just standard custom properties that cascade naturally.

CSS Import

Import the theme package in your app entry point:

import '@txkit/themes'

This single import includes light/dark themes and all visual variants. You can also import parts individually:

import '@txkit/themes/base'              // light theme only
import '@txkit/themes/dark'              // dark theme overrides
import '@txkit/themes/variants/soft'     // soft variant only

Theme Modes

Pass theme to TxKitProvider:

<TxKitProvider config={{
  // ...
  theme: 'dark', // 'light' | 'dark' | 'auto' (default)
}}>

'auto' follows the user's system preference via prefers-color-scheme.

Switching at Runtime

Use setTheme from the useTxKit hook:

import { useTxKit } from '@txkit/react'
 
const ThemeToggle = () => {
  const { theme, setTheme } = useTxKit()
 
  return (
    <button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>
      {theme}
    </button>
  )
}

Visual Variants

Pass variant to TxKitProvider to apply a visual style preset:

<TxKitProvider config={{
  // ...
  variant: 'soft', // 'default' | 'soft' | 'sharp' | 'rounded'
}}>
VariantRadii (sm/md/lg)Button RadiusShadowsTransitionFeel
default4/6/8pxradius-mdStandard150ms easeNeutral
soft8/12/16pxradius-mdSubtle, diffused200ms ease-outGentle
sharp0/0/0px0None100ms linearCrisp
rounded16/20/28pxPill (9999px)Elevated200ms cubic-bezierPlayful

Variants override --tx-radius-*, --tx-shadow-*, and --tx-transition. They combine with any theme mode (light/dark).

Customizing

Override any --tx-* variable in your CSS:

.tx-root {
  --tx-color-primary: #8B5CF6;
  --tx-radius-md: 12px;
}

For dark mode overrides, target .tx-dark:

.tx-dark {
  --tx-color-primary: #A78BFA;
}

CSS Custom Properties

All color values are defined in OKLCH for perceptual uniformity. The hex values below are approximations - check packages/themes/src/base.css and dark.css for canonical OKLCH definitions.

Colors

VariableLight (approx hex)Dark (approx hex)
--tx-color-primary#4338CA#6366F1
--tx-color-primary-hover#3730A3#818CF8
--tx-color-primary-active#312E81#4F46E5
--tx-color-primary-text#FFFFFF#FFFFFF
--tx-color-primary-alphaprimary @ 10%primary @ 15%
--tx-color-ringprimary @ 40%primary @ 50%

Semantic

VariableLightDark
--tx-color-success#059669#34D399
--tx-color-warning#D97706#FBBF24
--tx-color-error#DC2626#F87171
--tx-color-info#2563EB#60A5FA

Surfaces

VariableLightDark
--tx-color-bg#FFFFFF#0F172A
--tx-color-bg-elevated#FFFFFF#1E293B
--tx-color-bg-secondary#F8FAFC#1E293B
--tx-color-bg-tertiary#F1F5F9#334155
--tx-color-bg-muted#F1F1F4#1F2937

Text

VariableLightDark
--tx-color-text#0F172A#F1F5F9
--tx-color-text-secondary#475569#94A3B8
--tx-color-text-tertiary#94A3B8#64748B

Borders

VariableLightDark
--tx-color-border#E2E8F0#334155
--tx-color-border-hover#CBD5E1#475569

Typography

VariableValue
--tx-font-familysystem-ui, -apple-system, sans-serif
--tx-font-mono'IBM Plex Mono', ui-monospace, monospace
--tx-font-size-xs0.75rem
--tx-font-size-sm0.875rem
--tx-font-size-base1rem
--tx-font-size-lg1.125rem

Spacing

VariableValue
--tx-space-xs0.25rem
--tx-space-sm0.5rem
--tx-space-md0.75rem
--tx-space-lg1rem
--tx-space-xl1.5rem
--tx-space-2xl2rem

Radii

Default variant. Visual variants override these (see Visual Variants).

VariableValue
--tx-radius-sm4px
--tx-radius-md6px
--tx-radius-lg8px
--tx-radius-xl12px
--tx-radius-full9999px
--tx-radius-buttonvar(--tx-radius-md)

Shadows

Two-layer OKLCH shadows. Dark mode uses higher opacity for visibility on dark surfaces.

VariableLightDark
--tx-shadow-sm0 1px 2px black/4%, 0 1px 1px black/3%0 1px 2px black/20%, 0 1px 1px black/15%
--tx-shadow-md0 4px 12px black/8%, 0 1px 2px black/4%0 4px 12px black/30%, 0 1px 2px black/20%
--tx-shadow-lg0 8px 24px black/12%, 0 2px 4px black/4%0 8px 24px black/40%, 0 2px 4px black/20%

Motion

VariableValue
--tx-transition150ms ease
--tx-duration-fast100ms
--tx-duration-normal200ms
--tx-duration-moderate300ms
--tx-duration-slow400ms
--tx-ease-defaultcubic-bezier(0.2, 0, 0, 1)
--tx-ease-entercubic-bezier(0.05, 0.7, 0.1, 1)
--tx-ease-exitcubic-bezier(0.3, 0, 0.8, 0.15)
--tx-ease-springcubic-bezier(0.34, 1.56, 0.64, 1)

Z-index

VariableValue
--tx-z-dropdown1000
--tx-z-modal1001
--tx-z-toast1002