A helper for getting tailwind values into css custom properties and switching them between media queries and classes. You can try it out here: https://play.tailwindcss.com/Gt21fePNvv
The tailwindcss-theme-swapper is a tool that extends the Tailwind CSS framework by allowing users to customize their theme through CSS Custom Properties. This tool provides the ability to update and modify these custom properties using various selectors or media queries. The only requirement for using this tool is support for CSS Custom Properties, although it is worth noting that IE11 may have limited functionality unless supplemented with postcss-preset-env.
To install tailwindcss-theme-swapper, follow these steps:
npm install tailwindcss-theme-swapper
or
yarn add tailwindcss-theme-swapper
tailwind.config.js):const themeSwapper = require('tailwindcss-theme-swapper');
module.exports = {
// Your Tailwind config options here
plugins: [
// Other plugins
themeSwapper,
],
};
tailwind.config.js file:module.exports = {
theme: {
extend: {
// Your existing Tailwind config options here
},
swapper: {
// Define your CSS Custom Properties here
},
},
variants: {
// Your Tailwind variant options here
},
plugins: [
// Other plugins
],
};
.example-element {
background-color: var(--primary-color); /* Example use of a CSS Custom Property */
}
Please note that the above steps are a simplified guide and you may need to refer to the official documentation for more detailed instructions.
The tailwindcss-theme-swapper tool extends the functionality of the Tailwind CSS framework by allowing users to easily customize their theme using CSS Custom Properties. With minimal installation steps, users can add and update these properties to create unique and personalized designs. This tool is a valuable addition for Tailwind CSS users who want more flexibility and control over their project’s theme.