@formkit/theme-creator

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

🎨 Official theme creator for FormKit themes

原始使用文档
文档目录5 节
  1. To do
  2. Usage
  3. Creating a theme
  4. Using a theme
  5. Publishing a theme

FormKit Theme Creator

CI

Use this package to build your own FormKit theme and (optionally) share it with the world.

To do

  • Add min/max for variables to clamp values within a range.
  • Add custom scales to variables.

Usage

Themes are written using createTheme with tailwindcss classes and will output a theme file that can be imported into your FormKit configuration — or alternatively a semantic stylesheet will be generated automatically from the tailwind classes you define.

Creating a theme

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',
    }
  }
})

Using a theme

Once your theme is created, users can import it and use it to generate their own class list, or they can use the semantic stylesheet that is generated automatically. They are also able to configure the theme prior to generation.

// 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'
    }
  }
})

Publishing a theme

When publishing your theme to npm, you should use the formkit-theme- prefix. This will allow users to easily find your theme by searching for formkit-theme- on 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 是什么?

🎨 Official theme creator for FormKit themes

如何安装 @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 和提交记录判断。