Configuration

Configuration

Global registration

Register the full library once at app bootstrap:

Copied
import SaxDesignVue from 'sax-design-vue'

app.use(SaxDesignVue)

For tree-shaking, register only the components you need — see Using Components.

Color tokens

Color tokens have two layers. Channel tokens such as --sax-primary store HSL values. Complete color tokens such as --sax-css-primary wrap them as hsl(var(--sax-primary)). Components consume the complete color tokens (var(--sax-css-primary) or color-mix(in srgb, var(--sax-css-primary) 12%, transparent)), so a theme can still edit H/S/L while an application can override --sax-css-primary with any CSS color.

Copied
:root {
  --sax-theme-primary-h: 222.8deg;
  --sax-theme-primary-s: 100%;
  --sax-theme-primary-l: 54.9%;
  --sax-theme-primary-dark-h: var(--sax-theme-primary-h);
  --sax-theme-primary-dark-s: 92%;
  --sax-theme-primary-dark-l: 70%;
}

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

Pass theme to SConfigProvider, or call applyThemeConfig(), with HEX, RGB, or HSL values. Both generate the base primary, dark primary, and hover / active / subtle variables. See Color themes for examples. Composite tokens such as --sax-primary remain readable, but theme customization should target the --sax-theme-primary-* keys. Override --sax-css-* when a complete CSS color is needed.

Component language

Component-generated copy — including calendar months and weekdays, date/time controls, pagination, upload states, empty states, action buttons, and accessibility labels — reads from the locale supplied to SConfigProvider. English is the default. Use the built-in Chinese locale for Chinese UI:

Copied
<script setup lang="ts">
import { zhCn } from 'sax-design-vue/locales'
</script>

<template>
  <s-config-provider :locale="zhCn">
    <app />
  </s-config-provider>
</template>

Use en from the same entry for explicit English. The locale object is reactive, so changing the value passed to locale updates component-generated text without recreating the component tree. User-provided labels, slots, and placeholders remain under application control.

Global date and time settings

Set a default IANA timezone for Date Picker, Date Range Picker, and Time Picker through SConfigProvider. auto-apply-now controls whether clicking Now immediately commits and closes. Component-level values take precedence.

Copied
<template>
  <s-config-provider timezone="Asia/Shanghai" :auto-apply-now="true">
    <app />
  </s-config-provider>
</template>

The time zone leaves the entered wall-clock fields unchanged but changes the corresponding Date, value-format="x", or value-format="timestamp" instant. timestamp emits numeric milliseconds; x emits a millisecond string.

Date components can render directly in SSR and SSG. Configure the same timezone on the server and client to avoid hydration differences for absolute values. Consider client-only only when the application intentionally relies on the browser system zone.

Global component shape

Set shape="square" on SConfigProvider to make compatible controls and their popups use square corners by default. A component-level shape still takes precedence, so individual controls can opt back into rounded, circle, or pill when supported.

Copied
<template>
  <s-config-provider shape="square">
    <s-input placeholder="Inherited square input" />
    <s-select placeholder="Inherited square select" />
    <s-button>Inherited square button</s-button>

    <s-input shape="rounded" placeholder="Local rounded override" />
  </s-config-provider>
</template>

The default remains rounded when no global value is configured. The setting is inherited by nested providers unless a nested provider supplies its own shape.

The same option can be configured once during full-library installation: app.use(SaxDesignVue, { shape: 'square' }).

Global size

size sets the default density for components that use the shared small / default / large scale. Button, Input, Date Picker, Time Picker, Rate, Steps, Tabs, and Tag currently inherit it. An explicit component size always takes precedence.

Copied
<template>
  <s-config-provider size="large">
    <s-input placeholder="Inherits large" />
    <s-button>Inherits large</s-button>
    <s-button size="small">Locally overridden to small</s-button>
  </s-config-provider>
</template>

Components such as Calendar and Navbar have their own size vocabularies (for example, medium and compact) and therefore do not inherit this scale.

Common interaction defaults

Application-wide interaction policies can be shared through button, dialog, drawer, notification, pagination, radioGroup, and popper. Each object accepts only reusable defaults; content, controlled values, callbacks, and business data remain local to component instances. radioGroup accepts animated (enabled by default) and direction; explicit component props take precedence.

