Comments (6)
One solution is to escape the string in less:
background: ~"color(red a(90%))";
from discuss.
Hey @aphofstede! The reason this isn't working as you'd expect is that Less processes your CSS before Tailwind does; Tailwind is meant to work on Less' output.
That means that Less is literally trying to run the code fade(config('colors.grey'), 50%)
, because Tailwind hasn't replaced the config call with the actual color value by the time Less is trying to apply the fade function.
The best way to add transparent variations of colors would be to add them as new colors in your tailwind.js
config file.
Another approach that I bet would work is to use the postcss-color-function
plugin, which would let you do that sort of alpha channel manipulation in the PostCSS phase:
.input[type=text], .input[type=password] {
background-color: color(config('colors.grey'), a(50%));
}
I haven't tested it myself but it should work.
from discuss.
Thanks @adamwathan , that makes sense. It takes a bit of getting used to the pipeline I guess. (the PostCSS step is new, for me)
I added 'teal-lightest-half-transparent': 'rgba(232,255,254,0.5)',
to the colors array.
In my app.css
it appears to have rendered correctly:
.bg-teal-lightest-half-transparent,
.hover\:bg-teal-lightest-half-transparent:hover {
background-color: rgba(232, 255, 254, 0.5);
}
So I can do:
input[type=text], input[type=password] {
@apply .bg-teal-lightest-half-transparent;
}
Yet I get background-color: undefined
in the CSS if I try to do:
input[type=text], input[type=password] {
background-color: config('colors.teal-lightest-half-transparent');
}
the docs imply that that should work?
from discuss.
@aphofstede Can you share a demo repo so I can try it out? Are you sure it's in the colors array and not just the backgroundColors
array? Try config('backgroundColors.teal-lightest-half-transparent')
and see if that makes a different 👍
from discuss.
Can't reproduce it anymore.. I think you might be right about the backgroundColors array actually, good instinct! 🤭 😄 Thanks
from discuss.
I know this is closed, but unfortunately the trick with postcss-color-function
won't work with LESS, because it has its own color
function. The LESS compiler is therefor throwing an error and not passing it on to the postcss pipeline. You can use this npm lib instead though: postcss-color-mod-function
, which uses "color-mod" as the function name instead.
from discuss.
Related Issues (20)
- Dissapear all no-overrided CSS-classes in *.scss after upgrade from 1.1.3 to 1.2.0
- Looking for feedback on a new plugin: tailwindcss-logical (CSS Logical Properties and Values / RTL)
- Left align columns with css grid HOT 2
- unable to complete installation due to unresponsive npx commands to create necessary files. HOT 6
- Circle - part of it colored HOT 1
- @apply focus:outline-none throw error HOT 2
- Multiple psuedo selectors HOT 1
- does possible use Tailwind like a base "normal" CSS framework? HOT 1
- Possible to prefix the reset CSS rules with ID selector on build? HOT 4
- Export CSS output to JSON HOT 1
- Positioning of HTML elements
- Class .-translate-y-1/2 is not working HOT 2
- Cascade style classes?
- Only prefix custom component plugins with addComponents HOT 1
- Tailwind not working in angular component scss file
- Utility classes are completely missing HOT 1
- @apply not working in imported css with `a {}` only HOT 2
- Different color schemes for different users HOT 2
- Better support for styling for print
- More Fonts Families Out of the Box
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from discuss.