Skip to content

Global configuration

God Kit exposes a Vue plugin, createGkKit, that centralizes runtime options: theme (named themes with system fallback), display breakpoints, locale and t(), defaults per component, and optional aliases. Import from god-kit/vue/config so your app can tree-shake the rest of the library as needed.

Can I use a config file?

The package does not read a fixed path like gk.config.json at runtime. You choose where configuration lives: most apps define a small TypeScript (or JavaScript) module that exports a GkKitOptions object and pass it to createGkKit. That gives you type-checking, splitting messages into per-locale files, and environment-based overrides.

ts
// src/gk.config.ts
import type { GkKitOptions } from 'god-kit/vue/config'

export const gkKitConfig: GkKitOptions = {
  theme: {
    defaultTheme: 'system',
    themes: {
      brandNight: {
        extends: 'dark',
        isDark: true,
        tokens: {
          '--gk-color-primary': '#8b5cf6',
          '--gk-color-primary-hover': '#7c3aed',
        },
      },
    },
  },
  display: { mobileBreakpoint: 'md' },
  locale: {
    locale: 'en',
    fallback: 'en',
    messages: {
      en: { /* … */ },
      fr: { /* … */ },
    },
  },
}
ts
// main.ts
import { createGkKit } from 'god-kit/vue/config'
import { gkKitConfig } from './gk.config'

app.use(createGkKit(gkKitConfig))

You can also import JSON (if your bundler allows) or merge objects from CMS / remote config before calling createGkKit.

Setup

Register the plugin once in your app entry (after creating the app):

ts
import { createApp } from 'vue'
import { createGkKit } from 'god-kit/vue/config'
import App from './App.vue'

const app = createApp(App)
app.use(
  createGkKit({
    theme: { defaultTheme: 'system' },
    display: { mobileBreakpoint: 'md' },
    locale: { locale: 'en', fallback: 'en' },
    defaults: {
      GkButton: { variant: 'primary' },
    },
  })
)
app.mount('#app')

Ensure tokens.css is loaded before vue.css so semantic variables apply. See Getting started.

Full options reference (GkKitOptions)

KeyTypePurpose
themeGkKitThemeOptionsNamed theme registry, default mode, and optional DOM root.
displayGkKitDisplayOptionsResponsive breakpoints and mobile threshold.
localeGkKitLocaleOptionsActive locale, fallback, and message catalogs.
defaultsGkKitComponentDefaultsGlobal default props per component name (PascalCase).
aliasesGkKitAliasesExtra registered component names (plain or with default props).

theme (GkKitThemeOptions)

FieldTypeDefaultDescription
defaultThemeGkThemeName'light'Initial theme. Built-ins: light, dark, system, ocean, highContrast.
scopeHTMLElement | null | () => HTMLElement | nulldocument.documentElementElement that receives data-gk-theme and gk-theme-dark.
themesRecord<string, Omit<GkThemeDefinition, 'name'>>{}Additional custom themes (hybrid model: TS token overrides + optional CSS selectors).
includePresetsbooleantrueIncludes built-in presets (ocean, highContrast) in the runtime registry.

Resolved theme is always a concrete name (never literal system). Use useGkTheme() for name, resolved, isDark, change(), toggle(), cycle(), plus runtime registry helpers registerTheme, registerThemes, and unregisterTheme.

display (GkKitDisplayOptions)

FieldTypeDefaultDescription
mobileBreakpointGkDisplayBreakpointName | number'md'Viewport width strictly below this threshold counts as mobile (name uses thresholds, or pass pixels).
thresholdsPartial<GkDisplayThresholds>(see below)Lower bounds in px for named breakpoints xsxxl.

Default breakpoint pixels

NameDefault lower bound (px)
xs0
sm600
md960
lg1280
xl1920
xxl2560

useGkDisplay() exposes width/height, name, mobile, and flags xsxxl. GkNavigationDrawer uses mobile when neither permanent nor temporary is set.

locale (GkKitLocaleOptions)

