sdxc

[ @sdxc/u/effects ]

backdropInvert

Inverts the colours showing through the element's translucent background.

import { backdropInvert } from "@sdxc/u/effects";

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.backdropInvert()css({ "--ui-backdrop-invert": "1", backdropFilter: "... invert(var(--ui-backdrop-invert, 0)) ...", WebkitBackdropFilter: "... invert(var(--ui-backdrop-invert, 0)) ..." })
u.transparencySafe(u.backdropInvert(0.15))css({ "@media (prefers-reduced-transparency: no-preference)": { "--ui-backdrop-invert": "0.15", backdropFilter: "...", WebkitBackdropFilter: "..." } })

Examples

Basic example

Use backdropInvert(n) to invert the colors showing through an element, where backdropInvert() with no argument inverts them fully:

backdropInvert(0.25)
backdropInvert()
<div mix={[...]}>
	<div mix={[...]}>
		<div mix={[backdropInvert(0.25), ...]}>backdropInvert(0.25)</div>
	</div>
	<div mix={[...]}>
		<div mix={[backdropInvert(), ...]}>backdropInvert()</div>
	</div>
</div>

Applying on a state

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

u.hover(u.backdropInvert())

Responsive design

Wrap the call in a container query to scope it to one width.

u.at("md", u.backdropInvert())

Signature

u.backdropInvert(value?: number | (string & {}))

Written by Sergio Xalambrí. Follow @sergiodxa for new packages, or sponsor the work.