class

Opal::UI::Element

Inherits Opal::UI::Themable < Reference < Object

Base class for all visual components in the declarative UI hierarchy.

Instance methods

add_class(name : String) : self
Source
children

Returns child elements for hierarchical tree traversal and DOM querying

Source
classes
Source
classes=(classes : Set(String))
Source
has_class?(name : String) : Bool
Source
id=(id : String | Nil)
Source
preferred_print_size(available_w : Int32) : Tuple(Int32, Int32)

Returns the preferred size for one-shot print mode rendering, where height should expand to fit all content rather than clamping to viewport rows.

Source
preferred_size(available_w : Int32, available_h : Int32) : Tuple(Int32, Int32)
Source
query(selector : String) : Array(Element)

Queries all descendants matching a CSS-like selector string

Source
query(klass : T.class) : Array(T) forall T

Queries all descendants matching a specific Crystal type class

Source
query_one(selector : String) : Element

Queries the first descendant matching selector, or raises KeyError

Source
query_one(klass : T.class) : T forall T

Queries the first descendant matching type class, or raises KeyError

Source
query_one?(selector : String) : Element | Nil

Queries the first descendant matching selector, or nil

Source
query_one?(klass : T.class) : T | Nil forall T

Queries the first descendant matching type class, or nil

Source
remove_class(name : String) : self
Source
render(buffer : Buffer, x : Int32, y : Int32, width : Int32, height : Int32) : Nil
Source
render_print(buffer : Buffer, width : Int32, height : Int32) : Nil

Print-mode rendering hook that components can override if their print layout differs from interactive layout

Source
to_print_s(width : Int32 | Nil = nil, color : Bool | Nil = nil, theme : Theme | Nil = nil) : String

Renders the element into a string buffer in one-shot print mode. If color is nil, auto-detects from TTY and NO_COLOR environment variable.

Source
to_string(width : Int32 | Nil = nil, color : Bool | Nil = nil, theme : Theme | Nil = nil) : String

Alias for to_print_s

Source