pub fn button<'a, Message, Renderer>(
label: impl IntoFragment<'a>,
variant: ButtonVariant,
) -> Button<'a, Message, Renderer>Examples found in repository?
examples/showcase/pages/feedback.rs (line 55)
51fn snackbars() -> material::Element<'static, Message> {
52 use material::widget::button::{self, ButtonVariant};
53
54 page::row([button::action(
55 button::button("Show snackbar", ButtonVariant::Filled),
56 Message::ShowSnackbar,
57 )])
58 .into()
59}
60
61fn dialogs() -> material::Element<'static, Message> {
62 use material::widget::button::{self, ButtonVariant};
63
64 page::row([button::action(
65 button::button("Open sign-in dialog", ButtonVariant::Filled),
66 Message::DialogOpened,
67 )])
68 .into()
69}More examples
examples/showcase/pages/controls.rs (line 23)
18fn counter_controls(state: &Showcase) -> material::Element<'_, Message> {
19 use material::widget::button::{self, ButtonVariant};
20
21 page::row([
22 button::action(
23 button::button("Minus", ButtonVariant::Outlined),
24 Message::Decrement,
25 ),
26 material::text::headline_medium(state.count.to_string()).into(),
27 button::action(
28 button::button("Plus", ButtonVariant::Filled),
29 Message::Increment,
30 ),
31 ])
32 .into()
33}
34
35fn action_buttons(state: &Showcase) -> material::Element<'_, Message> {
36 use material::widget::button::{self, ButtonVariant};
37
38 page::row(button::enabled_actions(
39 state.enabled,
40 Message::Increment,
41 [
42 button::button("Filled", ButtonVariant::Filled),
43 button::button("Tonal", ButtonVariant::FilledTonal),
44 button::button("Text", ButtonVariant::Text),
45 ],
46 ))
47 .into()
48}examples/showcase/pages/structure.rs (line 235)
224fn sheet_content(
225 title: &'static str,
226 supporting: &'static str,
227) -> material::Element<'static, Message> {
228 use material::widget::button::{self, ButtonVariant};
229
230 material::widget::sheet::bottom_content(page::compact_stack([
231 material::text::title_medium(title).into(),
232 material::text::body_medium(supporting).into(),
233 page::row([
234 button::action(
235 button::button("Dismiss", ButtonVariant::Text),
236 Message::Decrement,
237 ),
238 button::action(
239 button::button("Apply", ButtonVariant::Filled),
240 Message::Increment,
241 ),
242 ])
243 .into(),
244 ]))
245 .into()
246}
247
248fn side_sheet_content(
249 title: &'static str,
250 supporting: &'static str,
251) -> material::Element<'static, Message> {
252 use material::widget::button::{self, ButtonVariant, IconButtonVariant};
253
254 let header = Row::new()
255 .push(material::text::title_medium(title).width(Length::Fill))
256 .push(button::action(
257 button::icon_button("close", IconButtonVariant::Standard),
258 Message::Decrement,
259 ))
260 .align_y(alignment::Vertical::Center);
261 let actions = Row::new()
262 .push(Space::new().width(Length::Fill))
263 .push(button::action(
264 button::button("Apply", ButtonVariant::Filled),
265 Message::Increment,
266 ))
267 .spacing(page::ROW_SPACING)
268 .align_y(alignment::Vertical::Center);
269
270 material::widget::sheet::side_content(
271 Column::new()
272 .push(header)
273 .push(material::text::body_medium(supporting))
274 .push(Space::new().height(Length::Fill))
275 .push(actions)
276 .spacing(page::COMPACT_STACK_SPACING)
277 .height(Length::Fill),
278 )
279 .into()
280}examples/quickstart/app.rs (line 78)
72 fn view(self, app: &App) -> material::Element<'_, Message> {
73 match self {
74 Self::Home => page::surface(
75 page::header("Home", "A small Material app"),
76 column![
77 material::text::headline_medium(app.count.to_string()),
78 button::button("Increment", button::ButtonVariant::Filled)
79 .on_press(Message::Increment),
80 button::button("Decrement", button::ButtonVariant::Outlined)
81 .on_press(Message::Decrement),
82 ]
83 .spacing(12),
84 )
85 .into(),
86 Self::Settings => page::surface(
87 page::header("Settings", "Pages are enum variants"),
88 material::text::body_large("Use the menu button in the rail"),
89 )
90 .into(),
91 }
92 }