Skip to content

Commit f5119bc

Browse files
committed
Use '@support' to detect whether '@container' attribute is supported on browser, and ensure it can be rolled back to the media query
1 parent 3c3dd3c commit f5119bc

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,18 @@ export = plugin(
3232
matchVariant(
3333
'@',
3434
(value = '', { modifier }) => {
35-
let parsed = parseValue(value)
35+
const parsed = parseValue(value);
3636

37-
return parsed !== null ? `@container ${modifier ?? ''} (min-width: ${value})` : []
37+
if (parsed === null) return [];
38+
39+
return [
40+
`@supports (container-type: inline-size) {
41+
@container ${modifier ?? ''} (min-width: ${value})
42+
}`,
43+
`@supports not (container-type: inline-size) {
44+
@media (min-width: ${value})
45+
}`
46+
];
3847
},
3948
{
4049
values,

0 commit comments

Comments
 (0)