Skip to content

Commit ba10379

Browse files
Add h-lh/min-h-lh/max-h-lh utilities to match an elements line height (#17790)
This PR adds the following utilities that can be used to match an elements line height: - `h-lh` - `min-h-lh` - `max-h-lh` These are all equivalent to providing `1lh` as an arbitrary value. e.g. `h-[1lh]`
1 parent 62ca1ec commit ba10379

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- Ensure `@tailwindcss/upgrade` runs on Tailwind CSS v4 projects ([#17717](https://github.com/tailwindlabs/tailwindcss/pull/17717))
13+
- Add `h-lh` / `min-h-lh` / `max-h-lh` utilities to match an elements line height ([#17790](https://github.com/tailwindlabs/tailwindcss/pull/17790))
1314

1415
### Fixed
1516

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

+3
Original file line numberDiff line numberDiff line change
@@ -4562,6 +4562,7 @@ exports[`getClassList 1`] = `
45624562
"h-dvw",
45634563
"h-fit",
45644564
"h-full",
4565+
"h-lh",
45654566
"h-lvh",
45664567
"h-lvw",
45674568
"h-max",
@@ -7482,6 +7483,7 @@ exports[`getClassList 1`] = `
74827483
"max-h-dvw",
74837484
"max-h-fit",
74847485
"max-h-full",
7486+
"max-h-lh",
74857487
"max-h-lvh",
74867488
"max-h-lvw",
74877489
"max-h-max",
@@ -7703,6 +7705,7 @@ exports[`getClassList 1`] = `
77037705
"min-h-dvw",
77047706
"min-h-fit",
77057707
"min-h-full",
7708+
"min-h-lh",
77067709
"min-h-lvh",
77077710
"min-h-lvw",
77087711
"min-h-max",

packages/tailwindcss/src/utilities.test.ts

+18
Original file line numberDiff line numberDiff line change
@@ -2917,6 +2917,7 @@ test('height', async () => {
29172917
'h-lvh',
29182918
'h-dvh',
29192919
'h-min',
2920+
'h-lh',
29202921
'h-max',
29212922
'h-fit',
29222923
'h-4',
@@ -2957,6 +2958,10 @@ test('height', async () => {
29572958
height: 100%;
29582959
}
29592960

2961+
.h-lh {
2962+
height: 1lh;
2963+
}
2964+
29602965
.h-lvh {
29612966
height: 100lvh;
29622967
}
@@ -2993,6 +2998,7 @@ test('height', async () => {
29932998
'h-svh/foo',
29942999
'h-lvh/foo',
29953000
'h-dvh/foo',
3001+
'h-lh/foo',
29963002
'h-min/foo',
29973003
'h-max/foo',
29983004
'h-fit/foo',
@@ -3020,6 +3026,7 @@ test('min-height', async () => {
30203026
'min-h-lvh',
30213027
'min-h-dvh',
30223028
'min-h-min',
3029+
'min-h-lh',
30233030
'min-h-max',
30243031
'min-h-fit',
30253032
'min-h-4',
@@ -3055,6 +3062,10 @@ test('min-height', async () => {
30553062
min-height: 100%;
30563063
}
30573064

3065+
.min-h-lh {
3066+
min-height: 1lh;
3067+
}
3068+
30583069
.min-h-lvh {
30593070
min-height: 100lvh;
30603071
}
@@ -3086,6 +3097,7 @@ test('min-height', async () => {
30863097
'min-h-svh/foo',
30873098
'min-h-lvh/foo',
30883099
'min-h-dvh/foo',
3100+
'min-h-lh/foo',
30893101
'min-h-min/foo',
30903102
'min-h-max/foo',
30913103
'min-h-fit/foo',
@@ -3111,6 +3123,7 @@ test('max-height', async () => {
31113123
'max-h-svh',
31123124
'max-h-lvh',
31133125
'max-h-dvh',
3126+
'max-h-lh',
31143127
'max-h-min',
31153128
'max-h-max',
31163129
'max-h-fit',
@@ -3143,6 +3156,10 @@ test('max-height', async () => {
31433156
max-height: 100%;
31443157
}
31453158

3159+
.max-h-lh {
3160+
max-height: 1lh;
3161+
}
3162+
31463163
.max-h-lvh {
31473164
max-height: 100lvh;
31483165
}
@@ -3179,6 +3196,7 @@ test('max-height', async () => {
31793196
'max-h-svh/foo',
31803197
'max-h-lvh/foo',
31813198
'max-h-dvh/foo',
3199+
'max-h-lh/foo',
31823200
'max-h-min/foo',
31833201
'max-h-max/foo',
31843202
'max-h-fit/foo',

packages/tailwindcss/src/utilities.ts

+16-5
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,6 @@ export function createUtilities(theme: Theme) {
943943
* @css `max-height`
944944
*/
945945
for (let [key, value] of [
946-
['auto', 'auto'],
947946
['full', '100%'],
948947
['svw', '100svw'],
949948
['lvw', '100lvw'],
@@ -964,12 +963,24 @@ export function createUtilities(theme: Theme) {
964963
staticUtility(`h-${key}`, [['height', value]])
965964
staticUtility(`min-w-${key}`, [['min-width', value]])
966965
staticUtility(`min-h-${key}`, [['min-height', value]])
967-
if (key !== 'auto') {
968-
staticUtility(`max-w-${key}`, [['max-width', value]])
969-
staticUtility(`max-h-${key}`, [['max-height', value]])
970-
}
966+
staticUtility(`max-w-${key}`, [['max-width', value]])
967+
staticUtility(`max-h-${key}`, [['max-height', value]])
971968
}
972969

970+
staticUtility(`size-auto`, [
971+
['--tw-sort', 'size'],
972+
['width', 'auto'],
973+
['height', 'auto'],
974+
])
975+
staticUtility(`w-auto`, [['width', 'auto']])
976+
staticUtility(`h-auto`, [['height', 'auto']])
977+
staticUtility(`min-w-auto`, [['min-width', 'auto']])
978+
staticUtility(`min-h-auto`, [['min-height', 'auto']])
979+
980+
staticUtility(`h-lh`, [['height', '1lh']])
981+
staticUtility(`min-h-lh`, [['min-height', '1lh']])
982+
staticUtility(`max-h-lh`, [['max-height', '1lh']])
983+
973984
staticUtility(`w-screen`, [['width', '100vw']])
974985
staticUtility(`min-w-screen`, [['min-width', '100vw']])
975986
staticUtility(`max-w-screen`, [['max-width', '100vw']])

0 commit comments

Comments
 (0)