This repo contains a collection of packages that makes the integration of Tailwind with CSS-in-JS libraries easier.
You may have encountered some of these problems when using Tailwind with CSS-in-JS libraries.
md:hover[text-xs font-normal]
tailwind.config.js
tailwind.config.js
customizationxwind uses a babel plugin that transforms Tailwind classes into CSS object styles or a classes string. The CSS object styles output can be used with your favorite CSS-in-JS library like emotion, styled-components ... The classes string output can be used with the xwind cli to generate a minimal css file of the used Tailwind classes.
import xw from "xwind";
const styles = xw`text-red-100 hover:text-green-100 hover:bg-blue-200`;
// OR (with custom array syntax)
const styles = xw`text-red-100 hover[text-green-100 bg-blue-200]`;
Transforms by default into Postcss-js / JSS compatible syntax:
const styles = {
"--text-opacity": "1",
color: ["#fde8e8", "rgba(253, 232, 232, var(--text-opacity))"],
"&:hover": {
"--text-opacity": "1",
"--bg-opacity": "1",
color: ["#def7ec", "rgba(222, 247, 236, var(--text-opacity))"],
backgroundColor: ["#c3ddfd", "rgba(195, 221, 253, var(--bg-opacity))"],
},
};
Transform to CSS string syntax with the css plugin:
const styles = `
--text-opacity: 1;
color: #fde8e8;
color: rgba(253, 232, 232, var(--text-opacity));
&:hover {
--text-opacity: 1;
--bg-opacity: 1;
color: #def7ec;
color: rgba(222, 247, 236, var(--text-opacity));
background-color: #c3ddfd;
background-color: rgba(195, 221, 253, var(--bg-opacity));
}
`;
objectstyles plugins make it possible to support any CSS-in-JS library syntax.
import xw from "xwind";
const styles = xw`text-red-100 hover:text-green-100 hover:bg-blue-200`;
// OR (with custom array syntax)
const styles = xw`text-red-100 hover[text-green-100 bg-blue-200]`;
Transforms into a classes string:
const styles = "text-red-100 hover:text-green-100 hover:bg-blue-200";
Generate the css output with with the xwind cli:
npx run xwind
Output file "/src/styles/xwind.css":
/*! Generated with xwind | https://github.com/arthie/xwind */
.hover\:bg-blue-200:hover {
--tw-bg-opacity: 1;
background-color: rgba(191, 219, 254, var(--tw-bg-opacity));
}
.text-red-100 {
--tw-text-opacity: 1;
color: rgba(254, 226, 226, var(--tw-text-opacity));
}
.hover\:text-green-100:hover {
--tw-text-opacity: 1;
color: rgba(220, 252, 231, var(--tw-text-opacity));
}
This package is a typescript language service plugin that adds editor support for xwind tagged template syntax: xw`...` or tw`...`
This extension activates typescript-xwind-plugin inside VS Code's Typescript language service.
Want to create Tailwind tools with javascript? Have a look at these packages they make the xwind and typescript-xwind-plugin possible.
The class-utilities package contains flexible utilities to compose and parse Tailwind classes.
The core package uses Tailwind internals to extracts/generate all the data you could want from Tailwind. It provides the data in a structured way with the necessary utilities to create and manipulate this data.
This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Tailwind Labs Inc., or any of its subsidiaries or its affiliates. The name Tailwind as well as related names, marks, emblems and images are registered trademarks of their respective owners.
The official Tailwind website can be found at https://tailwindcss.com/.
Please contact the project ower if there are any concerns regarding: Tailwind CSS brand assets and usage guidelines.
MIT. Copyright (c) 2020 Arthur Petrie.