The easiest way to get started with FormKit Tailwind Themes is to install the themes package and head to themes.formkit.com, customize a theme, and choose Download theme.
FormKit Themes
Versatile, configurable, MIT-licensed Tailwind themes for use in your projects. Spend less time styling — more time building.
Alternatively, you can use the FormKit CLI to select a theme for your project. Run the following command in the same directory as your formkit.config.{ts|js} file:
npx formkit@latest theme
This command will create a formkit.theme.{ts|js} file in the root of your project. To complete the setup you will need use the rootClasses from this theme file in your formkit.config.{ts|js}:
// formkit.config.ts
import { defineFormKitConfig } from '@formkit/vue'
import { rootClasses } from './formkit.theme'
export default defineFormKitConfig({
config: {
rootClasses,
},
})
Finally, you'll need to add the formkit.theme.{ts|js} file to your CSS using a @source directive. This ensures Tailwind scans the theme file for class names to include in your CSS:
/* main.css (or your primary CSS file) */
@import "tailwindcss";
@source "./formkit.theme.ts";
@source "./formkit.config.ts";
If you're using Tailwind CSS 3, add the theme file to your tailwind.config.js content array instead:
// tailwind.config.js
module.exports = {
content: [
"./app.vue",
"./formkit.theme.ts"
]
}
If you run the command again, you will be taken to https://themes.formkit.com where you can customize your chosen theme.
# with existing formkit.theme file in your project root
> npx formkit@latest theme
? Found local theme file for <themeName>, edit this theme? › (Y/n)
By default, the icons required by FormKit will be loaded from CDN when requested. If you prefer to include the icons directly in your bundle for increased perfomance, to avoid any pop-in, or to alleviate possible SSR issues, then import the genesisIcons set from @formkit/icons and spread them into the icons property of your FormKit config:
Once you have a theme in your project, you can customize it further by following the documentation provided in the styling section of the FormKit docs.