Skip to main content

ButtonStyle

Trait ButtonStyle 

Source
pub trait ButtonStyle {
    // Required method
    fn body(&self, label: AnyPiece) -> AnyPiece;

    // Provided method
    fn label_color(&self) -> Option<Color> { ... }
}
Expand description

A pluggable button appearance (the SwiftUI ButtonStyle analog). Pure composition — a style builds its body from existing pieces/decorators, so it needs no per-backend native code. Apply one with Button::style.

Required Methods§

Source

fn body(&self, label: AnyPiece) -> AnyPiece

Build the button’s visual body from its (type-erased) label piece.

Provided Methods§

Source

fn label_color(&self) -> Option<Color>

An optional label color applied by Button::style BEFORE the label reaches body. Defaults to None (the label keeps its intrinsic color). A filled/colored style overrides this to guarantee contrast — since body gets the label type-erased and cannot recolor it, this is the seam through which a style tints its label. FilledButtonStyle returns white.

Implementors§

Day API ↩ Guides· daybrite.dev