Select supports select: { sortByOptionOrder: true } through both installation options and SConfigProvider. Local :sort-by-option-order="false" overrides the global default. The built-in default is false.

Copied
<script setup lang="ts">
const buttonDefaults = { debounce: false }
const dialogDefaults = { maskClosable: false, lockScroll: true }
const notificationDefaults = {
  duration: 6000,
  position: 'top-right' as const,
  showClose: true,
}
const paginationDefaults = {
  pageSizes: [20, 50, 100],
  pagerCount: 9,
}
</script>

<template>
  <s-config-provider
    :button="buttonDefaults"
    :dialog="dialogDefaults"
    :notification="notificationDefaults"
    :pagination="paginationDefaults"
    :radio-group="{ animated: true }"
  >
    <app />
  </s-config-provider>
</template>

Drawer can share its placement, size, close button, mask dismissal, and Teleport defaults. Direct SPopper usage can share show/hide delays, Teleport, positioning strategy, flipping, offset, arrow, and persistence. Composed components such as Tooltip, Select, and Date Picker keep their own semantic defaults and are not unexpectedly changed by the low-level popper configuration.

Global Table defaults

Use table to share feature policies and presentation defaults across Table instances. It accepts reusable editing, validation, history, change tracking, dragging, keyboard, range, clipboard, find, chart, context-menu, resizing, virtualization, multi-sort, selection, pagination, overflow, parent-indicator, header, alignment, striped, selection-mode, and rowKey settings. align defaults both headers and cells to left when omitted; headerAlign overrides headers only.

Copied
<script setup lang="ts">
import type { TableGlobalConfig } from 'sax-design-vue'

const tableDefaults: TableGlobalConfig = {
  striped: true,
  align: 'left',
  headerAlign: 'center',
  showOverflow: 'tooltip',
  editConfig: {
    mode: 'cell',
    onSwitch: 'commit',
    onContextChange: 'cancel',
    onScroll: 'keep',
  },
  selectionConfig: { trigger: 'row', reserve: true },
  virtualConfig: { estimateSize: 48, overscan: 6 },
}
const rows = [{ id: 1, name: 'Example' }]
const columns = [{ field: 'name', title: 'Name' }]
</script>

<template>
  <s-config-provider :table="tableDefaults">
    <s-table :data="rows" :columns="columns" />

    <!-- Scalars and false replace defaults; object fields are merged. -->
    <s-table
      :data="rows"
      :columns="columns"
      :striped="false"
      :edit-config="false"
      :selection-config="{ trigger: 'cell' }"
    />
  </s-config-provider>
</template>

Precedence is “explicit component value > nearest Provider > outer Provider > built-in component default.” Object configurations are shallow-merged by field, and an explicit false disables a globally enabled feature. Data, controlled state, columns, renderers, validation rules, business requests, and model-specific callbacks stay local to each Table so unrelated data models never become implicitly coupled.

Shape and motion tokens

Use the global tokens below to keep component geometry and motion consistent. --sax-radius is the master corner radius: core inputs, menus, popups, trees, buttons, pagination, and other shared controls inherit from it through the scale variables.

Copied
:root {
  /* Change one value to reshape the shared component scale. */
  --sax-radius: 10px;

  /* Change one value to speed up or slow down shared interactions. */
  --sax-motion-duration: 180ms;
  --sax-motion-easing: cubic-bezier(0.2, 0.8, 0.2, 1);
}
VariableDefaultPurpose
--sax-radius12pxMaster radius for standard surfaces and controls.
--sax-radius-xs / --sax-radius-sm / --sax-radius-mdderivedCompact control radii, derived from the master radius.
--sax-radius-lg / --sax-radius-xl / --sax-radius-2xl / --sax-radius-3xlderivedLarge containers, emphasized surfaces, and expressive legacy shapes.
--sax-radius-pill / --sax-radius-circle9999px / 50%Semantic values for pill and circular controls.
--sax-radius-loader-orb-a / -b / -cderived shape presetsOptional overrides for the three asymmetric loader illustrations.
--sax-radius-avatar / --sax-radius-checkbox35% / 32%Optional shape overrides for avatar and checkbox visual variants.
--sax-motion-duration0.25sShared transition duration.
--sax-motion-duration-fast / --sax-motion-duration-slow / --sax-motion-duration-loop / --sax-motion-duration-long0.18s / 0.43s / 0.7s / 1sOptional durations for compact state changes, entrances, looped animation, and long list transitions.
--sax-motion-easingcubic-bezier(.645,.045,.355,1)Default shared easing curve.
--sax-motion-easing-emphasized / --sax-motion-easing-standardbuilt-in curvesOptional easing overrides for entrance and state-change motion.

