This is a starter project for creating Tailwind CSS 3 plugins.
- Includes examples for:
addBaseaddUtilitiesmatchUtilitiesaddComponentsaddVariant- exposing options
- providing default values
- Tests with
Vitest - Coverage with
v8 - Releases with
np
Clone the project from GitHub:
git clone https://github.com/maizzle/tailwindcss-plugin-starter.gitInstall dependencies:
cd tailwindcss-plugin-starter
npm installWrite your plugin in the src/index.js.
Use the provided examples or see the Tailwind CSS plugin documentation.
Add tests in the src/index.test.js file or create your own test files.
Use npm run dev to start the test runner in watch mode.
Use npm test to run the tests once, with a coverage report.
- Update this
README.mdfile. - Update the
LICENSEfile. - Update plugin name, description etc in
package.json. If this is the first release, leave the version number as0.0.0andnpwill bump it for you (docs). - Update
CHANGELOG.mdor remove it if you're not going to keep a changelog. - Commit and push your changes.
- Run
npm run releaseto publish your plugin to npm.
Replace this text with a short description of what the plugin does.
Install the plugin from npm:
npm install -D tailwindcss-plugin-nameThen add the plugin to your tailwind.config.js file:
module.exports = {
theme: {
// ...
},
plugins: [
require('tailwindcss-plugin-name'),
// ...
],
}Provide instructions for how to use the plugin.
If your plugin is configurable, show users how to configure it.
// tailwind.config.js
module.exports = {
plugins: [
require('tailwindcss-plugin-name')({
className: 'markdown',
}),
// ...
],
}