Skip to content
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

Add radius-* utilities and deprecate rounded-* utilities #14912

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

adamwathan
Copy link
Member

This PR adds a new set of radius-* utilities to replace the existing rounded-* utilities.

These utilities derive their values from the --spacing-* scale by default, but can also be configured with radius-specific values using the --radius-* scale.

This change makes it easier to do things like concentric border radiuses, where you need to subtract the padding of the parent when calculating the child radius:

<div class="radius-8 p-2">
  <div class="radius-6">

Using the old t-shirt scale there was no clear connection to the spacing value which made this sort of thing annoying, and also difficult to notice that the value was carefully chosen to be concentric when reading the code.

I've kept the rounded-* utilities around for backwards compatibility, including the old t-shirt scale but have registered as inline reference so that they don't produce CSS variables by default. We plan to mark these as deprecated via IntelliSense though, and also plan to update our codemod tooling to make it easy to migrate from rounded-* to radius-* automatically.

@adamwathan adamwathan requested a review from a team as a code owner November 7, 2024 21:34
@adamwathan adamwathan force-pushed the feat/add-radius-utilities branch from 4c7d7b9 to 13f1106 Compare November 7, 2024 21:35
{
// border-radius
// Deprecated: `rounded` utilities
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we could generate a /* @deprecated */ comment next to the utility so that it shows in some editors as deprecated. But Lightning CSS sadly strips comments away (or their internal parser does).

@philipp-spiess philipp-spiess force-pushed the feat/add-radius-utilities branch from 13f1106 to fed942b Compare November 11, 2024 13:36
@@ -50,7 +51,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rename `shadow` to `shadow-sm`, `shadow-sm` to `shadow-xs`, and `shadow-xs` to `shadow-2xs` ([#14849](https://github.com/tailwindlabs/tailwindcss/pull/14849))
- Rename `inset-shadow` to `inset-shadow-sm`, `inset-shadow-sm` to `inset-shadow-xs`, and `inset-shadow-xs` to `inset-shadow-2xs` ([#14849](https://github.com/tailwindlabs/tailwindcss/pull/14849))
- Rename `drop-shadow` to `drop-shadow-sm` and `drop-shadow-sm` to `drop-shadow-xs` ([#14849](https://github.com/tailwindlabs/tailwindcss/pull/14849))
- Rename `rounded` to `rounded-sm` and `rounded-sm` to `rounded-xs` ([#14849](https://github.com/tailwindlabs/tailwindcss/pull/14849))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the change of moving the old scale to be deprecated as it was, I think we can revert this one, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mostly affects the codemod stuff, I think instead of mapping rounded to rounded-sm etc. we should map it to the new radius-* utilities but leave the values as-is 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah wait this is more complicated, we can only migrate to radius-* when we the value is defined in the JS config, the compat layer only works rounded-* utilities

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess also only if the theme is overwritten. 🤔

Consider this configuration:

{
  extend: {
    borderRadius: {
      '4xl': '2rem',
    },
  }
}

I expect this to create a --radius-4xl: 2rem variable (which it does currently) however, the other breakpoints will now be in the --rounded namespace, causing an inconsistency now because radius-4xl exists but radius-3xl doesn't.

Copy link
Member

@philipp-spiess philipp-spiess Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the v4 equivalent is actually

rounded => radius-1
rounded-sm => radius-0.5
rounded-md => radius-1.5
rounded-custom => radius-custom
etc.

if custom happens to be 4xl: not much we do here I think, although it would be cool if we can convert it to radius-8 but there might be an inherent meaning to the name so that's probably hard to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants