Skip to content

Commit c186e6f

Browse files
authored
Merge pull request #204 from LesnoyPudge/container-query-units
Add support for container query length units
2 parents 8daac7f + 549f8b8 commit c186e6f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/lib/validators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const arbitraryValueRegex = /^\[(?:([a-z-]+):)?(.+)\]$/i
22
const fractionRegex = /^\d+\/\d+$/
33
const stringLengths = new Set(['px', 'full', 'screen'])
44
const tshirtUnitRegex = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/
5-
const lengthUnitRegex = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh)/
5+
const lengthUnitRegex = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))/
66
// Shadow always begins with x and y offset separated by underscore
77
const shadowRegex = /^-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/
88

tests/arbitrary-values.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ test('handles simple conflicts with arbitrary values correctly', () => {
77
'm-[2px] m-[11svmin] m-[12in] m-[13lvi] m-[14vb] m-[15vmax] m-[16mm] m-[17%] m-[18em] m-[19px] m-[10dvh]',
88
),
99
).toBe('m-[10dvh]')
10+
expect(
11+
twMerge('h-[10px] h-[11cqw] h-[12cqh] h-[13cqi] h-[14cqb] h-[15cqmin] h-[16cqmax]'),
12+
).toBe('h-[16cqmax]')
1013
expect(twMerge('z-20 z-[99]')).toBe('z-[99]')
1114
expect(twMerge('my-[2px] m-[10rem]')).toBe('m-[10rem]')
1215
expect(twMerge('cursor-pointer cursor-[grab]')).toBe('cursor-[grab]')

0 commit comments

Comments
 (0)