[ @sdxc/u/effects ]
backface-visibility
Controls whether the back face of a 3D-transformed element renders once it rotates away from the viewer; the "hidden" default keeps flip-card and page-turn effects showing only their front face.
import { backfaceVisibility } from "@sdxc/u/effects";Quick reference
Every documented call, beside the CSS it emits.
| Call | CSS |
|---|---|
u.backfaceVisibility() | css({ backfaceVisibility: "hidden" }) |
Examples
Basic example
Use backfaceVisibility("hidden") to hide an element once a 3D transform turns its back to the viewer, or "visible" to show it mirrored:
visible
hidden
<div mix={[perspective(600), ...]}>
<div mix={[...]}>
<div mix={[rotateY(150), backfaceVisibility("visible"), ...]}>visible</div>
</div>
<div mix={[...]}>
<div mix={[rotateY(150), backfaceVisibility("hidden"), ...]}>hidden</div>
</div>
</div>Building a flip card
Hide the back face of both sides of a card and turn the card around on hover. Hover the card:
Front
Back
<div mix={[perspective(800)]}>
<div
mix={[
zstack(),
transformStyle(),
transition("transform", { duration: 600 }),
when(":hover > &", rotateY(180)),
]}
>
<div mix={[backfaceVisibility(), ...]}>Front</div>
<div mix={[backfaceVisibility(), rotateY(180), ...]}>Back</div>
</div>
</div>Applying on a state
Wrap the call in a state utility to scope it to one selector.
u.hover(u.backfaceVisibility())Responsive design
Wrap the call in a container query to scope it to one width.
u.at("md", u.backfaceVisibility())Signature
u.backfaceVisibility(value?: BackfaceVisibilityValue)