SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

selection

Applies utilities to the element's ::selection; only color, background-color, text-decoration, and text-shadow take effect, and overriding the platform's contrast guarantee requires a high-contrast pair.

tsx
import { selection } from "@sdxc/u/state";

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.selection(u.bg("brand.tint"))css({ "&::selection": { backgroundColor: "..." } })

Examples

Basic example

Wrap utilities in selection() to style the text a user highlights. Select some of the paragraph:

Utilities compose: a state wrapper takes any of them, so the same few calls style a button at rest, under the pointer, and while it is pressed.

tsx
<p mix={[selection([bg("brand.solid"), fg("brand.onSolid")]), ...]}>
	Utilities compose: a state wrapper takes any of them, so the same few calls style a button at
	rest, under the pointer, and while it is pressed.
</p>

Responsive design

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

typescript
u.at("md", u.selection(u.bg("brand.tint")))

Signature

typescript
u.selection(input: UtilityInput<Node>)
@sdxc/u

Can’t find it? Contact us