Skip to content

Commit 3e53e25

Browse files
Add bg-{top,bottom}-{left,right} utilities (#17378)
We’re using this naming for `mask-*` and `mask-radial-at-*` position utilities and we want to be consistent. The old ones for `background-position` will stay but are deprecated --------- Co-authored-by: Robin Malfait <[email protected]>
1 parent eecb6f7 commit 3e53e25

File tree

5 files changed

+56
-15
lines changed

5 files changed

+56
-15
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- _Experimental_: Add `wrap-anywhere`, `wrap-break-word`, and `wrap-normal` utilities ([#12128](https://github.com/tailwindlabs/tailwindcss/pull/12128))
2121
- _Experimental_: Add `@source inline(…)` ([#17147](https://github.com/tailwindlabs/tailwindcss/pull/17147))
2222
- _Experimental_: Add `@source not` ([#17255](https://github.com/tailwindlabs/tailwindcss/pull/17255))
23+
- Added new `bg-{top,bottom}-{left,right}` utilities ([#17378](https://github.com/tailwindlabs/tailwindcss/pull/17378))
2324

2425
### Fixed
2526

2627
- Fix symlink issues when resolving `@source` directives ([#17391](https://github.com/tailwindlabs/tailwindcss/pull/17391))
2728

29+
### Changed
30+
31+
- Deprecated `bg-{left,right}-{top,bottom}` utilities ([#17378](https://github.com/tailwindlabs/tailwindcss/pull/17378))
32+
2833
## [4.0.17] - 2025-03-26
2934

3035
### Fixed

packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,6 +2156,8 @@ exports[`getClassList 1`] = `
21562156
"bg-blend-screen",
21572157
"bg-blend-soft-light",
21582158
"bg-bottom",
2159+
"bg-bottom-left",
2160+
"bg-bottom-right",
21592161
"bg-center",
21602162
"bg-clip-border",
21612163
"bg-clip-content",
@@ -2326,8 +2328,6 @@ exports[`getClassList 1`] = `
23262328
"bg-inherit/95",
23272329
"bg-inherit/100",
23282330
"bg-left",
2329-
"bg-left-bottom",
2330-
"bg-left-top",
23312331
"bg-linear-0",
23322332
"bg-linear-0/oklab",
23332333
"bg-linear-0/oklch",
@@ -2529,10 +2529,10 @@ exports[`getClassList 1`] = `
25292529
"bg-repeat-x",
25302530
"bg-repeat-y",
25312531
"bg-right",
2532-
"bg-right-bottom",
2533-
"bg-right-top",
25342532
"bg-scroll",
25352533
"bg-top",
2534+
"bg-top-left",
2535+
"bg-top-right",
25362536
"bg-transparent",
25372537
"bg-transparent/0",
25382538
"bg-transparent/5",

packages/tailwindcss/src/compat/legacy-utilities.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ export function registerLegacyUtilities(designSystem: DesignSystem) {
1919
])
2020
}
2121

22+
// Legacy `background-position` utilities for compatibility with v4.0 and earlier
23+
designSystem.utilities.static('bg-left-top', () => [decl('background-position', 'left top')])
24+
designSystem.utilities.static('bg-right-top', () => [decl('background-position', 'right top')])
25+
designSystem.utilities.static('bg-left-bottom', () => [
26+
decl('background-position', 'left bottom'),
27+
])
28+
designSystem.utilities.static('bg-right-bottom', () => [
29+
decl('background-position', 'right bottom'),
30+
])
31+
2232
designSystem.utilities.functional('max-w-screen', (candidate) => {
2333
if (!candidate.value) return
2434
if (candidate.value.kind === 'arbitrary') return

packages/tailwindcss/src/utilities.test.ts

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10190,20 +10190,26 @@ test('bg', async () => {
1019010190
'bg-scroll',
1019110191

1019210192
// background-position
10193-
'bg-center',
1019410193
'bg-top',
10195-
'bg-right-top',
10196-
'bg-right-bottom',
10194+
'bg-top-left',
10195+
'bg-top-right',
1019710196
'bg-bottom',
10198-
'bg-left-bottom',
10197+
'bg-bottom-left',
10198+
'bg-bottom-right',
1019910199
'bg-left',
10200-
'bg-left-top',
10200+
'bg-right',
10201+
'bg-center',
1020110202
'bg-[50%]',
1020210203
'bg-[120px]',
1020310204
'bg-[120px_120px]',
1020410205
'bg-[length:120px_120px]',
1020510206
'bg-[position:120px_120px]',
1020610207
'bg-[size:120px_120px]',
10208+
// Legacy versions in v4.0 and earlier
10209+
'bg-right-top',
10210+
'bg-right-bottom',
10211+
'bg-left-bottom',
10212+
'bg-left-top',
1020710213

1020810214
// background-repeat
1020910215
'bg-repeat',
@@ -10610,6 +10616,14 @@ test('bg', async () => {
1061010616
background-position: bottom;
1061110617
}
1061210618
10619+
.bg-bottom-left {
10620+
background-position: 0 100%;
10621+
}
10622+
10623+
.bg-bottom-right {
10624+
background-position: 100% 100%;
10625+
}
10626+
1061310627
.bg-center {
1061410628
background-position: center;
1061510629
}
@@ -10626,6 +10640,10 @@ test('bg', async () => {
1062610640
background-position: 0 0;
1062710641
}
1062810642
10643+
.bg-right {
10644+
background-position: 100%;
10645+
}
10646+
1062910647
.bg-right-bottom {
1063010648
background-position: 100% 100%;
1063110649
}
@@ -10638,6 +10656,14 @@ test('bg', async () => {
1063810656
background-position: top;
1063910657
}
1064010658
10659+
.bg-top-left {
10660+
background-position: 0 0;
10661+
}
10662+
10663+
.bg-top-right {
10664+
background-position: 100% 0;
10665+
}
10666+
1064110667
.bg-no-repeat {
1064210668
background-repeat: no-repeat;
1064310669
}

packages/tailwindcss/src/utilities.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,15 +2390,15 @@ export function createUtilities(theme: Theme) {
23902390
staticUtility('bg-local', [['background-attachment', 'local']])
23912391
staticUtility('bg-scroll', [['background-attachment', 'scroll']])
23922392

2393-
staticUtility('bg-center', [['background-position', 'center']])
23942393
staticUtility('bg-top', [['background-position', 'top']])
2395-
staticUtility('bg-right-top', [['background-position', 'right top']])
2396-
staticUtility('bg-right', [['background-position', 'right']])
2397-
staticUtility('bg-right-bottom', [['background-position', 'right bottom']])
2394+
staticUtility('bg-top-left', [['background-position', 'left top']])
2395+
staticUtility('bg-top-right', [['background-position', 'right top']])
23982396
staticUtility('bg-bottom', [['background-position', 'bottom']])
2399-
staticUtility('bg-left-bottom', [['background-position', 'left bottom']])
2397+
staticUtility('bg-bottom-left', [['background-position', 'left bottom']])
2398+
staticUtility('bg-bottom-right', [['background-position', 'right bottom']])
24002399
staticUtility('bg-left', [['background-position', 'left']])
2401-
staticUtility('bg-left-top', [['background-position', 'left top']])
2400+
staticUtility('bg-right', [['background-position', 'right']])
2401+
staticUtility('bg-center', [['background-position', 'center']])
24022402

24032403
staticUtility('bg-repeat', [['background-repeat', 'repeat']])
24042404
staticUtility('bg-no-repeat', [['background-repeat', 'no-repeat']])

0 commit comments

Comments
 (0)