boltz-ui 0.2.7

High-level reusable GPUI UI components (Label, Button, Input, etc.).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
use crate::component_prelude::*;
use gpui::{AnyElement, AnyView, DefiniteLength};
use ui_macros::RegisterComponent;

use crate::traits::animation_ext::CommonAnimationExt;
use crate::{ButtonCommon, ButtonLike, ButtonSize, ButtonStyle, Icon, Label};
use crate::{
    Color, DynamicSpacing, ElevationIndex, KeyBinding, KeybindingPosition, TintColor, prelude::*,
};

/// An element that creates a button with a label and optional icons.
///
/// Common buttons:
/// - Label, Icon + Label: [`Button`] (this component)
/// - Icon only: [`IconButton`]
/// - Custom: [`ButtonLike`]
///
/// To create a more complex button than what the [`Button`] or [`IconButton`] components provide, use
/// [`ButtonLike`] directly.
///
/// # Examples
///
/// **A button with a label**, is typically used in scenarios such as a form, where the button's label
/// indicates what action will be performed when the button is clicked.
///
/// ```
/// use ui::prelude::*;
///
/// Button::new("button_id", "Click me!")
///     .on_click(|event, window, cx| {
///         // Handle click event
///     });
/// ```
///
/// **A toggleable button**, is typically used in scenarios such as a toolbar,
/// where the button's state indicates whether a feature is enabled or not, or
/// a trigger for a popover menu, where clicking the button toggles the visibility of the menu.
///
/// ```
/// use ui::prelude::*;
///
/// Button::new("button_id", "Click me!")
///     .start_icon(Icon::new(IconName::Check))
///     .toggle_state(true)
///     .on_click(|event, window, cx| {
///         // Handle click event
///     });
/// ```
///
/// To change the style of the button when it is selected use the [`selected_style`][Button::selected_style] method.
///
/// ```
/// use ui::prelude::*;
/// use ui::TintColor;
///
/// Button::new("button_id", "Click me!")
///     .toggle_state(true)
///     .selected_style(ButtonStyle::Tinted(TintColor::Accent))
///     .on_click(|event, window, cx| {
///         // Handle click event
///     });
/// ```
/// This will create a button with a blue tinted background when selected.
///
/// **A full-width button**, is typically used in scenarios such as the bottom of a modal or form, where it occupies the entire width of its container.
/// The button's content, including text and icons, is centered by default.
///
/// ```
/// use ui::prelude::*;
///
/// let button = Button::new("button_id", "Click me!")
///     .full_width()
///     .on_click(|event, window, cx| {
///         // Handle click event
///     });
/// ```
///
#[derive(IntoElement, Documented, RegisterComponent)]
pub struct Button {
    base: ButtonLike,
    label: SharedString,
    label_color: Option<Color>,
    label_size: Option<LabelSize>,
    selected_label: Option<SharedString>,
    selected_label_color: Option<Color>,
    start_icon: Option<Icon>,
    end_icon: Option<Icon>,
    key_binding: Option<KeyBinding>,
    key_binding_position: KeybindingPosition,
    alpha: Option<f32>,
    truncate: bool,
    loading: bool,
}

impl Button {
    /// Creates a new [`Button`] with a specified identifier and label.
    ///
    /// This is the primary constructor for a [`Button`] component. It initializes
    /// the button with the provided identifier and label text, setting all other
    /// properties to their default values, which can be customized using the
    /// builder pattern methods provided by this struct.
    pub fn new(id: impl Into<ElementId>, label: impl Into<SharedString>) -> Self {
        Self {
            base: ButtonLike::new(id),
            label: label.into(),
            label_color: None,
            label_size: None,
            selected_label: None,
            selected_label_color: None,
            start_icon: None,
            end_icon: None,
            key_binding: None,
            key_binding_position: KeybindingPosition::default(),
            alpha: None,
            truncate: false,
            loading: false,
        }
    }

    /// Sets the color of the button's label.
    pub fn color(mut self, label_color: impl Into<Option<Color>>) -> Self {
        self.label_color = label_color.into();
        self
    }

    /// Defines the size of the button's label.
    pub fn label_size(mut self, label_size: impl Into<Option<LabelSize>>) -> Self {
        self.label_size = label_size.into();
        self
    }

    /// Sets the label used when the button is in a selected state.
    pub fn selected_label<L: Into<SharedString>>(mut self, label: impl Into<Option<L>>) -> Self {
        self.selected_label = label.into().map(Into::into);
        self
    }

    /// Sets the label color used when the button is in a selected state.
    pub fn selected_label_color(mut self, color: impl Into<Option<Color>>) -> Self {
        self.selected_label_color = color.into();
        self
    }

