SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

supports

A feature-query wrapper, applying the given utilities only when the browser supports query — progressive enhancement for CSS features without a reliable fallback path other than "don't apply this at all".

tsx
import { supports } from "@sdxc/u/responsive";

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.supports("(corner-shape: squircle)", u.corner("squircle"))css({ "@supports (corner-shape: squircle)": { cornerShape: "squircle" } })

Examples

Basic example

Use supports(query, ...) to apply utilities only when the browser supports a feature, like supports("(backdrop-filter: blur(1px))", ...), keeping a solid fallback for the rest:

Frosted glass
tsx
<div mix={[...]}>
	<div
		mix={[
			bg("color.neutral.900"),
			supports("(backdrop-filter: blur(1px))", [bg("transparent"), backdropBlur("md")]),
			...,
		]}
	>
		Frosted glass
	</div>
</div>

Testing a selector

Use selector(...) in the query to test a selector, like supports("selector(:has(*))", ...). Check the box:

tsx
<label
	mix={[
		hstack({ gap: 3 }),
		border({ color: "neutral.border", width: 1 }),
		supports("selector(:has(*))", has(":checked", bg("brand.tint"))),
		...,
	]}
>
	<input type="checkbox" />
	Email me a weekly summary
</label>

Applying on a state

Wrap the call in a state utility to scope it to one selector.

typescript
u.hover(u.supports("(corner-shape: squircle)", u.corner("squircle")))

Signature

typescript
u.supports(query: string, input: UtilityInput<Node>)
@sdxc/u

Can’t find it? Contact us