gpuijs

Reference

CSS support

The host parses CSS with lightningcss, matches selectors against the native tree, and maps computed values onto GPUI styles. This page lists what's supported. Anything not listed is skipped, and the host prints [gpuijs] unsupported css: … the first time it meets it.

#The cascade

FeatureSupport
Specificity and source orderYes
!importantYes, including against inline styles
Inline styles (style prop, el.style)Yes
Cascade layers (@layer, statements and blocks, nested)Yes. Unlayered rules beat every layer, and the UA stylesheet sits in the lowest.
InheritanceYes: color, the font properties, line-height, letter-spacing, text-align, white-space, text-transform, pointer-events and custom properties inherit
inherit, initial, unset, revertYes
Custom properties and var() with fallbacksYes, including nested fallbacks. Cycles resolve to the fallback.
@propertyYes: inherits and initial-value are honoured
CSS nesting (&)Yes, lowered at parse time
@importNot at runtime. The CLI bundles imports before the host sees the CSS.

#At-rules

RuleSupport
@mediawidth, height, min-*/max-* and range syntax ((width >= 768px)), prefers-color-scheme (follows macOS, live), prefers-reduced-motion (no-preference matches), hover: hover, pointer: fine (and the any- forms), color. and, or, not and only work, and em/rem resolve against 16px.
@containerSize conditions against the nearest container (or the nearest one with that name). The window size stands in before the first layout.
@supportsEvaluated: a declaration is supported when lightningcss can parse it into a typed value
@layerYes
@keyframesYes. The last definition of a name wins.
@propertyYes
@font-faceNot yet (skipped with a warning). Fonts come from the system.
@page, @counter-style, @namespaceNo

#Selectors

SelectorSupport
Type, .class, #id, *Yes
Attribute selectors: [a], [a=v], [a~=v], [a|=v], [a^=v], [a$=v], [a*=v], i/s flagsYes. See which attributes the host sees.
Combinators: descendant, >, +, ~Yes
:is(), :where(), :not()Yes
:has()On the subject: :has(x), :has(> x), :has(+ x), :has(~ x) and longer relative selectors. Not nested inside another pseudo-class.
:nth-child(), :nth-last-child(), :nth-of-type(), :nth-last-of-type(), :first-child, :last-child, :only-child, :first-of-type, :last-of-type, :only-of-typeYes. :nth-child(… of S) isn't supported.
:root, :emptyYes
:hover, :activeYes, applied natively without JavaScript. :hover on an ancestor works (.group:hover .x).
:focus, :focus-within, :focus-visibleYes
:disabled, :enabledOn input, button, select and textarea
:checkedOn checkboxes and radios
:placeholder-shownYes
:link, :any-link<a> with an href
:dir()Always ltr for now
:visited, :target, :invalid, :required and other statesNever match
::before, ::afterYes, with string content
Other pseudo-elements (::placeholder, ::selection, ::marker, ::-webkit-scrollbar, ::backdrop)Skipped

Selectors that the matcher can't evaluate are skipped whole, not misapplied: :nth-col(), :nth-child(… of …) and & outside a nested rule.

#Attributes in selectors