    /// Sets an icon to display at the start (left) of the button label.
    ///
    /// The icon's color will be overridden to `Color::Disabled` when the button is disabled.
    pub fn start_icon(mut self, icon: impl Into<Option<Icon>>) -> Self {
        self.start_icon = icon.into();
        self
    }

    /// Sets an icon to display at the end (right) of the button label.
    ///
    /// The icon's color will be overridden to `Color::Disabled` when the button is disabled.
    pub fn end_icon(mut self, icon: impl Into<Option<Icon>>) -> Self {
        self.end_icon = icon.into();
        self
    }

    /// Display the keybinding that triggers the button action.
    pub fn key_binding(mut self, key_binding: impl Into<Option<KeyBinding>>) -> Self {
        self.key_binding = key_binding.into();
        self
    }

    /// Sets the position of the keybinding relative to the button label.
    ///
    /// This method allows you to specify where the keybinding should be displayed
    /// in relation to the button's label.
    pub fn key_binding_position(mut self, position: KeybindingPosition) -> Self {
        self.key_binding_position = position;
        self
    }

    /// Sets the alpha property of the color of label.
    pub fn alpha(mut self, alpha: f32) -> Self {
        self.alpha = Some(alpha);
        self
    }

    /// Truncates overflowing labels with an ellipsis (`…`) if needed.
    ///
    /// Buttons with static labels should _never_ be truncated, ensure
    /// this is only used when the label is dynamic and may overflow.
    pub fn truncate(mut self, truncate: bool) -> Self {
        self.truncate = truncate;
        self
    }

    /// Displays a rotating loading spinner in place of the `start_icon`.
    ///
    /// When `loading` is `true`, any `start_icon` is ignored. and a rotating
    pub fn loading(mut self, loading: bool) -> Self {
        self.loading = loading;
        self
    }

    /// Convenience for a Tailwind-style solid "primary" button: solid
    /// `palette::primary(600)` background with white text.
    ///
    /// Equivalent to `.style(ButtonStyle::Tinted(TintColor::Accent))`.
    pub fn primary(mut self) -> Self {
        self.base = self.base.style(ButtonStyle::Tinted(TintColor::Accent));
        self.label_color = Some(Color::Custom(gpui::white()));
        self
    }

    /// Convenience for a Tailwind-style solid "danger" button: solid
    /// `palette::danger(600)` background with white text.
    ///
    /// Equivalent to `.style(ButtonStyle::Tinted(TintColor::Error))`.
    pub fn danger(mut self) -> Self {
        self.base = self.base.style(ButtonStyle::Tinted(TintColor::Error));
        self.label_color = Some(Color::Custom(gpui::white()));
        self
    }

    /// Convenience for a Tailwind-style "soft" button: faint
    /// `palette::primary(50)` background with `palette::primary(700)` text.
    ///
    /// Implemented as an additive background override on top of the
    /// `Tinted(Accent)` style, so it does not require a new `ButtonStyle`
    /// variant.
    pub fn soft(mut self) -> Self {
        self.base = self
            .base
            .style(ButtonStyle::Tinted(TintColor::Accent))
            .background_override(palette::primary(50));
        self.label_color = Some(Color::Custom(palette::primary(700)));
        self
    }

    /// shadcn/ui variant alias (recommended vocabulary).
    ///
    /// Maps to existing [`ButtonStyle`] / convenience builders without
    /// renaming legacy `.primary()` / `.danger()` / `.soft()` call sites.
    /// For link-style buttons use [`ButtonLink`] instead.
    pub fn variant(mut self, variant: ButtonVariant) -> Self {
        match variant {
            ButtonVariant::Default => self.primary(),
            ButtonVariant::Destructive => self.danger(),
            ButtonVariant::Outline => {
                self.base = self.base.style(ButtonStyle::Outlined);
                self.label_color = None;
                self
            }
            ButtonVariant::Secondary => {
                self.base = self.base.style(ButtonStyle::Filled);
                self.label_color = None;
                self
            }
            ButtonVariant::Ghost => {
                self.base = self.base.style(ButtonStyle::Transparent);
                self.label_color = None;
                self
            }
        }
    }

    /// shadcn/ui size alias. Icon-only sizing uses [`IconButton`], not this API.
    pub fn shadcn_size(mut self, size: ButtonSizeAlias) -> Self {
        let mapped = match size {
            ButtonSizeAlias::Sm => ButtonSize::Compact,
            ButtonSizeAlias::Default => ButtonSize::Default,
            ButtonSizeAlias::Lg => ButtonSize::Medium,
            ButtonSizeAlias::Icon => ButtonSize::None,
        };
        self.base = self.base.size(mapped);
        self
    }
}

