-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust shadow, radius, and blur scales to ensure all utilities have a value suffix #14849
Conversation
shadow
to shadow-sm
and inset-shadow
to inset-shadow-sm
shadow
and inset-shadow
utilities
I like the new range 👍
I think a challenge of using the default theme of Tailwind is, sometimes class names are not predictable (to guess). For example, It's not easy to guess if each token starts with I think it would be better if they all start at the same name ( Here are the other sizings from Tailwind 4 alpha, and since they all don't start from the same name, it's sometimes hard guess, I think it's a common experience to try typing the class name it in editor and if there's an intellisense and I don't see a suggestion, then I know "oh, this one starts at
|
My first thought would be to follow the font size classes and use a |
I’m slightly against this proposal, the best feature of tailwind is that is basically a standard library at this point, predictable results unless theres project-specific overrides. The idea that things change meaning across versions creates both a mental overhead (less trust of the result) and technical challenges for things with different versions, eg design systems + app code, federated modules ecc. considering this is more of “I wish it was different” than a solution to a problem makes me think is not worth it |
I'm all for the band-aid ripping. A major version shouldn't be held back by choices made in a by-then legacy version. Break all the things 🔥 |
This sounds good to me -- I've been using TW for years and I never understood that So now, will anything happen if I use the class |
The new scale makes sense, would make shadow and alias to shadow-md for predictably though. |
shadow
and inset-shadow
utilities6047dc6
to
d1724fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I wonder if something can be simplified in the utilities code now that we no longer need to handle an shadow
(without an argument)?
In other words, do we still need this branch now or should this just return null
?
@philipp-spiess I think we should still support that for backwards compatibility personally, just in case someone is porting over their existing config that still has a |
@adamwathan makes sense... does this mean it should be in the compat layer though? (depends on if we want people to use this in a fresh v4 project I guess?) |
@philipp-spiess Yeah maybe? Just a question of do we consider the whole idea of being able to have a I'm not sure how we'd make it work in the compat layer either without unregistering the default |
Exactly, that's what I was thinking. I don't know what is right either though.
We do have a precedence for this where we just wrap the core utility and handle an additional cases: https://github.com/tailwindlabs/tailwindcss/blob/next/packages/tailwindcss/src/compat/theme-variants.ts#L9-L27 |
This PR adds a migration for migrating the changes we implemented in #14849 This is the migration we perform: | Old | New | | ----------------- | ------------------ | | `shadow` | `shadow-sm` | | `shadow-sm` | `shadow-xs` | | `shadow-xs` | `shadow-2xs` | | `inset-shadow` | `inset-shadow-sm` | | `inset-shadow-sm` | `inset-shadow-xs` | | `inset-shadow-xs` | `inset-shadow-2xs` | | `drop-shadow` | `drop-shadow-sm` | | `drop-shadow-sm` | `drop-shadow-xs` | | `rounded` | `rounded-sm` | | `rounded-sm` | `rounded-xs` | | `blur` | `blur-sm` | | `blur-sm` | `blur-xs` | Also added an integration test to ensure that `shadow` is properly migrated to `shadow-sm`, and doesn't get migrated to `shadow-xs` (because `shadow-sm` is migrated to `shadow-xs`).
This PR reintroduces the `blur`, `shadow`, `drop-shadow`, and `rounded` utilities that were removed in #14849, just to preserve backward compatibility as much as possible. These values are still considered deprecated, and we register them as `inline reference` with the theme to ensure they don't produce any CSS variables in output: ```css /* Deprecated */ @theme default inline reference { --blur: 8px; --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); --drop-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 1px 1px rgb(0 0 0 / 0.06); --radius: 0.25rem; } ``` These values won't be included in the documentation, and in the future we'll add an option to explicitly register things as `deprecated` so that they don't appear as completions in IntelliSense either. Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
This PR reworks the default
--shadow-*
and--inset-shadow-*
scales to remove the bareshadow
andinset-shadow
utilities, and ensure every shadow has an explicit size as part of the utility name.Here's a complete list of changes:
shadow-xs
shadow-2xs
shadow-sm
shadow-sm
shadow-xs
shadow
shadow
shadow-sm
shadow-md
shadow-md
shadow-md
shadow-lg
shadow-lg
shadow-lg
shadow-xl
shadow-xl
shadow-xl
inset-shadow-xs
inset-shadow-2xs
inset-shadow-sm
inset-shadow-xs
shadow-inner
inset-shadow
inset-shadow-sm
The motivation for this change is just to make the scale more predictable — it's never been intuitive to me that
shadow
sits in betweenshadow-sm
andshadow-md
.This PR doesn't remove the ability to create classes like
shadow
andinset-shadow
by adding bare--shadow
and--inset-shadow
theme variables, but does remove them from the default theme.Impact
We'll include a codemod for this in our upgrade tool to automate this change for people upgrading from v3 to v4, but this is still sort of an annoying breaking change admittedly and will make lots of educational resources, example components, and LLM tools out of date for v4 😕 At the same time I don't want to feel like we can never correct regrettable legacy decisions just to preserve backward compatibility.
We made a similar change like this when we went from the v0.x color palette to the v1.x color palette changing names like
bg-red
tobg-red-500
and that proved to definitely be the right decision long term, so want to rip the band-aid off here too if we can.Planning to make the same change for
rounded
,drop-shadow
, andblur
as well — maybe in separate PRs but maybe just all in this one as well since I don't think we want to do one and not all.Update: I've also made the same changes to the
--radius-*
,--drop-shadow-*
, and--blur-*
scales now, effectively removed therounded
,drop-shadow
, andblur
classes by default, and changing the meaningrounded-sm
,drop-shadow-sm
, andblur-sm
.We'll put together a codemod to handle this stuff in a separate PR.