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. Every value must be a string, including numbers.

node.style('backgroundColor', '#1f6fb2')
node.style('padding', '12px 16px')
node.style('flex-grow', '1')

// Invalid: numeric values are not accepted.
node.style('opacity', 0.5) // 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

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.

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
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
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%
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

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

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, 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.

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