/// shadcn/ui button variants (additive alias over [`ButtonStyle`]).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ButtonVariant {
    #[default]
    Default,
    Destructive,
    Outline,
    Secondary,
    Ghost,
}

/// shadcn/ui button sizes (additive alias over [`ButtonSize`]).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ButtonSizeAlias {
    Sm,
    #[default]
    Default,
    Lg,
    Icon,
}

impl Toggleable for Button {
    /// Sets the selected state of the button.
    ///
    /// # Examples
    ///
    /// Create a toggleable button that changes appearance when selected:
    ///
    /// ```
    /// use ui::prelude::*;
    /// use ui::TintColor;
    ///
    /// let selected = true;
    ///
    /// Button::new("toggle_button", "Toggle Me")
    ///     .start_icon(Icon::new(IconName::Check))
    ///     .toggle_state(selected)
    ///     .selected_style(ButtonStyle::Tinted(TintColor::Accent))
    ///     .on_click(|event, window, cx| {
    ///         // Toggle the selected state
    ///     });
    /// ```
    fn toggle_state(mut self, selected: bool) -> Self {
        self.base = self.base.toggle_state(selected);
        self
    }
}

impl SelectableButton for Button {
    /// Sets the style for the button in a selected state.
    ///
    /// # Examples
    ///
    /// Customize the selected appearance of a button:
    ///
    /// ```
    /// use ui::prelude::*;
    /// use ui::TintColor;
    ///
    /// Button::new("styled_button", "Styled Button")
    ///     .toggle_state(true)
    ///     .selected_style(ButtonStyle::Tinted(TintColor::Accent));
    /// ```
    fn selected_style(mut self, style: ButtonStyle) -> Self {
        self.base = self.base.selected_style(style);
        self
    }
}

impl Disableable for Button {
    /// Disables the button, preventing interaction and changing its appearance.
    ///
    /// When disabled, the button's icon and label will use `Color::Disabled`.
    ///
    /// # Examples
    ///
    /// Create a disabled button:
    ///
    /// ```
    /// use ui::prelude::*;
    ///
    /// Button::new("disabled_button", "Can't Click Me")
    ///     .disabled(true);
    /// ```
    fn disabled(mut self, disabled: bool) -> Self {
        self.base = self.base.disabled(disabled);
        self
    }
}

impl Clickable for Button {
    fn on_click(
        mut self,
        handler: impl Fn(&gpui::ClickEvent, &mut Window, &mut App) + 'static,
    ) -> Self {
        self.base = self.base.on_click(handler);
        self
    }

    fn cursor_style(mut self, cursor_style: gpui::CursorStyle) -> Self {
        self.base = self.base.cursor_style(cursor_style);
        self
    }
}

impl FixedWidth for Button {
    /// Sets a fixed width for the button.
    ///
    /// # Examples
    ///
    /// Create a button with a fixed width of 100 pixels:
    ///
    /// ```
    /// use ui::prelude::*;
    ///
    /// Button::new("fixed_width_button", "Fixed Width")
    ///     .width(px(100.0));
    /// ```
    fn width(mut self, width: impl Into<DefiniteLength>) -> Self {
        self.base = self.base.width(width);
        self
    }

    /// Makes the button take up the full width of its container.
    ///
    /// # Examples
    ///
    /// Create a button that takes up the full width of its container:
    ///
    /// ```
    /// use ui::prelude::*;
    ///
    /// Button::new("full_width_button", "Full Width")
    ///     .full_width();
    /// ```
    fn full_width(mut self) -> Self {
        self.base = self.base.full_width();
        self
    }
}

impl ButtonCommon for Button {
    fn id(&self) -> &ElementId {
        self.base.id()
    }

    /// Sets the visual style of the button.
    fn style(mut self, style: ButtonStyle) -> Self {
        self.base = self.base.style(style);
        self
    }

    /// Sets the size of the button.
    fn size(mut self, size: ButtonSize) -> Self {
        self.base = self.base.size(size);
        self
    }

    /// Sets a tooltip that appears on hover.
    ///
    /// # Examples
    ///
    /// Add a tooltip to a button:
    ///
    /// ```
    /// use ui::{Tooltip, prelude::*};
    ///
    /// Button::new("tooltip_button", "Hover Me")
    ///     .tooltip(Tooltip::text("This is a tooltip"));
    /// ```
    fn tooltip(mut self, tooltip: impl Fn(&mut Window, &mut App) -> AnyView + 'static) -> Self {
        self.base = self.base.tooltip(tooltip);
        self
    }

