Feature Request: More shadow utilities / classes #3426
Replies: 2 comments
-
The issue shows more people would like something like this (scroll down for all the upvotes) My proposal would also make this easier to achieve: |
Beta Was this translation helpful? Give feedback.
-
I just published a Tailwind plugin that elegantly solves this, called For example: <div class="shadow-lg shadow-slate-900/20 shadow-b-2 shadow-r-[3px] -shadow-spread-2">...</div> Github: https://github.com/kaelansmith/tailwind-extended-shadows |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In my projects I use a healthy amount of dynamic shadows. I always add our own presets as the current defaults are lacking options related to color, inset/outset, blur, spread, offset and more. I think many users of tailwind could appreciate better out-of-the-box shadow options.
Here is the set of classes I want to propose;
Classes
shadow
: base class, likeborder
andtransform
shadow-inner
: alternative base class. Adds theinset
option to the final box-shadow (already exists kinda)shadow-both
: alternative base class. Generates both a inset and outset shadow from all given values.shadow-<color>-<saturation>
: basically the shadow version ofbg-red-500
shadow-x-<distance>
: as many as there aretranslate-x-<distance>
distancesshadow-y-<distance>
: as many as there aretranslate-y-<distance>
distancesshadow-blur-<blur>
: softest, soft, normal, harder, hardshadow-spread-<size>
: as many as there aretranslate-x/y-<distance>
distancesAlternatives:
We could keep shadow-sm but allow the other classes to be added as modifiers.
Add another base class called 'shadow-custom' which is required for the other options to take effect.
You could then still create the same shadows we have now by just doing
shadow shadow-soft
instead ofshadow-sm
.Shortening
shadow
tosh
could also be an option to save space.Maybe we could then also add
tsh
for text-shadows while we're at it.4. Maybe a combination of all of the above?
Examples
Here is a full example using all classes. Please ignore all thoughts about how ugly this input is with my values. Instead, think about how nice it would look with your values.
<input class="bg-white shadow-inner shadow-green-50 shadow-x-2 shadow-y-3 shadow-blur-hard shadow-spread-1 focus:shadow-x-3 focus:shadow-y-4">
using
sh
instead ofshadow
:<input class="bg-white sh-inner sh-green-50 sh-x-2 sh-y-3 sh-blur-hard sh-spread-1 sh-x-3 focus:sh-y-4">
using
shw
instead ofshadow
:<input class="bg-white shw-inner shw-green-50 shw-x-2 shw-y-3 shw-blur-hard shw-spread-1 shw-x-3 focus:shw-y-4">
Final thoughts
In my eyes this is just another thing that could be made easier to do with tailwind. Shadows are the large majority of my custom configs and contents of all <style> tags. Every time I have to add something to my config it feels like a loss. Having this work out of the box would be amazing.
I do understand that this, depending on the implementation and how tailwind generates variants under the hood, could increase the total size of tailwind a lot. If that is the case this might be better off as a plugin or separated utility.
Beta Was this translation helpful? Give feedback.
All reactions