button_groups

Function button_groups 

Source
pub fn button_groups<F>(
    args: impl Into<ButtonGroupsArgs>,
    state: ButtonGroupsState,
    scope_config: F,
)
where F: FnOnce(&mut ButtonGroupsScope<'_>),
Expand description

§button_groups

Button groups organize buttons and add interactions between them.

§Usage

Used for grouping related actions.

§Arguments

  • args - Arguments for configuring the button group.
  • state - State of the button group.
  • scope_config - A closure that configures the children of the button group using a ButtonGroupsScope.

§Example

use tessera_ui_basic_components::{
   button_groups::{ButtonGroupsArgs, ButtonGroupsState, button_groups},
   text::{TextArgs, text},
};

let button_groups_state = ButtonGroupsState::default();
button_groups(
    ButtonGroupsArgs::default(),
    button_groups_state.clone(),
    |scope| {
        scope.child(
            |color| {
                text(TextArgs {
                    text: "Button 1".to_string(),
                    color,
                    ..Default::default()
                })
            },
            |_| {
                println!("Button 1 clicked");
            },
        );

        scope.child(
            |color| {
                text(TextArgs {
                    text: "Button 2".to_string(),
                    color,
                    ..Default::default()
                })
            },
            |actived| {
                println!("Button 2 clicked");
            },
        );

        scope.child(
            |color| {
                text(TextArgs {
                    text: "Button 3".to_string(),
                    color,
                    ..Default::default()
                })
            },
            |actived| {
                println!("Button 3 clicked");
            },
        );
    },
);