class UI::TabView

Overview

A container that switches between views using a tab bar.

On iOS: UITabBarController (bottom Liquid Glass tab bar per HIG) On macOS: NSTabViewController with toolbar-style tabs On Android: BottomNavigationView + FragmentContainerView On Web: Tab panel with role="tablist"

HIG: "A tab bar lets people navigate between top-level sections of your app." HIG tab-bars Platform considerations (iOS): "A tab bar floats above content at the bottom of the screen. Its items rest on a Liquid Glass background that allows content beneath to peek through."

Defined in:

ui/views/tab_view.cr

Constructors

Instance Method Summary

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) : self
fluid_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

def self.new(tabs : Array(Tab) = [] of Tab, selected_index : Int32 = 0) #

[View source]
def self.new(tabs : Array(Tab), selected_index : Int32 = 0, &block : Int32 -> Nil) #

[View source]

Instance Method Detail

def accept(visitor : PlatformVisitor) #
Description copied from class UI::View

Accept a platform visitor for rendering dispatch. Each concrete view type calls visitor.visit(self).


[View source]
def bar_position : Symbol #

Position of the tab bar relative to the content area. :bottom -- iOS HIG default; bar floats at the bottom of the screen. :top -- macOS toolbar-style; bar appears above content.


[View source]
def bar_position=(bar_position : Symbol) #

Position of the tab bar relative to the content area. :bottom -- iOS HIG default; bar floats at the bottom of the screen. :top -- macOS toolbar-style; bar appears above content.


[View source]
def current_content : View | Nil #

The currently selected tab's content view


[View source]
def glass_bar : Bool #

Whether to apply Liquid Glass to the tab bar surface. Defaults true per HIG iOS tab-bars guidance. Set false for a plain opaque bar (brand override -- see component doc Customization section).


[View source]
def glass_bar=(glass_bar : Bool) #

Whether to apply Liquid Glass to the tab bar surface. Defaults true per HIG iOS tab-bars guidance. Set false for a plain opaque bar (brand override -- see component doc Customization section).


[View source]
def material_semantic : Symbol | Nil #

Phase 5 v2 — Apple semantic material override. nil = HIG-canonical default :system_resolved (SwiftUI's .toolbarBackground(.bar, for:) handles tab-bar chrome; AppleSemantic does NOT suppress that). To apply a custom material, set this to a non-default semantic role.


[View source]
def material_semantic=(material_semantic : Symbol | Nil) #

Phase 5 v2 — Apple semantic material override. nil = HIG-canonical default :system_resolved (SwiftUI's .toolbarBackground(.bar, for:) handles tab-bar chrome; AppleSemantic does NOT suppress that). To apply a custom material, set this to a non-default semantic role.


[View source]
def on_change : Proc(Int32, Nil) | Nil #

Callback when tab selection changes


[View source]
def on_change=(on_change : Proc(Int32, Nil) | Nil) #

Callback when tab selection changes


[View source]
def selected_index : Int32 #

Currently selected tab index (0-based)


[View source]
def selected_index=(selected_index : Int32) #

Currently selected tab index (0-based)


[View source]
def selected_tint_color : Color | Nil #

Tint color applied to the selected tab icon and label. Defaults to nil, which resolves to the system accent color (system blue via UIColor.tintColor / NSColor.controlAccentColor).


[View source]
def selected_tint_color=(selected_tint_color : Color | Nil) #

Tint color applied to the selected tab icon and label. Defaults to nil, which resolves to the system accent color (system blue via UIColor.tintColor / NSColor.controlAccentColor).


[View source]
def tabs : Array(Tab) #

The available tabs


[View source]
def tabs=(tabs : Array(Tab)) #

The available tabs


[View source]