The host sees these attributes: id, class, role, type, name, href, title, for, colspan, disabled, hidden, checked, and every attribute whose name contains a hyphen (data-*, aria-*, and custom ones like cmdk's cmdk-item). Inside SVG, every attribute is passed through.

Others, like value, placeholder, alt and dir, aren't available to attribute selectors.

#Values

KindSupport
Lengthspx, rem (16px), em, %, ch, vw, vh, vmin, vmax, svh/lvh/dvh and friends (all the window size), pt, in, cm, mm
Mathcalc() (lengths mixed with percentages), min(), max(), clamp(), abs()
ColorsNamed colors, hex, rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch(), color(), color-mix(), currentColor, transparent, light-dark() (follows the macOS appearance)
Angles and timesdeg, rad, grad, turn, s, ms
Easinglinear, ease, ease-in, ease-out, ease-in-out, cubic-bezier(), steps()

#Properties

#Box model and sizing

PropertyNotes
width, height, min-*, max-* (and logical inline-size, block-size, ...)auto, lengths and stretch. min-content, max-content and fit-content widths size to content.
margin-*, padding-* (and logical forms)Including auto margins
border-*-width, border-*-style, border-*-colorsolid. dashed and dotted draw dashed. double, groove and the rest draw solid. A side with none or hidden isn't drawn.
border-*-radius (and logical forms)Yes
box-sizingAlways border-box
aspect-ratioYes
overflow, overflow-x, overflow-yvisible, hidden, clip, scroll, auto. Clipping one axis clips both.
visibilityvisible, and hidden (collapse acts as hidden)

#Layout

PropertyNotes
displayblock, inline, inline-block, flex, inline-flex, grid, inline-grid, flow-root, none, contents, table values, -webkit-box. See Layout.
positionstatic, relative, absolute, fixed. sticky acts as relative.
top, right, bottom, left, inset (and logical forms)Yes
z-indexYes
flex-direction, flex-wrap, flex-grow, flex-shrink, flex-basis, flex, flex-flowYes
align-items, align-self, align-content, justify-content, justify-items, justify-self, place-*Yes
gap, row-gap, column-gapYes
orderYes
grid-template-columns, grid-template-rows, grid-template-areas, grid-templateTrack sizes, fr, minmax(), repeat() with auto-fill/auto-fit, named lines and areas
grid-auto-columns, grid-auto-rows, grid-auto-flowIncluding dense
grid-column, grid-row, grid-area and their longhandsLines, spans and area names
container-type, container-name, containerYes

#Text and fonts

PropertyNotes
colorYes
font-familyInstalled fonts. system-ui, -apple-system and BlinkMacSystemFont map to the system UI font.
font-size, font-weight, font-styleYes
line-heightNumbers, lengths and percentages
text-alignleft, right, center, start, end. justify aligns left.
text-decoration-line, -color, -style, -thicknessunderline and line-through, with wavy drawn wavy. Dotted, dashed and double lines draw solid.
text-transformuppercase, lowercase, capitalize
text-overflowellipsis and clip
white-spacenormal, nowrap, pre, pre-wrap, pre-line, break-spaces
overflow-wrap, word-wrap, word-breakoverflow-wrap: break-word and anywhere, word-break: break-all and break-word
letter-spacingYes
-webkit-line-clamp, line-clampYes, with display: -webkit-box and -webkit-box-orient: vertical
font-variant-numerictabular-nums, proportional-nums, lining-nums, oldstyle-nums, diagonal-fractions, stacked-fractions, ordinal, slashed-zero, as OpenType features
font-feature-settingsYes
contentA string, on ::before and ::after

#Backgrounds and borders

PropertyNotes
background-colorYes
background-imageurl() of a local file, linear-gradient() with up to four stops (any angle or corner direction), and radial-gradient() drawn from the center at farthest-corner size
background-sizecover, contain, 100% 100%, auto
background-positionKeywords, lengths, percentages
box-shadowMultiple shadows, inset shadows, spread, blur. Animatable.
outline, outline-width, outline-style, outline-color, outline-offsetDrawn as a ring outside the border

Conic and repeating gradients aren't drawn. Radial gradients at other positions or sizes draw at the center, at farthest-corner size. background-repeat, background-clip, background-origin and background-attachment are accepted and ignored.

#Effects

PropertyNotes
opacityGroup opacity. A translucent box with children is composited once, as in a browser.
filterblur(), brightness(), contrast(), grayscale(), hue-rotate(), invert(), opacity(), saturate(), sepia(), composed into one color matrix. drop-shadow() and url() aren't supported. macOS only.
backdrop-filterblur(): what's behind the box is blurred under its background. Other functions are skipped. macOS only.
clip-pathinset(50%) or more hides the box (Tailwind's sr-only). Other shapes aren't applied.
mix-blend-mode, maskNo

#Transforms

PropertyNotes
transformtranslate*(), rotate()/rotateZ(), scale*() and lists of them. Translations in px, % or mixed calc(). translate3d() and scale3d() keep their 2D part, and translateZ()/perspective() are ignored. rotateX()/rotateY(), skew() and matrix() aren't supported.
translate, rotate, scaleYes, composed with transform as CSS composes them
transform-originKeywords, lengths and percentages

A list composes as translate, rotate, scale, then any translate that came after a rotation (moving along the rotated axes). Rotations and scales in one list are each summed into one.

#Transitions and animations

PropertyNotes
transition, transition-property, -duration, -delay, -timing-functionAnimates colors, opacity, box-shadow, transforms, and px width/height/insets. See Styling.
animation, animation-name, -duration, -delay, -timing-function, -iteration-count, -direction, -fill-mode, -play-stateYes
animation-timeline, animation-range-*, animation-compositionAccepted. Animations run on time.

#Interaction

PropertyNotes
cursorauto, default, none, pointer, text, vertical-text, crosshair, copy, alias, context-menu, no-drop, not-allowed, grab, grabbing, col-resize, row-resize, and the n/e/s/w/ne/nw/se/sw/ew/ns/nesw/nwse-resize cursors
pointer-eventsnone (inherited) lets presses and hover pass through. auto restores them.
app-region, -webkit-app-regiondrag and no-drag, for custom title bars

#Images

PropertyNotes
object-fitfill, contain, cover, none, scale-down
object-positionYes

#SVG

fill, stroke, fill-opacity, fill-rule, stroke-opacity, stroke-width, stroke-linecap, stroke-linejoin, stroke-dasharray, stroke-dashoffset, shape-rendering, text-anchor and dominant-baseline apply to SVG elements, winning over their attributes. See Images, SVG and assets.

#Accepted and ignored

These parse without a warning but change nothing. Most have no effect in gpuijs, or are always effectively on:

box-sizing, appearance, user-select, resize, vertical-align, text-indent, text-align-last, text-size-adjust, text-rendering, tab-size, list-style-*, color-scheme, print-color-adjust, background-repeat, background-clip, background-origin, background-attachment, word-spacing: 0, border-spacing: 0, font-stretch: normal, font-variant-caps: normal, and the old -webkit-box-* and -ms-flex-* spellings that Emotion writes next to standard flexbox.

#Known gaps

The main things missing, in rough order of how often apps hit them:

  1. @font-face web fonts.
  2. position: sticky.
  3. Changing font size or family within a paragraph's inline text.
  4. Multi-line <textarea>.
  5. rowspan in tables.
  6. skew(), matrix() and real 3D transforms.
  7. Conic and repeating gradients, and gradients with more than four stops.
  8. mix-blend-mode, mask and arbitrary clip-path shapes.
  9. ::placeholder, ::selection and scrollbar styling.