nova_forms/components/
icon_button.rs

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
use leptos::*;

use crate::Icon;

/// A button that only contains an icon.
#[component]
pub fn IconButton(
    #[prop(optional, into)] button_type: Option<String>,
    #[prop(into)] label: TextProp,
    #[prop(into)] icon: String,
    #[prop(optional, into)] id: Option<String>,
    #[prop(optional, into)] form: Option<String>,
    #[prop(optional, into)] disabled: Option<MaybeSignal<bool>>,
) -> impl IntoView {
    view! {
        <button
            class="overlay icon-button button"
            disabled=move || disabled.map(|s| s.get()).unwrap_or_default()
            type=button_type.unwrap_or("button".to_owned())
            form=form
            id=id.unwrap_or_default()
        >
            <Icon label=label icon=icon />
        </button>
    }
}