@formkit/theme-creator

中文文档
2.0.0发布于 2025/12/13MITTypeScriptESM + CJS近 30 天下载 1.1万

QQ FormKit 主题的官方主题创建者

中文使用文档
文档目录5 节
  1. 来做
  2. 使用量
  3. 创建主题
  4. 使用主题
  5. 发布主题

FormKit 主题创建者

CI

使用此软件包来构建自己的FormKit主题并(可选)与世界共享.

来做

  • 为变量添加分/ 最大值以锁定一个范围内的值.
  • 在变量中添加自定义缩放 .

使用量

主题使用 createTheme 与 尾风 分类,并输出一个可以导入到窗体Kit配置中的主题文件——或者自动生成语义样式表 从 您定义的尾风类 .

创建主题

import { createTheme } from '@formkit/theme-creator';

export default createTheme({
  // Define your theme details here:
  meta: {
    name: 'Midnight blizzard',
    description: 'A cold and blustery theme for FormKit',
    formkitVersion: '^1.2.0',
    darkMode: true,
    supportedInputs: ['text', 'textarea', 'select']
    author: 'Justin Schroeder',
    authorLink: 'https://x.com/jpschroeder'
  },
  variables: {
    borderColor: {
      // Allow the theme editor to modify this variable with the "color" widget.
      editor: 'color', 
      // Only use tailwind base colors for editable variables.
      value: 'slate'
    },
    darkModeBorderColor: {
      // Allow the theme editor to modify this variable with the "color" widget.
      editor: 'color', 
      // Only use tailwind base colors for editable variables.
      value: 'white'
    },
    spacing: {
      editor: 'spacing',
      // Use tailwind spacing scale for editable variables.
      value: '2'
    },
    // This variable is not editable by GUI theme editor, but can be changed
    // by a user who wants to manually configure the theme.
    errorColor: 'red-500',
  },
  // Define your theme styles here for each input type.
  inputs: {
    text: {
      // Use the variables defined above in your styles by prepending a `$`.
      // These will be directly replaced in your class list.
      inner: 'p-$spacing bg-white/10 rounded-md border-$borderColor-100 dark:border-$darkModeBorderColor-50',
    }
  }
})

使用主题

一旦创建了您的主题, 用户可以导入并使用它生成自己的主题 类列表,也可以使用自动生成的语义样式表. 它们也可以在生成前配置主题.

// formkit-theme.config.ts
import midnightBlizzard from 'formkit-theme-midnight-blizzard'

export default midnightBlizzard({
  errorColor: 'red-300'
}, {
  // Users can change some of your classes here, they can even use the variable
  // names. These classes will be merged with the theme’s classes using
  // tailwind-merge.
  inputs: {
    text: {
      // Here they want the darkmode border color to be a bit stronger:
      inner: 'dark:border-$darkModeBorderColor-100'
    }
  }
})

发布主题

在向 npm 发布主题时, 您应该使用 formkit-theme- 前缀。 这将允许用户通过搜索轻松找到您的主题 formkit-theme- 时间npm.

版本与发布记录

@formkit/theme-creator 共发布 21 个版本,首次发布于 2023/10/05;过去 12 个月发布了 1 个版本。

版本发布日期距今
2.0.0latest2025/12/1311 个月前
0.11.12024/02/032 年前
0.11.02024/02/032 年前
0.10.02024/01/242 年前
0.9.12023/11/302 年前
0.9.02023/10/213 年前

关于 @formkit/theme-creator 的常见问题

@formkit/theme-creator 是什么?

QQ FormKit 主题的官方主题创建者

如何安装 @formkit/theme-creator?

在项目目录运行 npm install @formkit/theme-creator,或使用 pnpm add / yarn add / bun add。

@formkit/theme-creator 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@formkit/theme-creator 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@formkit/theme-creator 可以商用吗?

@formkit/theme-creator 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@formkit/theme-creator 的下载量有多少?

根据 npm 官方下载统计,@formkit/theme-creator 在 2026/10/16 – 2026/11/14 这 30 天内被下载 10,961 次,日均约 365 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@formkit/theme-creator 还在维护吗?

最新版本 2.0.0 发布于 2025/12/13(11 个月前);至今共发布 21 个版本,其中过去 12 个月发布了 1 个;首次发布于 2023/10/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。