class
UI::Button
- UI::Button
- UI::View
- Reference
- Object
Overview
A tappable button with a text label and optional action callback.
The #on_tap proc is invoked when the button is activated.
Buttons can be disabled to prevent interaction.
Defined in:
ui/views/button.crConstructors
- .new(label : String, *, role : Symbol = :default, style : ButtonStyle = ButtonStyle::Default, symbol : String | Nil = nil, type : Type = Type::Button)
-
.new(label : String, *, role : Symbol = :default, style : ButtonStyle = ButtonStyle::Default, symbol : String | Nil = nil, type : Type = Type::Button, &block : -> Nil)
Convenience constructor that accepts a tap handler block
Instance Method Summary
-
#accept(visitor : PlatformVisitor)
Accept a platform visitor for rendering dispatch.
-
#background=(new_color : Color | Nil) : Color | Nil
Background color, nil means transparent/inherited
-
#corner_radius=(new_radius : Float64) : Float64
Shape modifiers
-
#disabled : Bool
Whether the button is disabled (non-interactive).
- #disabled=(new_value : Bool) : Bool
-
#font : Font
Font for the button label
-
#font=(font : Font)
Font for the button label
-
#foreground_color : Color
Foreground (label) color
-
#foreground_color=(new_color : Color) : Color
Foreground (label) color
-
#label : String
The button's display label
-
#label=(label : String)
The button's display label
-
#on_tap : Proc(Nil) | Nil
Callback invoked when the button is tapped
-
#on_tap=(on_tap : Proc(Nil) | Nil)
Callback invoked when the button is tapped
-
#role : Symbol
Semantic role for the button.
-
#role=(role : Symbol)
Semantic role for the button.
-
#style : ButtonStyle
Visual style.
-
#style=(style : ButtonStyle)
Visual style.
-
#symbol : String | Nil
Leading SF Symbol glyph name (macOS 11+ / iOS 13+).
-
#symbol=(symbol : String | Nil)
Leading SF Symbol glyph name (macOS 11+ / iOS 13+).
-
#type : Type
HTML form-submission role on the web target.
-
#type=(type : Type)
HTML form-submission role on the web target.
Instance methods inherited from class UI::View
accept(visitor : PlatformVisitor)
accept,
accessibility_label : String | Nil
accessibility_label,
accessibility_label=(accessibility_label : String | Nil)
accessibility_label=,
background : Color | Nil
background,
background=(background : Color | Nil)
background=,
blur_radius : Float64
blur_radius,
blur_radius=(blur_radius : Float64)
blur_radius=,
border_color : Color | Nil
border_color,
border_color=(border_color : Color | Nil)
border_color=,
border_width : Float64
border_width,
border_width=(border_width : Float64)
border_width=,
clip_to_bounds : Bool
clip_to_bounds,
clip_to_bounds=(clip_to_bounds : Bool)
clip_to_bounds=,
container_query(name : String) : self
container_query,
container_query_name : String | Nil
container_query_name,
container_query_name=(container_query_name : String | Nil)
container_query_name=,
corner_radius : Float64
corner_radius,
corner_radius=(corner_radius : Float64)
corner_radius=,
fill_screen! : self
fill_screen!,
fluid_height(min : String | Number, ideal : String | Number, max : String | Number) : selffluid_height : UI::Fluid | Nil fluid_height, fluid_height=(fluid_height : UI::Fluid | Nil) fluid_height=, fluid_width(min : String | Number, ideal : String | Number, max : String | Number) : self
fluid_width : UI::Fluid | Nil fluid_width, fluid_width=(fluid_width : UI::Fluid | Nil) fluid_width=, hidden : Bool hidden, hidden=(hidden : Bool) hidden=, id : String | Nil id, id=(id : String | Nil) id=, maximum_height : Float64 | Nil maximum_height, maximum_height=(maximum_height : Float64 | Nil) maximum_height=, maximum_width : Float64 | Nil maximum_width, maximum_width=(maximum_width : Float64 | Nil) maximum_width=, minimum_height : Float64 | Nil minimum_height, minimum_height=(minimum_height : Float64 | Nil) minimum_height=, minimum_width : Float64 | Nil minimum_width, minimum_width=(minimum_width : Float64 | Nil) minimum_width=, opacity : Float64 opacity, opacity=(opacity : Float64) opacity=, padding : EdgeInsets padding, padding=(padding : EdgeInsets) padding=, root_fill : Bool root_fill, root_fill=(root_fill : Bool) root_fill=, shadow_color : Color | Nil shadow_color, shadow_color=(shadow_color : Color | Nil) shadow_color=, shadow_offset_x : Float64 shadow_offset_x, shadow_offset_x=(shadow_offset_x : Float64) shadow_offset_x=, shadow_offset_y : Float64 shadow_offset_y, shadow_offset_y=(shadow_offset_y : Float64) shadow_offset_y=, shadow_radius : Float64 shadow_radius, shadow_radius=(shadow_radius : Float64) shadow_radius=, swiftkit_state_handle : Pointer(Void) | Nil swiftkit_state_handle, swiftkit_state_handle=(swiftkit_state_handle : Pointer(Void) | Nil) swiftkit_state_handle=, test_id : String | Nil test_id, test_id=(test_id : String | Nil) test_id=
Constructor Detail
Convenience constructor that accepts a tap handler block
Instance Method Detail
Accept a platform visitor for rendering dispatch.
Each concrete view type calls visitor.visit(self).
Background color, nil means transparent/inherited
Shape modifiers
Whether the button is disabled (non-interactive).
Reactive: after the renderer has emitted the SwiftUI hosting view,
mutating this property propagates through the SwiftKit bridge so
SwiftUI re-renders the Button with .disabled(true) / .disabled(false)
without a tree rebuild. Setters issued before the view has been
rendered are plain property assignments — the next render seeds the
reactive state from the new value. Phase 6.11 added the reactive
path so the Voyager Todo editor can flip Save's disabled state as
the user types (blank title → disabled; non-blank → enabled) without
rebuilding the whole screen.
Semantic role for the button. HIG-standard values: :default — normal/primary action (no special styling) :destructive — action destroys data; renderers color the label red :cancel — dismisses a presentation surface; renderers weight the label Semibold per HIG
Semantic role for the button. HIG-standard values: :default — normal/primary action (no special styling) :destructive — action destroys data; renderers color the label red :cancel — dismisses a presentation surface; renderers weight the label Semibold per HIG
Visual style. See ButtonStyle for full documentation. Default renders as a system bordered button; override to Prominent for filled-blue primary CTAs or Borderless for text-link style.
Visual style. See ButtonStyle for full documentation. Default renders as a system bordered button; override to Prominent for filled-blue primary CTAs or Borderless for text-link style.
Leading SF Symbol glyph name (macOS 11+ / iOS 13+). When non-nil the renderers prepend an SF Symbol image to the button. Unknown symbol names are silently skipped rather than crashing.
Leading SF Symbol glyph name (macOS 11+ / iOS 13+). When non-nil the renderers prepend an SF Symbol image to the button. Unknown symbol names are silently skipped rather than crashing.
HTML form-submission role on the web target. See UI::Button::Type.
Defaults to Type::Button (non-submitting). Set explicitly on the
button intended to submit a UI::Form — multi-button forms do NOT
auto-promote; only single-button forms do (see UI::Form).
HTML form-submission role on the web target. See UI::Button::Type.
Defaults to Type::Button (non-submitting). Set explicitly on the
button intended to submit a UI::Form — multi-button forms do NOT
auto-promote; only single-button forms do (see UI::Form).