Watch for changes, build for production and learn more about how _tw, WordPress and Tailwind work together
Watching for changes
During development you’ll probably want Tailwind to be watching your theme repository for changes and regenerating your style.css
file automatically:
npm run watch
The watch
command will run continuously in the background, keeping things up-to-date.
Adding custom CSS
Everything you need to configure Tailwind or to add custom CSS can be found in the ./tailwind
folder. The ./tailwind/tailwind.css
file imports a variety of other files to generate style.css
and style-editor.css
. (You should never edit those files directly, as they will be overwritten when new versions are generated.) There are comments throughout the CSS files in the ./tailwind
folder explaining what to put in each file.
Adding block editor–only CSS
The ./tailwind/tailwind-editor-extra.css
file is processed by Tailwind (so you can use @apply
and other Tailwind functionality), and its output file is style-editor-extra.css
, alongside the existing style.css
and style-editor.css
files. It is added by default as an editor style in ./theme/functions.php
.
JavaScript
_tw includes esbuild as its JavaScript bundler. For details on how to use it, including an example covering how to install and bundle Alpine.js, please see the dedicated documentation page on JavaScript Bundling with esbuild.
theme.json
Now with built-in theme.json
support, _tw includes a basic theme.json
file in its theme
folder. The color and width values from that file are automatically made available to Tailwind via a Tailwind plugin.
This means the top-level colors in theme.json
can be used in Tailwind (with classes like bg-primary
or text-primary
), and the values for contentSize
and wideSize
are available for setting max-width
with either max-w-content
or max-w-wide
.
Please note that if one or more of your color palette’s slug
values matches a slug in Tailwind’s default color palette, those colors from the default palette—including all shades—will be overridden by the color
value from your theme.json
file.
(Still not using the block editor? You can safely ignore the included theme.json
support entirely!)
Tailwind Typography
Tailwind Typography comes preinstalled with _tw. To learn how to set up the Typography plugin in your generated theme, please see the dedicated documentation page on using Tailwind Typography.
Tailwind plugins
Tailwind’s other first-party plugins are automatically installed when you run npm install
, but they won’t be active until you uncomment the appropriate line or lines in the plugins
block of your tailwind.config.js
file.