nova_forms/components/
button.rs1use leptos::*;
2
3use crate::Icon;
4
5#[component]
7pub fn Button(
8 #[prop(optional, into)] button_type: Option<String>,
9 #[prop(into)] label: TextProp,
10 #[prop(into, optional)] icon: Option<String>,
11 #[prop(optional, into)] id: Option<String>,
12 #[prop(optional, into)] form: Option<String>,
13 #[prop(optional, into)] disabled: Option<MaybeSignal<bool>>,
14) -> impl IntoView {
15 view! {
16 <button
17 class="overlay icon-button button"
18 disabled=move || disabled.map(|s| s.get()).unwrap_or_default()
19 type=button_type.unwrap_or("button".to_owned())
20 form=form
21 id=id.unwrap_or_default()
22 >
23 {
24 if let Some(icon) = icon {
25 view! { <Icon label=label icon=icon /> }.into_view()
26 } else {
27 view! { <span>{label}</span> }.into_view()
28 }
29 }
30 </button>
31 }
32}
33
34#[component]
36pub fn ButtonGroup(
37 children: Children
38) -> impl IntoView {
39 view! {
40 <div class="button-group">
41 {children()}
42 </div>
43 }
44}