This repo contains a collection of packages that makes the integration of Tailwind with CSS-in-JS libraries easier.
Why does this exist?
You may have encountered some of these problems when using Tailwind with CSS-in-JS libraries.
- You have to use PurgeCSS to get the minimal CSS file, PurgeCSS relies on string matching
- No warnings when misspelling, refactoring or using a class that doesn't exist
- Inline classes can get very long and hard to read
- You have to specify the variants for utility classes in tailwind.config.js
Features / Goals
- Solve all of the above problems
- Automatically compatible with latest Tailwind version 2.X.X
- New syntax to apply variants to multiple utility classes
md:hover[text-xs font-normal]
- Reacts to changes in made in
tailwind.config.js
- Great developer experience with VS Code extension or typescript-xwind-plugin
- No runtime impact all transformations happen during build time
- Plugins to support any/your favorite CSS-in-JS syntax
Support for all Tailwind features:
- All utility and component classes
- All variant utility classes enabled
- Full support for custom classes and
tailwind.config.js
customization - Supports Tailwind plugins (@tailwindcss/typography, @tailwindcss/forms, ...)
Packages
xwind
xwind 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.
Output mode "objectstyles" example
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.
Output mode "classes" example
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));
}
Full xwind package documentation
typescript-xwind-plugin
This package is a typescript language service plugin that adds editor support for xwind tagged template syntax: xw`...` or tw`...`
xwind VS Code extension
This extension activates typescript-xwind-plugin inside VS Code's Typescript language service.
Developer packages
Want to create Tailwind tools with javascript? Have a look at these packages they make the xwind and typescript-xwind-plugin possible.
@xwind/class-utilities
The class-utilities package contains flexible utilities to compose and parse Tailwind classes.
@xwind/core (WIP)
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.
Non-Affiliation disclaimer
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.
License
MIT. Copyright (c) 2020 Arthur Petrie.
Support for experimental dark mode
Hi there,
When I try to use experimental dark mode, I get an error:
Here's the snippet:
Here's the config file:
Interestingly, the vscode plugin renders a tooltip correctly:
Any thoughts? :)
Font weight not generated with removeFallbacks plugin
With the removeFallbacks plugin, font-weight is not generated anymore since the update to tailwindcss 2.0 and xwind.
With the removeFallbacks plugin, tw
font-bold
emits an empty fontWeight objectv14.1 broken path for tailwindcss-data
After upgrading from v13 to v14 now getting this coming from macros
Allow customizable tailwind config file location
First off, thanks for making this library @Arthie! Really great work.
I'm using this package with create-react-app and emotion. I'd like to be able to import my tailwind config and pass it to emotion's theme provider. In order to do this with create-react-app however, the tailwind config has to be under the
src
folder.This PR adds the ability to specify a custom config file path using babel-plugin-macros'
config
option. This allows the user to specify aconfigFilePath
under the tailwindcssinjs config. For example, in package.json you can do:Let me know what you think! 🙂 If you are okay with this change I can include updated documentation on this PR as well.
[BABEL] Error unknown: Preset
i am trying to add @tailwindcssinjs/macro to existing nextjs app with ant design and i got this error
its working when using macro from tailwind.macro
Styled-components doesn't support fallbacks (Wrong compiled colors with tailwind >1.4.x)
Hey!
I just tried your library because it supports the latest versions of tailwind out of the box. However, I've had some issue with colors being wrongly generated.
I have the following styled component:
When compiling it with Babel, it generates the following:
The --border-opacity variable shouldn't be there. This generates the css:
border-color: #e2e8f0", "rgba(226, 232, 240, var(--border-opacity))
which is invalid. I had the same issue with a background-color.I'm using
@tailwindcssinjs/macro
0.3.1 andtailwindcss
1.4.4typescript-xwind-plugin: Auto complete not working without VS Code xwind plugin
Firstly thanks for the project @Arthie , it is easy to setup and make developer experience better IMO.
I wanted to enable auto complete for tw classes without installing xwind VS Code Extension. I followed the steps in typescript-xwind-plugin page but I couldn't make it work.
Checklist:
C:/Users/tkaplan/Documents/projects/xwind-test/react-app/tailwind.config.js
(also tried./tailwind.config.js
)Changes to the tailwind.config.js not taking effect in the xw types
I adjusted the tailwindcss theme, but my changes are not showing on the xw types and it logs errors
the error says "bg-yellow-dark is not a tailwind class, but its still works on the browser
I got the template from nextjs template for emotion and tailwindcss
Please help out🥺🥺
nextjs example run error
current document example err "Codesandbox with Typescript, Nextjs and Emotion"
and https://github.com/vercel/next.js/blob/canary/examples/with-tailwindcss-emotion/README.md
example run same error
help with tailwindcss-data usage
Hey folks,
I'm interested in building a tailwind cheatsheet which should be able to programmatically generate a list of tailwind classes given a config. I think
tailwindcss-data
might be able to help me with this, but I don't quite get how it all fits together. It seems that, based on the usage insidemacro
and thetypescript
, it's not a simple procedure and requires lots of deeper postcss knowledge.Would you be willing help me out with a concise example on how to go from
tailwindData(config, corePlugins)
to a list of generated classnames?Thanks in advance!
css flicker
Hello! Thanks for the great plugin, loving xwind so far (with nextjs). However, I'm getting some flicker (see https://easyblog-72jw8j77y.vercel.app), which is based off the nextjs starter. You can see the buttons flicker into position from lower to higher. https://www.loom.com/share/754773e26397462f852001c9b9fbb91d (here's a video if it's not showing on your end).
I tried to inline critical css to see if that would help, but emotion doesn't seem to be pulling any styles, not sure if it's trying to pull them before they're processed by xwind?
I created a
_document.js
with the following to extract critical. Any ideas? Thanks!Bump json5 from 2.1.3 to 2.2.3
Bumps json5 from 2.1.3 to 2.2.3.
Release notes
Sourced from json5's releases.
Changelog
Sourced from json5's changelog.
Commits
c3a7524
2.2.394fd06d
docs: update CHANGELOG for v2.2.33b8cebf
docs(security): use GitHub security advisoriesf0fd9e1
docs: publish a security policy6a91a05
docs(template): bug -> bug report14f8cb1
2.2.210cc7ca
docs: update CHANGELOG for v2.2.27774c10
fix: add proto to objects and arraysedde30a
Readme: slight tweak to intro97286f8
Improve example in readmeDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)@dependabot use these labels
will set the current labels as the default for future PRs for this repo and language@dependabot use these reviewers
will set the current reviewers as the default for future PRs for this repo and language@dependabot use these assignees
will set the current assignees as the default for future PRs for this repo and language@dependabot use this milestone
will set the current milestone as the default for future PRs for this repo and languageYou can disable automated security fix PRs for this repo from the Security Alerts page.
Bump qs from 6.5.2 to 6.5.3
Bumps qs from 6.5.2 to 6.5.3.
Changelog
Sourced from qs's changelog.
Commits
298bfa5
v6.5.3ed0f5dc
[Fix]parse
: ignore__proto__
keys (#428)691e739
[Robustness]stringify
: avoid relying on a globalundefined
(#427)1072d57
[readme] remove travis badge; add github actions/codecov badges; update URLs12ac1c4
[meta] fix README.md (#399)0338716
[actions] backport actions from main5639c20
Clean up license text so it’s properly detected as BSD-3-Clause51b8a0b
add FUNDING.yml45f6759
[Fix] fix for an impossible situation: when the formatter is called with a no...f814a7f
[Dev Deps] backport from mainDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)@dependabot use these labels
will set the current labels as the default for future PRs for this repo and language@dependabot use these reviewers
will set the current reviewers as the default for future PRs for this repo and language@dependabot use these assignees
will set the current assignees as the default for future PRs for this repo and language@dependabot use this milestone
will set the current milestone as the default for future PRs for this repo and languageYou can disable automated security fix PRs for this repo from the Security Alerts page.
Bump decode-uri-component from 0.2.0 to 0.2.2
Bumps decode-uri-component from 0.2.0 to 0.2.2.
Release notes
Sourced from decode-uri-component's releases.
Commits
a0eea46
0.2.2980e0bf
Prevent overwriting previously decoded tokens3c8a373
0.2.176abc93
Switch to GitHub workflows746ca5d
Fix issue where decode throws - fixes #6486d7e2
Update license (#1)a650457
Tidelift tasks66e1c28
Meta tweaksDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)@dependabot use these labels
will set the current labels as the default for future PRs for this repo and language@dependabot use these reviewers
will set the current reviewers as the default for future PRs for this repo and language@dependabot use these assignees
will set the current assignees as the default for future PRs for this repo and language@dependabot use this milestone
will set the current milestone as the default for future PRs for this repo and languageYou can disable automated security fix PRs for this repo from the Security Alerts page.
Bump minimatch from 3.0.4 to 3.1.2
Bumps minimatch from 3.0.4 to 3.1.2.
Commits
699c459
3.1.22f2b5ff
fix: trim pattern25d7c0d
3.1.155dda29
fix: treat nocase:true as always having magic5e1fb8d
3.1.0f8145c5
Add 'allowWindowsEscape' option570e8b1
add publishConfig for v3 publishes5b7cd33
3.0.620b4b56
[fix] revert all breaking syntax changes2ff0388
document, expose, and test 'partial:true' optionDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)@dependabot use these labels
will set the current labels as the default for future PRs for this repo and language@dependabot use these reviewers
will set the current reviewers as the default for future PRs for this repo and language@dependabot use these assignees
will set the current assignees as the default for future PRs for this repo and language@dependabot use this milestone
will set the current milestone as the default for future PRs for this repo and languageYou can disable automated security fix PRs for this repo from the Security Alerts page.
Bump jsdom from 16.4.0 to 16.7.0
Bumps jsdom from 16.4.0 to 16.7.0.
Release notes
Sourced from jsdom's releases.
... (truncated)
Changelog
Sourced from jsdom's changelog.
... (truncated)
Commits
1aa3cbc
Version 16.7.0df1f551
Don't run WebSocketStream testseb105b2
Fix browser tests by enabling SharedArrayBuffer0dedfc0
Fix some bad cascade computation in getComputedStyle()8021a56
Fix "configuation" typo (#3213)a7febe3
Fix typo in level2/html.js (#3222)c9896c0
Return x, y properties from Element.getBoundingClientRect (#3187)346ea98
Update web-platform tests (#3203)364c77d
Bump to ws 7.4.693ba6a0
We are now on Matrix (#3207)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)@dependabot use these labels
will set the current labels as the default for future PRs for this repo and language@dependabot use these reviewers
will set the current reviewers as the default for future PRs for this repo and language@dependabot use these assignees
will set the current assignees as the default for future PRs for this repo and language@dependabot use this milestone
will set the current milestone as the default for future PRs for this repo and languageYou can disable automated security fix PRs for this repo from the Security Alerts page.
Bump minimist from 1.2.5 to 1.2.6
Bumps minimist from 1.2.5 to 1.2.6.
Commits
7efb22a
1.2.6ef88b93
security notice for additional prototype pollution issuec2b9819
isConstructorOrProto adapted from PRbc8ecee
test from prototype pollution PRDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)@dependabot use these labels
will set the current labels as the default for future PRs for this repo and language@dependabot use these reviewers
will set the current reviewers as the default for future PRs for this repo and language@dependabot use these assignees
will set the current assignees as the default for future PRs for this repo and language@dependabot use this milestone
will set the current milestone as the default for future PRs for this repo and languageYou can disable automated security fix PRs for this repo from the Security Alerts page.