px
API reference for the `px` function
Overview
The px()
function — short for Pseudo Expand — allows you to combine multiple pseudo-class strings into one unified selector.
It’s useful when working with Plumeria’s pseudo utilities like ps.hover
, ps.active
, or custom ps.fn.has()
.
The result is a single joined pseudo selector string that can be passed into css.create()
or other style utilities.
✅ Designed to work with pseudo-class utility strings — not general-purpose string concatenation.
Purpose
When defining styles for complex pseudo states (:hover:focus
, :has(div):focus-visible
, etc.), manually writing strings becomes error-prone.
The px()
function ensures type-safe composition of pseudo strings while preserving string literal types for DX and autocomplete.
Example
You can use the combined result in your styles:
Return value
Returns a joined pseudo selector string, preserving literal types:
Use cases
- Combine standard pseudo-classes:
- Combine functional and state pseudo-classes:
Type-safety benefit
px()
preserves string literal types, you get full type-checking and editor autocomplete — even for composed pseudo selectors.