Skip to content

Commit c32b608

Browse files
Add object-{top,bottom}-{left,right} utilities (#17437)
These match the new `mask-*` and updated `bg-*` utilities. This is the same as #17378 but for `object-position`. | Deprecated utility | New utility | | --------------------- | --------------------- | | `object-left-top` | `object-top-left` | | `object-right-top` | `object-top-right` | | `object-left-bottom` | `object-bottom-left` | | `object-right-bottom` | `object-bottom-right` |
1 parent f772266 commit c32b608

File tree

5 files changed

+46
-13
lines changed

5 files changed

+46
-13
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
- Added new `bg-{top,bottom}-{left,right}` utilities ([#17378](https://github.com/tailwindlabs/tailwindcss/pull/17378))
2626
- Added new `bg-{position,size}-*` utilities for arbitrary values ([#17432](https://github.com/tailwindlabs/tailwindcss/pull/17432))
2727
- Added new `shadow-*/{alpha}`, `inset-shadow-*/{alpha}`, and `text-shadow-*/{alpha}` utilities to control shadow opacity ([#17398](https://github.com/tailwindlabs/tailwindcss/pull/17398))
28+
- Added new `object-{top,bottom}-{left,right}` utilities ([#17437](https://github.com/tailwindlabs/tailwindcss/pull/17437))
2829

2930
### Fixed
3031

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -7982,19 +7982,19 @@ exports[`getClassList 1`] = `
79827982
"not-italic",
79837983
"not-sr-only",
79847984
"object-bottom",
7985+
"object-bottom-left",
7986+
"object-bottom-right",
79857987
"object-center",
79867988
"object-contain",
79877989
"object-cover",
79887990
"object-fill",
79897991
"object-left",
7990-
"object-left-bottom",
7991-
"object-left-top",
79927992
"object-none",
79937993
"object-right",
7994-
"object-right-bottom",
7995-
"object-right-top",
79967994
"object-scale-down",
79977995
"object-top",
7996+
"object-top-left",
7997+
"object-top-right",
79987998
"oldstyle-nums",
79997999
"opacity-0",
80008000
"opacity-5",

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

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ export function registerLegacyUtilities(designSystem: DesignSystem) {
2929
decl('background-position', 'right bottom'),
3030
])
3131

32+
// Legacy `object-position` utilities for compatibility with v4.0 and earlier
33+
designSystem.utilities.static('object-left-top', () => [decl('object-position', 'left top')])
34+
designSystem.utilities.static('object-right-top', () => [decl('object-position', 'right top')])
35+
designSystem.utilities.static('object-left-bottom', () => [
36+
decl('object-position', 'left bottom'),
37+
])
38+
designSystem.utilities.static('object-right-bottom', () => [
39+
decl('object-position', 'right bottom'),
40+
])
41+
3242
designSystem.utilities.functional('max-w-screen', (candidate) => {
3343
if (!candidate.value) return
3444
if (candidate.value.kind === 'arbitrary') return

packages/tailwindcss/src/utilities.test.ts

+25-3
Original file line numberDiff line numberDiff line change
@@ -17706,15 +17706,21 @@ test('object', async () => {
1770617706

1770717707
// object-position
1770817708
'object-[var(--value)]',
17709+
'object-top',
17710+
'object-top-left',
17711+
'object-top-right',
1770917712
'object-bottom',
17710-
'object-center',
17713+
'object-bottom-left',
17714+
'object-bottom-right',
1771117715
'object-left',
17716+
'object-right',
17717+
'object-center',
17718+
17719+
// Legacy versions in v4.0 and earlier
1771217720
'object-left-bottom',
1771317721
'object-left-top',
17714-
'object-right',
1771517722
'object-right-bottom',
1771617723
'object-right-top',
17717-
'object-top',
1771817724
]),
1771917725
).toMatchInlineSnapshot(`
1772017726
".object-contain {
@@ -17745,6 +17751,14 @@ test('object', async () => {
1774517751
object-position: bottom;
1774617752
}
1774717753

17754+
.object-bottom-left {
17755+
object-position: left bottom;
17756+
}
17757+
17758+
.object-bottom-right {
17759+
object-position: right bottom;
17760+
}
17761+
1774817762
.object-center {
1774917763
object-position: center;
1775017764
}
@@ -17775,6 +17789,14 @@ test('object', async () => {
1777517789

1777617790
.object-top {
1777717791
object-position: top;
17792+
}
17793+
17794+
.object-top-left {
17795+
object-position: left top;
17796+
}
17797+
17798+
.object-top-right {
17799+
object-position: right top;
1777817800
}"
1777917801
`)
1778017802
expect(

packages/tailwindcss/src/utilities.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -3639,15 +3639,15 @@ export function createUtilities(theme: Theme) {
36393639
staticUtility('object-none', [['object-fit', 'none']])
36403640
staticUtility('object-scale-down', [['object-fit', 'scale-down']])
36413641

3642+
staticUtility('object-top', [['object-position', 'top']])
3643+
staticUtility('object-top-left', [['object-position', 'left top']])
3644+
staticUtility('object-top-right', [['object-position', 'right top']])
36423645
staticUtility('object-bottom', [['object-position', 'bottom']])
3643-
staticUtility('object-center', [['object-position', 'center']])
3646+
staticUtility('object-bottom-left', [['object-position', 'left bottom']])
3647+
staticUtility('object-bottom-right', [['object-position', 'right bottom']])
36443648
staticUtility('object-left', [['object-position', 'left']])
3645-
staticUtility('object-left-bottom', [['object-position', 'left bottom']])
3646-
staticUtility('object-left-top', [['object-position', 'left top']])
36473649
staticUtility('object-right', [['object-position', 'right']])
3648-
staticUtility('object-right-bottom', [['object-position', 'right bottom']])
3649-
staticUtility('object-right-top', [['object-position', 'right top']])
3650-
staticUtility('object-top', [['object-position', 'top']])
3650+
staticUtility('object-center', [['object-position', 'center']])
36513651
functionalUtility('object', {
36523652
themeKeys: ['--object-position'],
36533653
handle: (value) => [decl('object-position', value)],

0 commit comments

Comments
 (0)