FieldTypeDefaultDescription
localestring'en'Active BCP 47–style locale code for t() lookup.
fallbackstring'en'Used when a key is missing in the active locale.
messagesRecord<string, Record<string, string>>{} (merged with built-in English)Map localeCode → { translationKey → string }. Package English keys live in gkEnMessages; en is merged with those keys.

Placeholders in strings use {name} syntax; pass values as the second argument to t().

defaults (GkKitComponentDefaults)

Flat map: component name (PascalCase) → prop name → value. Subtrees can add layers with GkDefaultsProvider.

aliases (GkKitAliases)

Map custom tag nameComponent or { extends: Component, defaults?: { … } }. See Aliases.


Theme (named global themes + system)

  • theme.defaultTheme can be light, dark, system, built-in presets (ocean, highContrast), or custom names.
  • DOM: active concrete theme name is written to data-gk-theme; gk-theme-dark is toggled based on resolved darkness.
  • theme.scope: optional HTMLElement, getter () => HTMLElement | null, or null — defaults to document.documentElement.
  • theme.themes: register custom themes with token overrides and optional extends.

Example runtime switching and dynamic registration:

ts
import { useGkTheme } from 'god-kit/vue/config'

const theme = useGkTheme()

theme.registerTheme('forest', {
  extends: 'dark',
  isDark: true,
  tokens: {
    '--gk-color-primary': '#22c55e',
    '--gk-color-primary-hover': '#16a34a',
  },
})

theme.change('forest')

For subtree theming, wrap sections with GkThemeProvider and pass theme (and optional local themes) to scope theme application without changing the app root.

See Design tokens for --gk-* variables.

Display (responsive breakpoints)

Configure via createGkKit({ display: { ... } }):

  • mobileBreakpoint: a breakpoint name (e.g. md) or a number (pixels) — mobile when width < that threshold.
  • thresholds: partial override of xsxxl lower bounds.

This is separate from color theme: “display” here means viewport / layout, not light vs dark.

Multiple locales

  1. Register all languages in locale.messages: each top-level key is a locale code (en, fr, ar, …); each value is a flat key → string map. English gkEnMessages is merged into en automatically.
  2. Set initial locale with locale.locale and locale.fallback (e.g. fallback en when a key is missing in the active locale).
  3. Switch at runtime by updating the ref from useGkLocale():
ts
import { useGkLocale } from 'god-kit/vue/config'

const { locale } = useGkLocale()
locale.value = 'fr'
  1. Subtree overrides: GkLocaleProvider accepts locale, optional messages, and rtl (sets dir on the wrapper). Child t falls back to the parent when a key is missing.

vue-i18n: use GkVueI18nAdapter if you need full ICU / pluralization; God Kit’s built-in t() stays minimal by design.

See also RTL and i18n.

Defaults

createGkKit({ defaults: { GkButton: { variant: 'primary' }, ... } }) sets global defaults keyed by component name (PascalCase).

GkDefaultsProvider merges additional defaults for a subtree (parent map first, then local overrides).

useGkDefaults('GkButton') returns a computed map of defaults for that component. mergeGkProps(defaults, props) merges defaults with instance props; class and style are combined (arrays flattened) instead of overwritten.

Contextual nesting (defaults per parent component type) is not implemented yet; use flat keys only for now.

Aliases

Pass aliases to createGkKit:

  • Component — register under a new tag: app.component('GkPrimaryButton', GkButton) equivalent.
  • { extends: Component, defaults?: { ... } } — registers a thin wrapper that merges default props via mergeProps.

You can also register aliases manually with app.component and add a defaults entry for the new name so useGkDefaults picks them up.

Tree shaking

The main export god-kit/vue uses named exports and sideEffects: ["**/*.css"] so unused components can be dropped. The global config entry god-kit/vue/config is a separate chunk for apps that want createGkKit and composables without pulling every primitive.

Dynamic <component :is="..."> still requires explicit imports for each resolved component (same limitation as Vuetify).

See Build and bundling for sideEffects and export tables.

Released under the MIT License.