Skip to content

Commit 1d2d50e

Browse files
Add items-baseline-last utility (#13888)
This PR adds the `items-first-baseline` and `items-last-baseline` utility classes that can control [`baseline-position`](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items#formal_syntax) for the [align-items property](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items#baseline). Browser support: - MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/align-items#browser_compatibility - Can I use `first baseline`: https://caniuse.com/?search=align%20items%3A%20first%20baseline - Can I use `last baseline`: https://caniuse.com/?search=align%20items%3A%20last%20baseline The feature were requested multiple times: - #13518 - #12406 - #11623 - #4855 --------- Co-authored-by: Philipp Spiess <[email protected]>
1 parent d6d913e commit 1d2d50e

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- _Experimental_: Add `details-content` variant ([#15319](https://github.com/tailwindlabs/tailwindcss/pull/15319))
1313
- _Experimental_: Add `inverted-colors` variant ([#11693](https://github.com/tailwindlabs/tailwindcss/pull/11693))
1414
- _Experimental_: Add `scripting`, `scripting-none`, and `scripting-initial` variants ([#11929](https://github.com/tailwindlabs/tailwindcss/pull/11929))
15+
- _Experimental_: Add `items-baseline-last` utility ([#12128](https://github.com/tailwindlabs/tailwindcss/pull/12128))
1516
- _Experimental_: Add `pointer-none`, `pointer-coarse`, and `pointer-fine` variant ([#16946](https://github.com/tailwindlabs/tailwindcss/pull/16946))
1617
- _Experimental_: Add `any-pointer-none`, `any-pointer-coarse`, and `any-pointer-fine` variants ([#16941](https://github.com/tailwindlabs/tailwindcss/pull/16941))
1718
- _Experimental_: Add `user-valid` and `user-invalid` variants ([#12370](https://github.com/tailwindlabs/tailwindcss/pull/12370))

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

+1
Original file line numberDiff line numberDiff line change
@@ -4875,6 +4875,7 @@ exports[`getClassList 1`] = `
48754875
"isolation-auto",
48764876
"italic",
48774877
"items-baseline",
4878+
"items-baseline-last",
48784879
"items-center",
48794880
"items-end",
48804881
"items-start",

packages/tailwindcss/src/feature-flags.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export const enableBaselineLast = process.env.FEATURES_ENV !== 'stable'
12
export const enableDetailsContent = process.env.FEATURES_ENV !== 'stable'
23
export const enableInvertedColors = process.env.FEATURES_ENV !== 'stable'
34
export const enablePointerVariants = process.env.FEATURES_ENV !== 'stable'

packages/tailwindcss/src/utilities.test.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -7312,12 +7312,24 @@ test('align-content', async () => {
73127312
})
73137313

73147314
test('items', async () => {
7315-
expect(await run(['items-start', 'items-end', 'items-center', 'items-baseline', 'items-stretch']))
7316-
.toMatchInlineSnapshot(`
7315+
expect(
7316+
await run([
7317+
'items-start',
7318+
'items-end',
7319+
'items-center',
7320+
'items-baseline',
7321+
'items-baseline-last',
7322+
'items-stretch',
7323+
]),
7324+
).toMatchInlineSnapshot(`
73177325
".items-baseline {
73187326
align-items: baseline;
73197327
}
73207328
7329+
.items-baseline-last {
7330+
align-items: last baseline;
7331+
}
7332+
73217333
.items-center {
73227334
align-items: center;
73237335
}
@@ -7341,6 +7353,8 @@ test('items', async () => {
73417353
'-items-end',
73427354
'-items-center',
73437355
'-items-baseline',
7356+
'-items-first-baseline',
7357+
'-items-last-baseline',
73447358
'-items-stretch',
73457359
'items-start/foo',
73467360
'items-end/foo',

packages/tailwindcss/src/utilities.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from './ast'
1212
import type { Candidate, CandidateModifier, NamedUtilityValue } from './candidate'
1313
import type { DesignSystem } from './design-system'
14-
import { enableWrapAnywhere } from './feature-flags'
14+
import { enableBaselineLast, enableWrapAnywhere } from './feature-flags'
1515
import type { Theme, ThemeKey } from './theme'
1616
import { compareBreakpoints } from './utils/compare-breakpoints'
1717
import { DefaultMap } from './utils/default-map'
@@ -1882,6 +1882,9 @@ export function createUtilities(theme: Theme) {
18821882
staticUtility('items-start', [['align-items', 'flex-start']])
18831883
staticUtility('items-end', [['align-items', 'flex-end']])
18841884
staticUtility('items-baseline', [['align-items', 'baseline']])
1885+
if (enableBaselineLast) {
1886+
staticUtility('items-baseline-last', [['align-items', 'last baseline']])
1887+
}
18851888
staticUtility('items-stretch', [['align-items', 'stretch']])
18861889

18871890
staticUtility('justify-normal', [['justify-content', 'normal']])

0 commit comments

Comments
 (0)