    fn tab_index(mut self, tab_index: impl Into<isize>) -> Self {
        self.base = self.base.tab_index(tab_index);
        self
    }

    fn layer(mut self, elevation: ElevationIndex) -> Self {
        self.base = self.base.layer(elevation);
        self
    }

    fn track_focus(mut self, focus_handle: &gpui::FocusHandle) -> Self {
        self.base = self.base.track_focus(focus_handle);
        self
    }
}

impl RenderOnce for Button {
    #[allow(refining_impl_trait)]
    fn render(self, _window: &mut Window, cx: &mut App) -> ButtonLike {
        let is_disabled = self.base.disabled;
        let is_selected = self.base.selected;
        let button_style = self.base.style;

        let label = self
            .selected_label
            .filter(|_| is_selected)
            .unwrap_or(self.label);

        let label_color = if is_disabled {
            Color::Disabled
        } else if is_selected {
            self.selected_label_color.unwrap_or(Color::Selected)
        } else if let Some(color) = self.label_color {
            color
        } else if matches!(button_style, ButtonStyle::Tinted(_)) {
            // Solid Tinted backgrounds (primary/danger/etc.) need light text
            // for contrast — applies to every `.style(Tinted(..))` caller, not
            // just the `.primary()`/`.danger()` sugar.
            Color::Custom(gpui::white())
        } else {
            Color::default()
        };

        self.base.child(
            h_flex()
                .when(self.truncate, |this| this.min_w_0().overflow_hidden())
                .gap(DynamicSpacing::Base04.rems(cx))
                .when(self.loading, |this| {
                    this.child(
                        Icon::new(IconName::LoadCircle)
                            .size(IconSize::Small)
                            .color(Color::Muted)
                            .with_rotate_animation(2),
                    )
                })
                .when(!self.loading, |this| {
                    this.when_some(self.start_icon, |this, icon| {
                        this.child(if is_disabled {
                            icon.color(Color::Disabled)
                        } else if matches!(button_style, ButtonStyle::Tinted(_)) {
                            icon.color(Color::Custom(gpui::white()))
                        } else {
                            icon
                        })
                    })
                })
                .child(
                    h_flex()
                        .when(self.truncate, |this| this.min_w_0().overflow_hidden())
                        .when(
                            self.key_binding_position == KeybindingPosition::Start,
                            |this| this.flex_row_reverse(),
                        )
                        .gap(DynamicSpacing::Base06.rems(cx))
                        .justify_between()
                        .child(
                            Label::new(label)
                                .color(label_color)
                                .size(self.label_size.unwrap_or_default())
                                .when_some(self.alpha, |this, alpha| this.alpha(alpha))
                                .when(self.truncate, |this| this.truncate()),
                        )
                        .children(self.key_binding),
                )
                .when_some(self.end_icon, |this, icon| {
                    this.child(if is_disabled {
                        icon.color(Color::Disabled)
                    } else {
                        icon
                    })
                }),
        )
    }
}

impl Component for Button {
    fn scope() -> ComponentScope {
        ComponentScope::Input
    }

