Skip to content

Commit 1963517

Browse files
committed
Merge branch 'master' of github.com:formkit/docs-content
2 parents 45311af + 9ce02c3 commit 1963517

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

5.guides/create-a-tailwind-theme.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ npx formkit@latest theme --theme=formkit-theme-my-theme
380380
This command will produce a `formkit.theme.(mjs|ts)` file in your project's root directory. To complete the setup you will need to do the following two things:
381381

382382
- Import the `rootClasses` function from your built theme into your `formkit.config` file
383-
- Add the `formkit.theme` file to your `tailwind.config` file's `content` array.
383+
- Add a `@source` directive for the `formkit.theme` file in your CSS
384384

385385
```js
386386
// formkit.config.ts
@@ -395,16 +395,29 @@ export default defineFormKitConfig({
395395
})
396396
```
397397

398+
```css
399+
/* main.css (or your primary CSS file) */
400+
@import "tailwindcss";
401+
@source "./formkit.theme.ts";
402+
@source "./formkit.config.ts";
403+
```
404+
405+
::Callout
406+
---
407+
type: "tip"
408+
label: "Tailwind CSS 3"
409+
---
410+
If you're using Tailwind CSS 3, add the theme file to your `tailwind.config.js` content array instead:
398411
```js
399412
// tailwind.config.js
400413
module.exports = {
401-
...
402414
content: [
403415
"./app.vue",
404-
"~/formkit.theme" // <-- add your theme file
416+
"./formkit.theme.ts"
405417
]
406418
}
407419
```
420+
::
408421

409422
## Customizing the variables of a published theme
410423

@@ -429,7 +442,7 @@ Now you can use the `formkit` CLI to build your theme with your customizations a
429442
npx formkit@latest theme --theme=formkit.theme.config.ts
430443
```
431444

432-
Install the resulting `formkit.theme.(mjs|ts)` file by following the same instructions from the section above — adding the `rootClasses` to your `formkit.config` file and including the `formkit.theme.(mjs|ts)` file in your `tailwind.config` file's content array.
445+
Install the resulting `formkit.theme.(mjs|ts)` file by following the same instructions from the section above — adding the `rootClasses` to your `formkit.config` file and including the `formkit.theme.(mjs|ts)` file via `@source` directives in your CSS.
433446

434447
## Submitting your theme to themes.formkit.com
435448

_install/tailwind-install-instructions.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,31 @@ export default defineFormKitConfig({
3333
})
3434
```
3535

36-
Finally, youll need to add the `formkit.theme.{ts|js}` file to your Tailwind config file’s content property. This will ensure that the theme’s styles are included in your project’s CSS:
36+
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:
3737

38+
```css
39+
/* main.css (or your primary CSS file) */
40+
@import "tailwindcss";
41+
@source "./formkit.theme.ts";
42+
@source "./formkit.config.ts";
43+
```
44+
45+
::Callout
46+
---
47+
type: "tip"
48+
label: "Tailwind CSS 3"
49+
---
50+
If you're using Tailwind CSS 3, add the theme file to your `tailwind.config.js` content array instead:
3851
```js
3952
// tailwind.config.js
40-
/** @type {import('tailwindcss').Config} */
4153
module.exports = {
4254
content: [
4355
"./app.vue",
44-
"~/formkit.theme" // <-- add your theme file
45-
],
46-
darkMode: 'class',
47-
theme: {
48-
extend: {},
49-
},
50-
plugins: [],
56+
"./formkit.theme.ts"
57+
]
5158
}
5259
```
60+
::
5361

5462
If you run the command again, you will be taken to [https://themes.formkit.com](https://themes.formkit.com) where you can customize your chosen theme.
5563

0 commit comments

Comments
 (0)