@composy/theme-vue

LDesign 主题管理 - Vue 3 适配器
Install
npm install @composy/theme-vue
Latest Version:0.0.2
Vue:3
License:MIT
Last Updated:Oct 12, 2026
Links: npm
Maintainer: swimly

@composy/theme-vue 📦

LDesign 主题管理 - Vue 3 适配器

📦 安装

pnpm add @composy/theme-vue

🚀 快速上手

import { createThemePlugin, useDesignTokens, useThemeMode } from '@composy/theme-vue'
import { createApp, defineComponent, h } from 'vue'

const App = defineComponent({
  setup() {
    const { mode, setMode } = useThemeMode()
    const { tokens } = useDesignTokens()
    return () =>
      h(
        'button',
        { onClick: () => setMode(mode.value === 'dark' ? 'light' : 'dark') },
        tokens.value.colors.primary
      )
  },
})

const app = createApp(App)
app.use(createThemePlugin({ mode: 'auto' }))
app.mount('#app')

📚 导出 API

  • useTheme
  • useThemeMode
  • useDesignTokens
  • createThemePlugin
  • useThemeManager

插件创建的 ThemeManager 会随 Vue app 生命周期清理;独立 composable 创建的 manager 也会在组件卸载时销毁。

🎮 在线体验

cd playground
pnpm install
pnpm dev

开发校验

在此包目录运行:

npm run build
npm run type-check
npm run lint:check

Builder、TypeScript 和 ESLint 的权威配置位于 .ldesign/;包根配置文件保留为兼容入口。

📄 License

MIT © LDesign Team

useThemeMode() shares the injected ThemeManager with useTheme() and does not create a second matchMedia or DOM state machine. For multiple theme regions on one page, pass a different target element to each plugin, for example createThemePlugin({ mode: 'dark', target: panel }).

Related Packages

@qingmingmu/theme

青冥组件系统 —— CSS 变量主题系统

616
js-theme-switcher

A lightweight, framework-agnostic color palette theme switcher using CSS variabl...

361 0
@kaveraa/followtheme

A scoped theme follows the overlays it opens: dialogs, popovers and toasts porta...

307 0
skinsuite

多主题 / 多版式机制的纯内核(零运行时依赖):目录名与默认值的白名单常量、主题包...

416 0
@maz-ui/themes

Theme system for Maz-UI with TypeScript support and CSS variables

158,459 565

Version History

Version Released Vue License
0.0.2 3.5.32 MIT
0.0.1 ^3.5.32 MIT