class dom::Style
sys::Obj dom::Style
@Js
Style models CSS style properties for an Elem.
- addClass
-
Add the given CSS class name to this element. If this element already contains the given class name, then this method does nothing. Returns this.
- classes
-
Str[] classes
The CSS classes for this element.
- clear
-
This clear()
Clear all style declarations.
- computed
-
Get the computed property value.
- effective
-
Get the effetive style property value, which is the most specific style or CSS rule in effect on this node. Returns
null
if no rule in effect for given property. - get
-
Get the given property value.
color := style["color"]
- hasClass
-
Return true if this element has the given CSS class name, or false if it does not.
- removeClass
-
Remove the given CSS class name to this element. If this element does not have the given class name, this method does nothing. Returns this.
- set
-
@Operator
This set(Str name, Obj? val)Set the given propery value. If
val
is null this property is removed.style["color"] = "#f00"
- setAll
-
Set all the given property values.
style.setAll(["color":"#f00", "font-weight":"bold"])
- setCss
-
Set properties via CSS text.
style.setCss("color: #f00; font-weight: bold;")
- toggleClass
-
This toggleClass(Str name, Bool? cond := null)
Toggle the presence of the given CSS class name based on the
cond
argument:null
: remove class if present, or add if missingtrue
: always add class (seeaddClass
)false
: always remove class(seeremoveClass
)
- trap
-
virtual override Obj? trap(Str name, Obj?[]? args := null)
Get or set an attribute. Attribute names should be specifed in camel case:
style->backgroundColor == style["background-color"]