    fn sort_name() -> &'static str {
        "ButtonA"
    }

    fn description() -> Option<&'static str> {
        Some("A button triggers an event or action.")
    }

    fn preview(_window: &mut Window, _cx: &mut App) -> Option<AnyElement> {
        Some(
            v_flex()
                .gap_6()
                .children(vec![
                    example_group_with_title(
                        "Button Styles",
                        vec![
                            single_example(
                                "Default",
                                Button::new("default", "Default").into_any_element(),
                            ),
                            single_example(
                                "Filled",
                                Button::new("filled", "Filled")
                                    .style(ButtonStyle::Filled)
                                    .into_any_element(),
                            ),
                            single_example(
                                "Subtle",
                                Button::new("outline", "Subtle")
                                    .style(ButtonStyle::Subtle)
                                    .into_any_element(),
                            ),
                            single_example(
                                "Tinted",
                                Button::new("tinted_accent_style", "Accent")
                                    .style(ButtonStyle::Tinted(TintColor::Accent))
                                    .into_any_element(),
                            ),
                            single_example(
                                "Transparent",
                                Button::new("transparent", "Transparent")
                                    .style(ButtonStyle::Transparent)
                                    .into_any_element(),
                            ),
                        ],
                    ),
                    example_group_with_title(
                        "Primary / Danger / Soft",
                        vec![
                            single_example(
                                "Primary",
                                Button::new("primary", "Primary")
                                    .primary()
                                    .into_any_element(),
                            ),
                            single_example(
                                "Danger",
                                Button::new("danger", "Danger").danger().into_any_element(),
                            ),
                            single_example(
                                "Soft",
                                Button::new("soft", "Soft").soft().into_any_element(),
                            ),
                        ],
                    ),
                    example_group_with_title(
                        "Variant \u{d7} Size Matrix",
                        vec![
                            single_example(
                                "Large",
                                h_flex()
                                    .gap_2()
                                    .child(
                                        Button::new("matrix_primary_lg", "Primary")
                                            .primary()
                                            .size(ButtonSize::Large),
                                    )
                                    .child(
                                        Button::new("matrix_danger_lg", "Danger")
                                            .danger()
                                            .size(ButtonSize::Large),
                                    )
                                    .child(
                                        Button::new("matrix_soft_lg", "Soft")
                                            .soft()
                                            .size(ButtonSize::Large),
                                    )
                                    .into_any_element(),
                            ),
                            single_example(
                                "Medium",
                                h_flex()
                                    .gap_2()
                                    .child(
                                        Button::new("matrix_primary_md", "Primary")
                                            .primary()
                                            .size(ButtonSize::Medium),
                                    )
                                    .child(
                                        Button::new("matrix_danger_md", "Danger")
                                            .danger()
                                            .size(ButtonSize::Medium),
                                    )
                                    .child(
                                        Button::new("matrix_soft_md", "Soft")
                                            .soft()
                                            .size(ButtonSize::Medium),
                                    )
                                    .into_any_element(),
                            ),
                            single_example(
                                "Compact",
                                h_flex()
                                    .gap_2()
                                    .child(
                                        Button::new("matrix_primary_cp", "Primary")
                                            .primary()
                                            .size(ButtonSize::Compact),
                                    )
                                    .child(
                                        Button::new("matrix_danger_cp", "Danger")
                                            .danger()
                                            .size(ButtonSize::Compact),
                                    )
                                    .child(
                                        Button::new("matrix_soft_cp", "Soft")
                                            .soft()
                                            .size(ButtonSize::Compact),
                                    )
                                    .into_any_element(),
                            ),
                        ],
                    ),
                    example_group_with_title(
                        "Tint Styles",
                        vec![
                            single_example(
                                "Accent",
                                Button::new("tinted_accent", "Accent")
                                    .style(ButtonStyle::Tinted(TintColor::Accent))
                                    .into_any_element(),
                            ),
                            single_example(
                                "Error",
                                Button::new("tinted_negative", "Error")
                                    .style(ButtonStyle::Tinted(TintColor::Error))
                                    .into_any_element(),
                            ),
                            single_example(
                                "Warning",
                                Button::new("tinted_warning", "Warning")
                                    .style(ButtonStyle::Tinted(TintColor::Warning))
                                    .into_any_element(),
                            ),
                            single_example(
                                "Success",
                                Button::new("tinted_positive", "Success")
                                    .style(ButtonStyle::Tinted(TintColor::Success))
                                    .into_any_element(),
                            ),
                        ],
                    ),
                    example_group_with_title(
                        "Special States",
                        vec![
                            single_example(
                                "Default",
                                Button::new("default_state", "Default").into_any_element(),
                            ),
                            single_example(
                                "Disabled",
                                Button::new("disabled", "Disabled")
                                    .disabled(true)
                                    .into_any_element(),
                            ),
                            single_example(
                                "Selected",
                                Button::new("selected", "Selected")
                                    .toggle_state(true)
                                    .into_any_element(),
                            ),
                        ],
                    ),
                    example_group_with_title(
                        "Buttons with Icons",
                        vec![
                            single_example(
                                "Start Icon",
                                Button::new("icon_start", "Start Icon")
                                    .start_icon(Icon::new(IconName::Check))
                                    .into_any_element(),
                            ),
                            single_example(
                                "End Icon",
                                Button::new("icon_end", "End Icon")
                                    .end_icon(Icon::new(IconName::Check))
                                    .into_any_element(),
                            ),
                            single_example(
                                "Both Icons",
                                Button::new("both_icons", "Both Icons")
                                    .start_icon(Icon::new(IconName::Check))
                                    .end_icon(Icon::new(IconName::ChevronDown))
                                    .into_any_element(),
                            ),
                            single_example(
                                "Icon Color",
                                Button::new("icon_color", "Icon Color")
                                    .start_icon(Icon::new(IconName::Check).color(Color::Accent))
                                    .into_any_element(),
                            ),
                        ],
                    ),
                ])
                .into_any_element(),
        )
    }
}