Pill and circle shapes intentionally use their semantic tokens so they remain pill-shaped and circular. The legacy --sax-border-radius-* and --sax-transition-* variables remain available. They now resolve through these global tokens, so existing overrides continue to work.

Per-component configuration

Each component page documents:

  • Props — typed configuration (color, size, variants)
  • Events — v-model and interaction callbacks
  • Slots — composition and custom content
  • Example + code — live preview with copy-ready snippets

Start from the default example, then jump to the API table at the bottom of the page.

Auto-import (Vite)

Vite already resolves sax-design-vue from node_modules; no alias is needed. Install unplugin-vue-components, then use a small resolver for S-prefixed components. Import Sax styles once from your application entry file.

Copied
import { defineConfig } from 'vite'
import Components from 'unplugin-vue-components/vite'

const SaxDesignVueResolver = (name: string) => {
  if (!name.startsWith('S')) return

  return { name, from: 'sax-design-vue' }
}

export default defineConfig({
  plugins: [
    Components({
      resolvers: [SaxDesignVueResolver],
    }),
  ],
})
// src/main.ts
import 'sax-design-vue/theme-chalk/index.css'
import 'sax-design-vue/theme-chalk/dark/css-vars.css'

This resolver imports components from the package root; it does not need a filesystem path. Alternatively, import components directly from sax-design-vue for full control.

Nuxt

See Usage with Nuxt for SSR-specific notes.

Global week rules

firstDayOfWeek unifies weekday headings, date grids, week selection, and Calendar week views. Values are 0–6 (Sunday–Saturday), default 1. firstWeekContainsDate is the January date that must belong to week one, from 1–7, default 4. Defaults match ISO weeks; use 0 / 1 for Sunday-first weeks containing January 1. Calendar week numbers and DatePicker gggg-[W]ww share these rules. Explicit component start-day / first-day-of-week takes precedence over the nearest Provider and application installation configuration.

app.use(SaxDesignVue, { firstDayOfWeek: 1, firstWeekContainsDate: 4 })
<s-config-provider :first-day-of-week="0" :first-week-contains-date="1">
  <app />
</s-config-provider>

Shared SVG filters

Card liquid-glass textures and Tag mark/arrow/flag shadows register their static graphs automatically. The document-wide registry reuses identical definitions across component instances and Vue applications, including multiple library imports. The three built-in graphs stay cached for reuse after route changes. Each element still renders the shared graph against its own bounds.

Use defineSvgFilter and useSvgFilter for custom component filters. The graph is an immutable snapshot. Its key, attributes, primitive nodes, and optional scope determine its identity; different parameters cannot overwrite an existing definition.

<script setup lang="ts">
import { defineSvgFilter, useSvgFilter } from 'sax-design-vue'

const shadow = defineSvgFilter({
  key: 'soft-shadow',
  nodes: [
    {
      tag: 'feDropShadow',
      attrs: { dx: 0, dy: 2, stdDeviation: 2, 'flood-opacity': 0.15 },
    },
  ],
})
const { url } = useSvgFilter(shadow, { cache: true })
</script>

<template>
  <s-tag :style="{ filter: url }">Shared shadow</s-tag>
</template>

The composable acquires the graph after mount and releases its consumer when the component unmounts. Without cache: true, the last release removes the graph. Pass a document-unique scope for independently animated instances; avoid caching changing instance graphs. The returned id, url, ready, and element are refs. Until ready is true, SSR and hydration use the component’s CSS fallback and create no server-side DOM. Card and Tag provide their own fallbacks.

