class dom::Style

sys::Obj
  dom::Style

@Js

Source

Style models CSS style properties for an Elem.

addClass

This addClass(Str name)

Source

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.

addPseudoClass

Str addPseudoClass(Str name, Str css)

Source

Add a psuedo-class CSS definietion to this element. A new class name is auto-generated and used to prefix name, name must start with the : character. Returns the generated class name.

style.addPseudoClass(":hover", "background: #eee")
classes

Str[] classes

Source

The CSS classes for this element.

clear

This clear()

Source

Clear all style declarations.

computed

Obj? computed(Str name)

Source

Get the computed property value.

effective

Obj? effective(Str name)

Source

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

@Operator
Obj? get(Str name)

Source

Get the given property value.

color := style["color"]
hasClass

Bool hasClass(Str name)

Source

Return true if this element has the given CSS class name, or false if it does not.

removeClass

This removeClass(Str name)

Source

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)

Source

Set the given propery value. If val is null this property is removed.

style["color"] = "#f00"
setAll

This setAll(Str:Obj? map)

Source

Set all the given property values.

style.setAll(["color":"#f00", "font-weight":"bold"])
setCss

This setCss(Str css)

Source

Set properties via CSS text.

style.setCss("color: #f00; font-weight: bold;")
toggleClass

This toggleClass(Str name, Bool? cond := null)

Source

Toggle the presence of the given CSS class name based on the cond argument:

  • null: remove class if present, or add if missing
  • true: always add class (see addClass)
  • false: always remove class(see removeClass)
trap

virtual override Obj? trap(Str name, Obj?[]? args := null)

Source

Get or set an attribute. Attribute names should be specifed in camel case:

style->backgroundColor == style["background-color"]