v0.20.230 - 6.8 / 6.2

setStyle

Imperative helper for applying styles to an element. Accepts a CSS string, a style object, or a reactive accessor. A property value of null, undefined or false removes that property.

# Signature

# Arguments

nametypedescription
nodeElementtarget element
valuestring | object | signalstrings are assigned to style.cssText; objects are applied property-by-property; functions are unwrapped reactively. A property set to null, undefined or false is removed.

Returns: void

# When to use

In JSX, style="…", style={…} and style:color={…} already route through this helper. Call setStyle directly when you are building elements imperatively, writing a propsPlugin, or driving styles from an effect outside the render tree.

# Snippet