Docs
API Reference

Styles

uno implements a strict CSS-like subset. Style names accept both camelCase and kebab-case. The TypeScript type StyleName only includes camelCase names. Values are strings; node.style() also accepts a number for numeric longhands.

node.style('backgroundColor', '#1f6fb2')
node.style('padding', '12px 16px')
node.style('flex-grow', '1')
node.style('translateX', 120) // 120px
node.style('opacity', 0.5)

// Invalid: shorthands, colors, and keywords need a string.
node.style('padding', 12) // Throws an error

Units and common values

Value familyAccepted values
Lengthpx, rem, vw, or vh
Percentage lengthThe length units above plus %
ColorHex only: #RGB, #RGBA, #RRGGBB, or #RRGGBBAA
NumberA number encoded as a string, for example '1' or '0.5'
IntegerAn integer encoded as a string
Angledeg only, for example '45deg' or '-90deg'

In WebGPU, rem uses the value set by ui.setRootSize() (16 by default), while vw and vh use the last values supplied to ui.setViewport().

CSS-wide keywords other than unset, CSS functions such as calc() and var(), named colors, rgb(), em, and arbitrary CSS declarations are not supported.

Numeric values

node.style() accepts a number for the longhands in the NumberStyleName type. Lengths read it as px and rotate as deg; opacity, zIndex, flexGrow, flexShrink, aspectRatio, lineHeight, scaleX, and scaleY read it as is. node.style('width', 200) stores the same value as node.style('width', '200px') and applies the same range checks, but skips string parsing, so prefer numbers for values that change every frame. Percentages, rem, vw, vh, auto, unset, shorthands, colors, and keywords still need a string, and framework style props keep string values.

Resetting styles with unset

All properties accept 'unset'. Use it to clear a previously applied value:

node.style('opacity', '0.5')
node.style('opacity', 'unset')

For shorthands, 'unset' clears all the properties they expand into. For example, it clears padding on all four sides:

node.style('padding', '12px 16px')
node.style('padding', 'unset')

Framework adapters automatically apply 'unset' when a previously applied property is removed from the style object. In this React example, changing dimmed from true to false removes opacity and clears its previous value:

function Example({ dimmed }: { dimmed: boolean }) {
  return <View style={dimmed ? { opacity: '0.5' } : {}} />
}

Style properties

PropertyTypeAccepted values / expansion
displayyoga-layoutflex, none, contents
positionyoga-layoutstatic, relative, absolute
topyoga-layoutSigned percentage length or auto
rightyoga-layoutSigned percentage length or auto
bottomyoga-layoutSigned percentage length or auto
leftyoga-layoutSigned percentage length or auto
widthyoga-layoutNon-negative percentage length or auto
heightyoga-layoutNon-negative percentage length or auto
minWidthyoga-layoutNon-negative percentage length
minHeightyoga-layoutNon-negative percentage length
maxWidthyoga-layoutNon-negative percentage length
maxHeightyoga-layoutNon-negative percentage length
boxSizingyoga-layoutborder-box, content-box
aspectRatioyoga-layoutNon-negative number
flexDirectionyoga-layoutcolumn, column-reverse, row, row-reverse
flexWrapyoga-layoutnowrap, wrap, wrap-reverse
flexGrowyoga-layoutNon-negative number
flexShrinkyoga-layoutNon-negative number
flexBasisyoga-layoutNon-negative percentage length or auto
justifyContentyoga-layoutflex-start, center, flex-end, space-between, space-around, space-evenly
alignContentyoga-layoutValues above plus stretch, baseline
alignItemsyoga-layoutnormal, flex-start, center, flex-end, stretch, baseline
alignSelfyoga-layoutauto, normal, flex-start, center, flex-end, stretch, baseline
marginTopyoga-layoutSigned percentage length or auto
marginRightyoga-layoutSigned percentage length or auto
marginBottomyoga-layoutSigned percentage length or auto
marginLeftyoga-layoutSigned percentage length or auto
paddingTopyoga-layoutNon-negative percentage length
paddingRightyoga-layoutNon-negative percentage length
paddingBottomyoga-layoutNon-negative percentage length
paddingLeftyoga-layoutNon-negative percentage length
gapyoga-layoutNon-negative percentage length
rowGapyoga-layoutNon-negative percentage length
columnGapyoga-layoutNon-negative percentage length
overflowXyoga-layoutvisible, hidden, scroll
overflowYyoga-layoutvisible, hidden, scroll
directionyoga-layoutinherit, ltr, rtl
backgroundColorpaintingHex color
backgroundImagepaintingA key registered in the UI's resource store
backgroundSizeWidthpaintingNon-negative percentage length, cover, or contain
backgroundSizeHeightpaintingNon-negative percentage length, cover, or contain
backgroundPositionXpaintingSigned percentage length
backgroundPositionYpaintingSigned percentage length
backgroundRepeatpaintingno-repeat, repeat, repeat-x, repeat-y
borderTopWidthpaintingNon-negative length (no %)
borderRightWidthpaintingNon-negative length (no %)
borderBottomWidthpaintingNon-negative length (no %)
borderLeftWidthpaintingNon-negative length (no %)
borderTopStylepaintingnone, solid
borderRightStylepaintingnone, solid
borderBottomStylepaintingnone, solid
borderLeftStylepaintingnone, solid
borderTopColorpaintingHex color
borderRightColorpaintingHex color
borderBottomColorpaintingHex color
borderLeftColorpaintingHex color
borderTopLeftRadiuspaintingNon-negative percentage length
borderTopRightRadiuspaintingNon-negative percentage length
borderBottomRightRadiuspaintingNon-negative percentage length
borderBottomLeftRadiuspaintingNon-negative percentage length
boxShadowpaintingoffset-x offset-y blur spread [color]; length units only, non-negative blur, black default color
opacitypaintingNumber from 0 through 1
translateXpaintingSigned px length
translateYpaintingSigned px length
scaleXpaintingNon-negative number
scaleYpaintingNon-negative number
rotatepaintingSigned deg angle; positive turns clockwise
zIndexpaintingInteger
pointerEventspaintingall, none
colortextHex color
fontFamilytextFont name; case is preserved. WebGPU requires a registered font.
fontSizetextNon-negative length (no %)
lineHeighttextNon-negative unitless number or non-negative length
letterSpacingtextSigned length
textAligntextleft, right, center, justify
whiteSpacetextnormal, nowrap, pre-wrap, pre
textShadowtextoffset-x offset-y blur [color]; length units only, non-negative blur, black default color
textStroketextwidth color; non-negative length and a hex color
overflowshorthandsoverflowX, overflowY
bordershorthandsWidth, style, and color for all four sides
borderRadiusshorthandsOne to four corner radii
backgroundSizeshorthandsOne or two dimensions, or cover/contain alone
backgroundPositionshorthandsX and optional Y; Y defaults to 50%
translateshorthandstranslateX and optional translateY; Y defaults to 0px
scaleshorthandsscaleX and optional scaleY; Y defaults to X
marginshorthandsOne to four edge values
paddingshorthandsOne to four edge values
flexshorthandsCSS-like one-, two-, or three-value expansion to grow/shrink/basis; auto is supported, none is not

