A utility-first CSS framework for rapidly building custom user interfaces.
Documentation
For full documentation, visit tailwindcss.com.
Community
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
Discuss Tailwind CSS on GitHub
For casual chit-chat with others using the framework:
Join the Tailwind CSS Discord Server
Contributing
If you're interested in contributing to Tailwind CSS, please read our contributing docs before submitting a pull request.
TypeError: getProcessedPlugins is not a function
Describe the problem:
Upgraded from TailwindCSS 1.9.6 to 2.0.1 for my angular project following the instructions on their website. I had previously used the following guide: https://notiz.dev/blog/angular-10-with-tailwindcss#setup to Install the previous version and that worked before.
Please see error below:
Custom class name completion contexts
There has been quite a few requests for the extension to support class name completions in contexts other than a standard class(Name) attribute.
Some examples:
tailwind.macro
andtwin.macro
(#46, tailwindlabs/tailwindcss-intellisense#123):tailwind-rn
(#99):tailwind-ppx
(#120):I just wanted to consolidate all of these requests into a single issue that can be tracked more easily, as I think the solution could be the same for each of them.
I am reluctant to hard-code each of these cases into the extension because none of them are "official" methods of using Tailwind, and it may become a maintenance burden.
However, I am open to the idea of adding a user setting which would allow the definition of custom regular expressions. For example for
tailwind-rn
your regular expression might be something like:/\btailwind\([^)]+/ig
If you're interested in this feature feel free to "watch" this issue for updates, and post any comments/suggestions you may have.
Add CSS Grid utilities
This PR adds support for CSS Grid Layout to Tailwind CSS.
Here is an example of what it looks like to use these new utilities:
It adds a new
grid
value to thedisplay
core plugin, as well as provides new core plugins for the following CSS properties:grid-template-columns
grid-column-gap
grid-column
grid-column-start
grid-column-end
grid-template-rows
grid-row-gap
grid-row
grid-row-start
grid-row-end
grid-template-columns
These utilities take the form
grid-cols-{key}
where "key" is any value configured under thegridTemplateColumns
key in your theme config.By default we provide the necessary values to create basic equal width column grids with up to 12 columns:
I've opted to avoid any weird magic here and instead just given the user complete control over the value of this property, so although I'm just using
repeat(x, 1fr)
here for each value, there's absolutely nothing stopping you from creating something more custom like so:Providing a basic 12 column grid seemed like the most sensible thing to do by default, as there aren't many other good ideas I can think of that are actually general purpose and not hyper-specific to one site design.
grid-column-gap
These utilities take the form
col-gap-{key}
where "key" is any value configured under thegridColumnGap
key in your theme config.By default, this uses your
spacing
config, and therefore matches all of your padding/margin/width/height utilities.grid-column
These utilities take the form
col-{key}
where "key" is any value configured under thegridColumn
key in your theme config.By default we only provide values for spanning across columns:
Again no magic or assumptions here at all — I've included the word
span
explicitly in each key to make sure the utilities are generated likecol-span-5
for our default values, but you can totally do whatever you want here, like:...to generate a class that fills a named column area like
col-logo-area
.The reason I've duplicated the value (like
span 2 / span 2
) is so that you can easily override just thegrid-column-start
orgrid-column-end
value without losing thespan
value, like this:...which would create an element that spans 4 columns but starts at grid line 2.
grid-column-start
These utilities take the form
col-start-{key}
where "key" is any value configured under thegridColumnStart
key in your theme config.By default we only provide values that match the grid lines created by our default
gridTemplateColumns
config:grid-column-end
These utilities take the form
col-end-{key}
where "key" is any value configured under thegridColumnEnd
key in your theme config.By default we only provide values that match the grid lines created by our default
gridTemplateColumns
config:grid-template-rows
These utilities take the form
grid-rows-{key}
where "key" is any value configured under thegridTemplateRows
key in your theme config.By default we do not provide any values for this utility at all:
That means no
grid-rows-{key}
utilities are generated by default, and if you'd like to add them you need to customize your config.This is because I just could not think of any sensible general purpose default values for this — any real-world use case I could come up with seemed too specific to a given design.
grid-row-gap
These utilities take the form
row-gap-{key}
where "key" is any value configured under thegridRowGap
key in your theme config.By default, this uses your
spacing
config, and therefore matches all of your padding/margin/width/height utilities.grid-row
These utilities take the form
row-{key}
where "key" is any value configured under thegridRow
key in your theme config.By default we do not provide any values for this utility at all:
That means no
row-{key}
utilities are generated by default, and if you'd like to add them you need to customize your config.This is for the same reason as
grid-template-rows
.grid-row-start
These utilities take the form
row-start-{key}
where "key" is any value configured under thegridRowStart
key in your theme config.By default we do not provide any values for this utility at all:
That means no
row-start-{key}
utilities are generated by default, and if you'd like to add them you need to customize your config.This is for the same reason as
grid-template-rows
.grid-row-end
These utilities take the form
row-end-{key}
where "key" is any value configured under thegridRowEnd
key in your theme config.By default we do not provide any values for this utility at all:
That means no
row-end-{key}
utilities are generated by default, and if you'd like to add them you need to customize your config.This is for the same reason as
grid-template-rows
.What's not included
grid-auto-columns
utilitiesgrid-auto-rows
utilitiesgrid-auto-flow
utilitiesgrid-template-areas
utilitiesIf you think any of these are super important in a utility context, please reply with a good example and any ideas you have on how it should be included and we can definitely talk about getting it in.
Try it out
Here's a simple tailwind.run where I've thrown in the pre-compiled CSS so you can play with it:
https://tailwind.run/MSuVJB/1
Any feedback appreciated!
Tailwind CSS v1.0 To-Dos
Have been keeping track of this stuff in my personal to-do tracker but publishing them here in case anyone is interested.
Naturally a ton of stuff has already been done for v1.0 and deleted from my to-do list, so this is only the stuff remaining as of today.
Expect this list to grow and change over the next few weeks as I work towards finishing v1.0, but generally these are the things I've got lined up. They aren't in any sort of priority order or anything.
Done/Merged
flex-*
customizable.clearfix
?~~ Nah still useful enough to not make people add it themselves.sm
breakpoint up to 640px?break-normal
handle both properties to provide a nicer experience@tailwind preflight
in your CSS or keys in the wrong place in your config file to help guide people during the upgrade process?~~ Whatever, can do this if it actually bites people.PR Opened
Next (painful)
Next (straightforward)
Next (could wait until after 1.0)
disabled
variant?Tailwind 2.0 poor performance as part of a webpack PostCSS build system
Description of the problem
Tailwind CSS 2.0 builds slowly as part of a HMR webpack build system. It is slower than the release, but that could just be due to the amount of CSS generated increasing.
I filed a very similar issue a month ago https://github.com/tailwindlabs/tailwindcss/issues/2544 and worked around the problem by splitting the CSS up into separate chunks. Global
@apply
still worked, and everything was great.It's all written up in the article Speeding Up Tailwind CSS Builds
However with Tailwind CSS 2.0, the technique described in the article breaks.
Desired solution
I'm hoping to have the DX of working with Tailwind CSS 2.0 be improved from a HMR build time perspective.
I realize that you can only optimize your generation of CSS so much, and a PR is in the works to do just that with
esbuild
. I also realize that part of the slowness here is simply webpack and the surrounding ecosystem being slow when dealing with massive amounts of CSS (though I've optimized that quite a bit here).However, the paradigm that Tailwind CSS is using is what generates a massive amount of CSS, and webpack is a very widely used tool that many things are built upon.
Some way to address the DX here would be great; huge gains can be made using the CSS splitting technique described in the article, maybe there could be a way to restore that functionality to Tailwind 2.x?
Link to a minimal reproduction:
I made a new branch with Tailwind 2.0, webpack 5, PostCSS 8, and all the goodness:
https://github.com/nystudio107/tailwind-css-performance/tree/problem-tailwind-2.x
While
2.5s
isn't awful, this is in a pretty minimal CSS setup, where I was getting about1.2s
for the equivalent builds in Tailwind 1.x, and using the technique described in the article, the builds were around182ms
Integrate PurgeCSS directly into Tailwind
This PR adds a new
purge
config option for purging unused CSS directly from within Tailwind instead of having to pull in and configure PurgeCSS manually.The API is much more opinionated and slimmed down by default, optimizing for the 95% use case:
The
purge
option accepts an array of filenames/globs to scan for classes, and that's it. This should be enough for most people, but if you are one of those people who just can't help themselves and has to fiddle with everything, you can fine-tune the configuration however you like (keep reading for more on that).Things to note:
This option is only enabled when
NODE_ENV
isproduction
. If you want to enable it explicitly based on some other conditional logic, you can use an object syntax and theenabled
property, and specify your templates using thecontent
property:Only components and utilities are purged by default. Our base styles are not purged, and no custom CSS authored in your CSS files is purged, including any imports to outside libraries.
This is to make sure you don't accidentally run into common pitfalls, like forgetting to scan your root HTML template (which is difficult with frameworks like Next.js since it is buried in
node_modules
) or accidentally purging styles that come from whatever datepicker library you've pulled in as an npm dependency.This means we are not purging absolutely everything that could be safely purged, but you get 99% of the benefit with much less manual tuning. You will basically never need to whitelist anything using this approach.
Essentially we make your CSS file look like this:
If you really want to purge everything, you can do so using
mode: 'all'
:You're much more likely to accidentally remove important styles if you do this but I'm not the cops — if it tickles your pickle go for it.
We are using a new extractor strategy that tries to be as permissive as possible.
Here is the new extractor we're using:
...and here is the sample HTML we test our purging against:
It works really well and I would be pretty surprised if you ever needed to customize this.
If you want more control than what we offer, you can pass any options you want directly to PurgeCSS using the
options
property:Any options passed to PurgeCSS will override our own options, so for example if you pass
content
it will override ourcontent
property at the top-level.Happy purging 🤮
npx tailwindcss init not working
Describe the problem:
Using tailwind in post-css compatibility mode
I've got tailwind 2.0 installed and the build process runs, however now I want to set up a config file so I can add custom colors etcetera. I run the
npx tailwindcss init
command and it fails with this output.I can see autoprefix in both package.json
"autoprefixer": "^9.8.6",
and the autoprefixer folder in the node_modules folder.Not sure how to resolve this, please advise.
CSS Transitions
This PR introduces a handful of CSS transition utilities. See the discussion at https://github.com/tailwindcss/tailwindcss/issues/14. It's mostly just a few new generators and updated docs/tests/etc, but it also includes a fix to the
variants-and-disabling
partial that allows for no variants.Dev server must be restarted to have classes applied with Snowpack
What version of @tailwindcss/jit are you using?
0.1.4
What version of Node.js are you using?
14.2.0
What browser are you using?
Chrome
What operating system are you using?
macOS
Reproduction repository
https://www.youtube.com/watch?v=G6d-SXdcJXs
Hi there ☺️
I tried to use this new JIT feature with a new React app built with Snowpack. Unfortunately, I cannot have Snowpack use Tailwind JIT properly.
I think I might have missed something about the configuration process. When changing a class in a component, I have to stop and restart the dev server. Here are my config files:
Thanks!
Poor performance as part of a webpack PostCSS build system
Using the latest Tailwind CSS (1.8.13 as of this writing), I'm seeing slowness very similar to https://github.com/tailwindlabs/tailwindcss/issues/1620 & also https://github.com/tailwindlabs/tailwindcss/issues/443, the performance of using HMR with
webpack-dev-server
and webpack 4 or 5 is quite slow.It takes about 10 seconds on my MacBook Pro 2019 just changing a single color in a
.pcss
file, and it appears externally that it's rebuilding everything each time. The building of Tailwind CSS seems to have gotten slower and slower as the amount of utilities it includes have gone up.I'm not sure what the caching implemented in 1.7.2 does, but in a long running process (and maybe it's already doing this but) what if all of the Tailwind-specific imports like:
...were cached in a long running process, so it just returns the pre-generated blob? I'd imagine you're probably already doing this, but have any instrumentation or profiling been hooked up to the build to determine where the bottlenecks are?
My postcss.config.js looks like this:
...and the whole setup is essentially what's here: https://nystudio107.com/blog/an-annotated-webpack-4-config-for-frontend-web-development#tailwind-css-post-css-config
It's not doing anything fancy re: the PostCSS part of the build, but its extremely slow compared to the HRM of JavaScript modules, etc.
I tried removing
postcss-preset-env
to see if it made a difference, but it doesn't seem to.Related: https://stackoverflow.com/questions/63718438/webpack-dev-server-slow-compile-on-css-change-with-tailwind
Transient read failure may cause permanent failure to watch file
V3.1.18 Tailwind CLI, Visual Studio 2022 as editor. Node v14.18.1 Chrome Window 10 (No Docker or WSL)
This issue is a very close relative of #7759, but I think it might be quite specialised so I don't want to pollute that one.
I have a rather odd web project, which has a single HTML file. So the content section of tailwind.config.js looks like this:
I run a tailwind CLI watcher with a command like this:
I am suffering from the problem described in #7759 where the watcher stops watching after a while - anywhere between almost immediately and after lots and lots of successful rebuilds.
By using the "Process Monitor" utility to observe the filesystem activity on the index.html file, I have observed that when Visual Studio (devenv.exe) is saving index.html, it goes through a rename/replace process which means there is a window of time in which the index.html file does not actually exist. It appears that node.exe (i.e. Tailwind) sometimes tries to read the file during this window and finds it to be missing.
This apparently causes Tailwind to stop watching that file.
The blue selected line in the image is Node getting a file-not-found failure doing a CreateFile (it's actually an open-to-read) on index.html in the middle of devenv doing a rename dance. I think that's a smoking gun.
If I change the content file specification to be a wildcard, then my first impression is that things are much more robust:
So:
Even without the specific Visual Studio rename thing, transient read failures are probably an inescapable feature of Windows, because it's so common that people have tools like anti-virus and cloud-backup and indexers which do lots of automatic file opening.
Add logical properties support for inline direction
This PR introduces support for logical properties in the inline direction for all relevant existing utilities, making it easier to build sites that support LTR and RTL layouts without having to use the
rtl:
variant when you simply need to mirror the styles.| New class | Properties | Physical counterpart (LTR) | | -------------- | -------------------------------------------------------- | -------------------------- | |
start-*
|inset-inline-start
|left-*
| |end-*
|inset-inline-end
|right-*
| |ms-*
|margin-inline-start
|ml-*
| |me-*
|margin-inline-end
|mr-*
| |ps-*
|padding-inline-start
|pl-*
| |pe-*
|padding-inline-end
|pr-*
| |rounded-s-*
|border-start-start-radius
border-end-start-radius
|rounded-l-*
| |rounded-e-*
|border-start-end-radius
border-end-end-radius
|rounded-l-*
| |rounded-ss-*
|border-start-start-radius
|rounded-tl-*
| |rounded-se-*
|border-start-end-radius
|rounded-tr-*
| |rounded-ee-*
|border-end-end-radius
|rounded-br-*
| |rounded-es-*
|border-end-start-radius
|rounded-bl-*
| |border-s-*
|border-inline-start-width
|border-l-*
| |border-e-*
|border-inline-end-width
|border-r-*
| |border-s-*
|border-inline-start-color
|border-l-*
| |border-e-*
|border-inline-end-color
|border-r-*
| |scroll-ms-*
|scroll-margin-inline-start
|scroll-ml-*
| |scroll-me-*
|scroll-margin-inline-end
|scroll-mr-*
| |scroll-ps-*
|scroll-padding-inline-start
|scroll-pl-*
| |scroll-pe-*
|scroll-padding-inline-end
|scroll-pr-*
|Considerations
This PR is limited to supporting the inline direction only, as supporting the block direction introduces potential naming collisions that make the API design more challenging, for example is
mb-2
formargin-bottom
ormargin-block
?After a bunch of research and talking to people in the community, I'm convinced that in practice supporting the block direction has far fewer benefits than supporting the inline direction, so I've opted to support just the inline direction for now to avoid being blocked on the API and get this feature shipped so people can start benefitting from it today. We can always introduce support for the block direction separately in the future — no need for them to be introduced together and slow down the process.
Right now we are using the shortest names possible like
ps-*
but if we eventually add block support and feel like that's too ambiguous, we can always support a more verbose version likep-is-*
so that the block direction equivalent can bep-bs-*
. My gut is that the block direction stuff will be needed so infrequently that simply making the block direction more verbose and keeping the inline ones terse is actually going to be the better trade-off though.This PR does not include support for the logical values of
clear
orfloat
, as browser support is currently poor. We can of course revisit this in the future and add them another day when support is better.npx tailwindcss .... --watch is locking my files
I've installed the latest version of Tailwind (December 2022) and am using this guide : https://chrissainty.com/adding-tailwind-css-v3-to-a-blazor-app/
using this command: npx tailwindcss -i ./app.css -o ./wwwroot/css/app.css --watch
While editing the Blazor files, the Powershell terminal compiles my CSS and is somewhat working fine.
However - at some point i can't save the Razor / CSHTML files in Visual Studio because the files are locked by NPX / Node I then have to close Powershell / Tailwind builder to save my files.
Ultimately - i would much rather like to work with a pre-compiled subset version of Tailwind but have had a hard time finding the right way to select which features i want. That way i would have functioning Intellisense in Visual Studio.
`prefix` option + `modifier` + `arbitrary variant`: extra prefix is generated for classes inside variant
prefix: "tw-",
+hover:[&.header-is-scrolled_.menu-list_a]:tw-text-[#FF0000]
generates:expected result:
Tailwind Play Link
feat: add hyphens
In german language we have many long words. We concat cohesive words without whitespaces. It's pretty easy to have words with 15+ characters. The german language also has strict rules how to hyphenate based on syllables, so the https://tailwindcss.com/docs/word-break does not help at all for normal language.
So the hyphens rule comes in pretty handy: https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens
It's pretty straight forward addition, that's requested by a few people:
Add support for configuring default `font-variation-settings` for a `font-family`
I wanted to add default
font-variation-settings
for the beta version of the font, where Inter Display was merged into Inter as an optical-size axis. However, I discovered that there is no support for this option in the current codebase.This pull request adds support for configuring default
font-variation-settings
for afont-family
, which will allow users to change the way it is rendered in their projects. This will give users more flexibility when it comes to font customization.I decided not to open a feature request for this change as it may not be significant enough, and I hope that's okay. Thank you for considering this change, and for all the work you've done on this amazing framework! ❤