Skip to content

Commit 51b6224

Browse files
Update list of length units (tailwindlabs#10100)
* Update length units * Update changelog
1 parent c834da4 commit 51b6224

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- Prevent invalid arbitrary variant selectors from failing the build ([#10059](https://github.com/tailwindlabs/tailwindcss/pull/10059))
2929
- Properly handle subtraction followed by a variable ([#10074](https://github.com/tailwindlabs/tailwindcss/pull/10074))
3030
- Fix missing `string[]` in the `theme.dropShadow` types ([#10072](https://github.com/tailwindlabs/tailwindcss/pull/10072))
31+
- Update list of length units ([#10100](https://github.com/tailwindlabs/tailwindcss/pull/10100))
3132

3233
### Changed
3334

src/util/dataTypes.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ export function percentage(value) {
7777
return (value.endsWith('%') && number(value.slice(0, -1))) || isCSSFunction(value)
7878
}
7979

80+
// Please refer to MDN when updating this list:
81+
// https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
82+
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units
8083
let lengthUnits = [
8184
'cm',
8285
'mm',
@@ -90,10 +93,25 @@ let lengthUnits = [
9093
'ch',
9194
'rem',
9295
'lh',
96+
'rlh',
9397
'vw',
9498
'vh',
9599
'vmin',
96100
'vmax',
101+
'vb',
102+
'vi',
103+
'svw',
104+
'svh',
105+
'lvw',
106+
'lvh',
107+
'dvw',
108+
'dvh',
109+
'cqw',
110+
'cqh',
111+
'cqi',
112+
'cqb',
113+
'cqmin',
114+
'cqmax',
97115
]
98116
let lengthUnitsPattern = `(?:${lengthUnits.join('|')})`
99117
export function length(value) {

tests/arbitrary-values.test.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,9 @@
843843
.text-\[2\.23rem\] {
844844
font-size: 2.23rem;
845845
}
846+
.text-\[4cqw\] {
847+
font-size: 4cqw;
848+
}
846849
.text-\[length\:var\(--font-size\)\] {
847850
font-size: var(--font-size);
848851
}

tests/arbitrary-values.test.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@
284284

285285
<div class="text-[0]"></div>
286286
<div class="text-[2.23rem]"></div>
287+
<div class="text-[4cqw]"></div>
287288
<div class="text-[length:var(--font-size)]"></div>
288289
<div class="text-[angle:var(--angle)]"></div>
289290
<div class="text-[min(10vh,100px)]"></div>

0 commit comments

Comments
 (0)