Outside Vue setup, call svgFilter.acquire(definition, { cache: true }), apply the returned url, and call release() when the consumer is removed. svgFilter.getId(definition, scope?) returns a deterministic ID without creating DOM. svgFilter.clearUnused(document?) removes idle cached graphs while preserving those still used by any application. An explicit document option keeps iframe registries separate.

Animated placeholders and Dialog closing use private, transient filter graphs. Idle instances and SSR output contain no animation filters. A graph is created only for an actual animation and released after completion or cancellation. Dialog waits for close validation and loading completion before creating it; reduced motion, hidden-page closing and animation opt-out skip allocation. Independent instances never share mutable filter nodes.

SVG filter animation modules

defineSvgFilterAnimation declares an immutable module: a filter definition, attribute bindings addressed by primitive-child index paths, and a pure frame(progress) function. Progress ranges from 0 to 1. svgFilterAnimations.add() registers it without creating DOM; duplicate names with different declarations are rejected. The built-in dissolve module supplies the current particle effect.

Register reusable modules in your application entry or a dedicated startup file:

import { defineSvgFilterAnimation, svgFilterAnimations } from 'sax-design-vue'

export const softBlur = defineSvgFilterAnimation({
  name: 'soft-blur',
  duration: 240,
  reverseDuration: 320,
  definition: {
    key: 'animation-soft-blur',
    nodes: [
      { tag: 'feGaussianBlur', attrs: { stdDeviation: 0, result: 'blurred' } },
      {
        tag: 'feComponentTransfer',
        attrs: { in: 'blurred' },
        children: [{ tag: 'feFuncA', attrs: { type: 'linear', slope: 1 } }],
      },
    ],
  },
  bindings: [
    { path: [0], attribute: 'stdDeviation', channel: 'blur' },
    { path: [1, 0], attribute: 'slope', channel: 'alpha' },
  ],
  frame: (progress) => ({ blur: progress * 8, alpha: 1 - progress }),
})
svgFilterAnimations.add(softBlur)

SSvgFilterAnimation creates a named module’s graph only while playing and removes it on completion or cancellation. Static instances create no graph. Mount it only during playback to also avoid idle component instances. Set initial-progress before a fresh playback, progress to its destination, and animate-on-mount to start immediately. Changing the destination reverses from the current progress; changing modules requires remounting. settled reports the final progress. Duration overrides use milliseconds.

<script setup lang="ts">
import { shallowRef, useId } from 'vue'
import { SButton, SSvgFilterAnimation } from 'sax-design-vue'
import './svg-animations' // registers soft-blur above

const id = `soft-blur-${useId()}`
const hidden = shallowRef(false)
const running = shallowRef(false)
const initial = shallowRef(0)
const toggle = () => {
  if (!running.value) initial.value = hidden.value ? 1 : 0
  hidden.value = !hidden.value
  running.value = !window.matchMedia('(prefers-reduced-motion: reduce)').matches
}
</script>

<template>
  <SButton @click="toggle">Toggle</SButton>
  <SSvgFilterAnimation
    v-if="running"
    animation="soft-blur"
    :filter-id="id"
    :initial-progress="initial"
    :progress="hidden ? 1 : 0"
    animate-on-mount
    @settled="running = false"
  />
  <span
    :style="{
      filter: running ? `url(#${id})` : undefined,
      opacity: !running && hidden ? 0 : 1,
    }"
  >
    Animated content
  </span>
</template>

Use a document-unique filter ID for independently mounted applications. At completion, apply the intended ordinary CSS end state before removing the graph; this prevents a missing filter reference from briefly showing hidden content. Static shared filters continue to use svgFilter and useSvgFilter; animation modules share declarations, not playback state or DOM nodes.

Shared Agent icon

Global agentIcon accepts a PNG or SVG URL shared by the default Agent Editor and Message assistant icons. Component agent-icon props and icon slots can override it.

Copied
app.use(SaxDesignVue, { agentIcon: '/assistant.svg' })
<s-config-provider agent-icon="/assistant.png">
  <s-message content="Assistant answer" />
  <s-agent-editor v-model="document" />
</s-config-provider>
Last Updated: 2026-10-28, 06:17:56 UTC
Copied