state
hasSibling
Sugar over when("&:has(~ {selector})", input), styling an element by a sibling's state.
import { hasSibling } from "@sdxc/u/state";Quick reference
Every documented call, beside the CSS it emits.
| Call | CSS |
|---|---|
u.hasSibling("input:checked", u.bg("brand.solid")) | css({ "&:has(~ input:checked)": { backgroundColor: "..." } }) |
u.hasSibling("input:disabled", u.opacity(50)) | css({ "&:has(~ input:disabled)": { opacity: 0.5 } }) |
Using a custom value
Every scale argument also takes a raw CSS value, which passes through untouched.
u.hasSibling("input:checked", u.bg("brand.solid"))Responsive design
Wrap the call in a container query to scope it to one width.
u.at("md", u.hasSibling("input:checked", u.bg("brand.solid")))Signature
u.hasSibling(selector: string, input: UtilityInput<Node>)