whiteSpace: 'pre' preserves whitespace and explicit line breaks in text nodes while disabling automatic wrapping. Unlike nowrap, it preserves repeated spaces; unlike pre-wrap, it does not wrap text to fit the available width.

pointerEvents: 'none' removes a node from WebGPU hit testing.

translate, scale, and rotate move, scale, and turn what a node and its subtree paint without changing layout. As with the CSS individual transform properties, the origin is the center of the box: the scale applies first, then the rotation, then the translation. rotate only turns in the plane of the screen; the CSS axis forms such as rotate: x 45deg are not supported. Hit testing follows the transformed box. To animate every frame, prefer them over left, top, or fontSize: they do not trigger layout. To change a single axis, set translateX, translateY, scaleX, or scaleY; they have no CSS equivalent and the DOM renderer composes them into translate and scale.

A UI created with yoga: false only reads the box styles listed in Layout without Yoga and ignores the other yoga-layout styles.

The WebGPU renderer uses MTSDF alpha distance for strokes and shadows and the RGB distance field for the glyph fill.

Longhands are also public style names. For example, backgroundSizeWidth, backgroundPositionY, translateX, and every side-specific border property can be assigned directly.

Rendering differences

  • Opacity: WebGPU multiplies ancestor opacity into each drawable separately. Overlapping elements can therefore look different from CSS, which composites the subtree before applying group opacity.
  • Overflow: overflow: 'hidden' and overflow: 'scroll' clip children to a rectangle. borderRadius does not round this clip, so children can remain visible in the rounded corners.
  • Transforms: in WebGPU, translate, scale, and rotate do not extend the scrollable overflow (scrollWidth, scrollHeight). With a non-uniform scale, shadow blur and spread and the text stroke width use the smaller factor. Box shadow offsets, blur, and spread are rounded to whole pixels, so an animated scale moves them in 1 px steps.
  • Rotation: WebGPU ignores overflow: 'hidden' and overflow: 'scroll' on a rotated node and inside its subtree, so their children are not clipped; a scroll container still scrolls. Clips from ancestors above the rotation still apply. The DOM renderer clips rotated subtrees, as CSS does. Under a non-uniform scale above a rotation, WebGPU places every descendant exactly but draws each box as a rotated rectangle, without the skew that CSS shows.

Images and objectFit

objectFit is not a core style name. It is an Image component option implemented by the framework adapters:

objectFitApplied background size
fill (default)100% 100%
containcontain
covercover
noneunset

When neither dimension is supplied, Image uses the registered resource dimensions. When only one is supplied, it derives aspectRatio. Values inside style take precedence over the component's width and height props.

On this page