Colors

Colors

Default Colors

Sax Design Vue maintains primary, success, danger, warn, and dark semantic colors.

Primary
Success
Danger
Warn
Dark

HSL Theme Key

Component colors are stored as HSL channels. Define primary once; hover, active, and subtle states keep its H value and change only S/L. Dark mode uses the same H with its own S/L scale.

Use SConfigProvider for application themes:

Copied
<script setup lang="ts">
const theme = {
  primary: '#5b3cc4',
  // Optional: a same-hue dark primary is derived when omitted.
  darkPrimary: 'hsl(252 82% 72%)',
  states: {
    hover: { saturation: -2, lightness: -7 },
    active: { saturation: -4, lightness: -12 },
  },
  darkStates: {
    hover: { lightness: 7 },
    active: { lightness: 12 },
  },
}
</script>

<template>
  <s-config-provider :theme="theme">
    <App />
  </s-config-provider>
</template>

CSS

When using CSS directly, provide HSL channels without hsl(), or override the complete color token with any CSS color.

Copied
:root {
  --sax-theme-primary-h: 252deg;
  --sax-theme-primary-s: 54%;
  --sax-theme-primary-l: 50%;
  --sax-theme-primary-dark-h: var(--sax-theme-primary-h);
  --sax-theme-primary-dark-s: 82%;
  --sax-theme-primary-dark-l: 72%;
}

.marketing {
  --sax-css-primary: oklch(0.62 0.18 264);
}

Runtime Themes

applyThemeConfig() accepts the same object as SConfigProvider and returns a restore function.

Copied
<script lang="ts" setup>
import { onBeforeUnmount, onMounted } from 'vue'
import { applyThemeConfig } from 'sax-design-vue'

let restoreTheme: (() => void) | undefined

onMounted(() => {
  restoreTheme = applyThemeConfig({ primary: '#5b3cc4' })
})

onBeforeUnmount(() => restoreTheme?.())
</script>
Last Updated: 2026-10-28, 06:17:56 UTC
Copied