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
use Icon as IconData;
use *;
use BaseFloatingButton;
use component_doc;
use inject_style;
use crateIcon;
use floating_button_styles;
use FloatingButtonConfig;
/// Elevated floating control for the single most important action on a screen.
///
/// Rounded-square icon-only by default with elevated surface styling. Pin to a viewport corner with [`FloatingButtonConfig::fixed`]. Set `config.variant` to [`FloatingButtonVariant::Circular`] for a full circle, or [`FloatingButtonVariant::Extended`] for icon plus label with the same rounded-square corners.
///
/// # When to use
///
/// - One primary action that should stay visible above page content - Back-to-top and similar floating affordances built on the same base
///
/// # Usage
///
/// 1. Provide an icon or extended label via `children`. 2. Set `aria_label` for icon-only buttons. 3. Use `config.fixed(right, bottom)` when the button should float on the viewport.
///
/// # Best Practices
///
/// ## Do's
///
/// * Use one floating primary action per screen for the most important command * Provide a descriptive `aria_label` when no visible text is shown
///
/// ## Don'ts
///
/// * Do not use floating buttons for secondary or destructive actions without clear labeling
///
/// # Examples
///
/// ## Default
/// Rounded-square icon-only floating button with primary emphasis.
/// <!-- preview -->
/// ```rust
/// use crate::FloatingButton;
/// view! {
/// <div data-testid="floating-button-preview">
/// <FloatingButton aria_label="Add".to_string() icon=icondata::AiPlusOutlined />
/// </div>
/// }
/// ```
///
/// ## Extended
/// Extended variant includes a visible text label beside the icon.
/// <!-- preview -->
/// ```rust
/// use crate::{FloatingButton, FloatingButtonConfig, FloatingButtonVariant};
/// use leptos::prelude::*;
/// view! {
/// <div data-testid="floating-button-extended">
/// <FloatingButton
/// config=FloatingButtonConfig { variant: FloatingButtonVariant::Extended.into(), ..Default::default() }
/// aria_label="Navigate".to_string()
/// icon=icondata::AiCompassOutlined
/// >
/// "Navigate"
/// </FloatingButton>
/// </div>
/// }
/// ```
///
/// ## Size
/// Compare small, medium, and large icon-only sizes.
/// <!-- preview -->
/// ```rust
/// use crate::{FloatingButton, FloatingButtonConfig, FloatingButtonSize, Stack, StackConfig, FlexGap};
/// use leptos::prelude::*;
/// view! {
/// <div data-testid="floating-button-size">
/// <Stack config=StackConfig::horizontal(FlexGap::Medium)>
/// <FloatingButton
/// config=FloatingButtonConfig { size: FloatingButtonSize::Small.into(), ..Default::default() }
/// aria_label="Add small".to_string()
/// icon=icondata::AiPlusOutlined
/// />
/// <FloatingButton
/// config=FloatingButtonConfig { size: FloatingButtonSize::Medium.into(), ..Default::default() }
/// aria_label="Add medium".to_string()
/// icon=icondata::AiPlusOutlined
/// />
/// <FloatingButton aria_label="Add large".to_string() icon=icondata::AiPlusOutlined />
/// </Stack>
/// </div>
/// }
/// ```
///
/// ## Secondary color
/// Secondary treatment for less prominent floating actions.
/// <!-- preview -->
/// ```rust
/// use crate::{FloatingButton, FloatingButtonColor, FloatingButtonConfig};
/// use leptos::prelude::*;
/// view! {
/// <div data-testid="floating-button-secondary">
/// <FloatingButton
/// config=FloatingButtonConfig { color: FloatingButtonColor::Secondary.into(), ..Default::default() }
/// aria_label="Edit".to_string()
/// icon=icondata::AiEditOutlined
/// />
/// </div>
/// }
/// ```
]
config: FloatingButtonConfig,
/// Accessible name for icon-only buttons.
aria_label: String,
/// Optional leading icon from the icondata catalog.
icon: ,
/// Optional CSS class on the button element.
class: ,
/// When true, the button does not respond to clicks.
disabled: ,
/// Optional visible label for the extended variant.
children: ,
)