setClass
Imperative helper for assigning classes to an element. Accepts a string, an array, a {className: boolean} object, or a reactive accessor. Strings replace the full class attribute; arrays and objects add/remove individual classes.
# Signature
# Arguments
| name | type | description |
|---|---|---|
| node | Element | target element |
| value | string | string[] | { className: boolean } | signal | a string sets class wholesale; array/object forms add truthy entries and remove falsy ones; functions are tracked reactively. |
Returns: void
# When to use
JSX's class= and class:myClass= already flow through setClass. Use the function when building nodes imperatively, writing a propsPlugin, or driving a class from an effect outside JSX.
Related: class:__ covers the declarative forms.