abstract class
UI::View
- UI::View
- Reference
- Object
Overview
Abstract base class for all UI views.
Crystal prohibits recursive structs, so View must be a class. VStack/HStack/ZStack children arrays contain View references, creating a recursive type relationship.
Direct Known Subclasses
- UI::ActionSheetWithWebFallback
- UI::ActivityIndicator
- UI::ActivityRing
- UI::ActivityRings
- UI::ActivityView
- UI::Alert
- UI::AsyncImage
- UI::Button
- UI::Canvas
- UI::Capsule
- UI::Card
- UI::ChartView
- UI::Checkbox
- UI::Circle
- UI::ColorPicker
- UI::ColumnView
- UI::ComboBox
- UI::ConfirmationDialog
- UI::ContextMenuWithWebFallback
- UI::DatePicker
- UI::DisclosureGroup
- UI::Divider
- UI::Form
- UI::Gauge
- UI::GlassBackground
- UI::Grid
- UI::HStack
- UI::IconButton
- UI::Image
- UI::ImageWell
- UI::Label
- UI::LinkButton
- UI::ListView
- UI::MapView
- UI::MenuButton
- UI::NavigationLink
- UI::NavigationSplitView
- UI::NavigationStack
- UI::OutlineView
- UI::PageControl
- UI::Panel
- UI::PathControlWithWebFallback
- UI::PathView
- UI::Picker
- UI::Popover
- UI::ProgressView
- UI::RadioGroup
- UI::RatingIndicator
- UI::Rectangle
- UI::RichText
- UI::RoundedRectangle
- UI::ScrollView
- UI::SearchField
- UI::SecureField
- UI::SegmentedControl
- UI::Sheet
- UI::Slider
- UI::Snackbar
- UI::Spacer
- UI::Stepper
- UI::Surface
- UI::SwipeActionRow
- UI::TabView
- UI::TextArea
- UI::TextEditor
- UI::TextField
- UI::TimePicker
- UI::Toggle
- UI::ToggleButton
- UI::TokenField
- UI::Toolbar
- UI::Tooltip
- UI::VideoPlayer
- UI::VStack
- UI::WebViewComponent
- UI::ZStack
Defined in:
ui/view.crInstance Method Summary
-
#accept(visitor : PlatformVisitor)
Accept a platform visitor for rendering dispatch.
-
#accessibility_label : String | Nil
Accessibility label read by screen readers
-
#accessibility_label=(accessibility_label : String | Nil)
Accessibility label read by screen readers
-
#background : Color | Nil
Background color, nil means transparent/inherited
-
#background=(background : Color | Nil)
Background color, nil means transparent/inherited
-
#blur_radius : Float64
Blur modifier
-
#blur_radius=(blur_radius : Float64)
Blur modifier
- #border_color : Color | Nil
- #border_color=(border_color : Color | Nil)
-
#border_width : Float64
Border modifier
-
#border_width=(border_width : Float64)
Border modifier
- #clip_to_bounds : Bool
- #clip_to_bounds=(clip_to_bounds : Bool)
-
#container_query(name : String) : self
Chainable setter: mark this view as a container-query root.
-
#container_query_name : String | Nil
Container query name.
-
#container_query_name=(container_query_name : String | Nil)
Container query name.
-
#corner_radius : Float64
Shape modifiers
-
#corner_radius=(corner_radius : Float64)
Shape modifiers
-
#fill_screen! : self
Chainable shortcut for
self.root_fill = true. -
#fluid_height(min : String | Number, ideal : String | Number, max : String | Number) : self
Chainable setter: set a fluid vertical size.
- #fluid_height : UI::Fluid | Nil
- #fluid_height=(fluid_height : UI::Fluid | Nil)
-
#fluid_width(min : String | Number, ideal : String | Number, max : String | Number) : self
Chainable setter: set a fluid horizontal size.
-
#fluid_width : UI::Fluid | Nil
Fluid (responsive) size constraints.
-
#fluid_width=(fluid_width : UI::Fluid | Nil)
Fluid (responsive) size constraints.
-
#hidden : Bool
Whether the view is hidden from display
-
#hidden=(hidden : Bool)
Whether the view is hidden from display
-
#id : String | Nil
Optional identifier for this view, used for lookup and testing
-
#id=(id : String | Nil)
Optional identifier for this view, used for lookup and testing
- #maximum_height : Float64 | Nil
- #maximum_height=(maximum_height : Float64 | Nil)
- #maximum_width : Float64 | Nil
- #maximum_width=(maximum_width : Float64 | Nil)
- #minimum_height : Float64 | Nil
- #minimum_height=(minimum_height : Float64 | Nil)
-
#minimum_width : Float64 | Nil
Size constraints
-
#minimum_width=(minimum_width : Float64 | Nil)
Size constraints
-
#opacity : Float64
Opacity from 0.0 (fully transparent) to 1.0 (fully opaque)
-
#opacity=(opacity : Float64)
Opacity from 0.0 (fully transparent) to 1.0 (fully opaque)
-
#padding : EdgeInsets
Padding around the view content
-
#padding=(padding : EdgeInsets)
Padding around the view content
-
#root_fill : Bool
Phase 6.10 Rem 4 (Item 2D) — root-fill flag.
-
#root_fill=(root_fill : Bool)
Phase 6.10 Rem 4 (Item 2D) — root-fill flag.
- #shadow_color : Color | Nil
- #shadow_color=(shadow_color : Color | Nil)
- #shadow_offset_x : Float64
- #shadow_offset_x=(shadow_offset_x : Float64)
- #shadow_offset_y : Float64
- #shadow_offset_y=(shadow_offset_y : Float64)
-
#shadow_radius : Float64
Shadow modifier
-
#shadow_radius=(shadow_radius : Float64)
Shadow modifier
-
#swiftkit_state_handle : Pointer(Void) | Nil
SwiftKit reactive-state opaque pointer (Phase 3 Remediation 4).
-
#swiftkit_state_handle=(swiftkit_state_handle : Pointer(Void) | Nil)
SwiftKit reactive-state opaque pointer (Phase 3 Remediation 4).
-
#test_id : String | Nil
Test identifier for automated UI testing, maps to native test attributes
-
#test_id=(test_id : String | Nil)
Test identifier for automated UI testing, maps to native test attributes
Instance Method Detail
Accept a platform visitor for rendering dispatch.
Each concrete view type calls visitor.visit(self).
Accessibility label read by screen readers
Background color, nil means transparent/inherited
Chainable setter: mark this view as a container-query root. Renderers
that support container queries emit container-type: inline-size and
container-name: <name> on this element so descendant rules of the
form @container <name> (min-width: ...) resolve against this box.
Container query name. When set, the web renderer emits
container-type: inline-size; container-name: <name> on the element so
nested @container <name> (...) blocks resolve against this view's box
rather than the viewport.
Container query name. When set, the web renderer emits
container-type: inline-size; container-name: <name> on the element so
nested @container <name> (...) blocks resolve against this view's box
rather than the viewport.
Chainable setter: set a fluid vertical size. See #fluid_width.
Chainable setter: set a fluid horizontal size. Accepts CSS-compatible
strings (e.g. "60vw", "20rem") or numeric pixel values, which are
emitted as Npx. Returns self so calls can be chained.
Fluid (responsive) size constraints. When set, the web renderer emits a
width: clamp(min, ideal, max) (resp. height:) declaration instead of
the literal minimum_* / maximum_* pair. Native renderers will adopt
platform-idiomatic size class translations in later phases.
Fluid (responsive) size constraints. When set, the web renderer emits a
width: clamp(min, ideal, max) (resp. height:) declaration instead of
the literal minimum_* / maximum_* pair. Native renderers will adopt
platform-idiomatic size class translations in later phases.
Phase 6.10 Rem 4 (Item 2D) — root-fill flag.
When true, the renderer treats this view as a full-screen root
and:
- iOS / macOS: pins the view's width to the device screen width
and lets its height grow to the screen height (or scroll if
content exceeds it). Replaces the brittle hardcoded
content_width = 340.0pattern. - Web: emits
min-height: 100dvh+width: 100%(CSS dvh respects mobile address-bar resizing).
Set via view.root_fill = true or the chainable shortcut
view.fill_screen! (returns self for chaining).
The renderer-side honoring is best-effort — a #root_fill view
nested deep inside another stack is still constrained by its
parent's bounds. The intent is the OUTER root of an iOS / macOS
screen.
Phase 6.10 Rem 4 (Item 2D) — root-fill flag.
When true, the renderer treats this view as a full-screen root
and:
- iOS / macOS: pins the view's width to the device screen width
and lets its height grow to the screen height (or scroll if
content exceeds it). Replaces the brittle hardcoded
content_width = 340.0pattern. - Web: emits
min-height: 100dvh+width: 100%(CSS dvh respects mobile address-bar resizing).
Set via view.root_fill = true or the chainable shortcut
view.fill_screen! (returns self for chaining).
The renderer-side honoring is best-effort — a #root_fill view
nested deep inside another stack is still constrained by its
parent's bounds. The intent is the OUTER root of an iOS / macOS
screen.
SwiftKit reactive-state opaque pointer (Phase 3 Remediation 4).
Populated by the AppKit / UIKit renderer's visit method for views
that participate in the reactive surface (today: UI::Label,
UI::Button, UI::Toggle, UI::Slider). It mirrors the same
pointer held on the underlying NativeHandle so Crystal-side widget
mutators (e.g. UI::Label#text=) can dispatch through
LibSwiftKitBridge.apsk_*_set_* without having to thread the
NativeHandle back to user code. Nil for views that haven't been
rendered yet, weren't rendered by a SwiftKit renderer (Web /
Android), or aren't reactive widgets.
Lifetime: the pointer is +1 retained on the Swift side. The
NativeHandle.release! path drops the retain via
apsk_state_release; the View doesn't need to participate.
SwiftKit reactive-state opaque pointer (Phase 3 Remediation 4).
Populated by the AppKit / UIKit renderer's visit method for views
that participate in the reactive surface (today: UI::Label,
UI::Button, UI::Toggle, UI::Slider). It mirrors the same
pointer held on the underlying NativeHandle so Crystal-side widget
mutators (e.g. UI::Label#text=) can dispatch through
LibSwiftKitBridge.apsk_*_set_* without having to thread the
NativeHandle back to user code. Nil for views that haven't been
rendered yet, weren't rendered by a SwiftKit renderer (Web /
Android), or aren't reactive widgets.
Lifetime: the pointer is +1 retained on the Swift side. The
NativeHandle.release! path drops the retain via
apsk_state_release; the View doesn't need to participate.
Test identifier for automated UI testing, maps to native test attributes
Test identifier for automated UI testing, maps to native test attributes