dioxus_tw_components/components/organisms/form/radio/
props.rs

1use crate::attributes::*;
2use dioxus::prelude::*;
3use dioxus_tw_components_macro::UiComp;
4
5#[derive(Default, Clone, PartialEq, Props, UiComp)]
6pub struct RadioProps {
7    #[props(extends = input, extends = GlobalAttributes)]
8    attributes: Vec<Attribute>,
9    #[props(optional, default = false)]
10    checked: bool,
11
12    #[props(optional)]
13    oninput: EventHandler<FormEvent>,
14
15    #[props(optional, default)]
16    pub color: ReadOnlySignal<Color>,
17    #[props(optional, default)]
18    pub size: ReadOnlySignal<Size>,
19}
20
21#[component]
22pub fn Radio(mut props: RadioProps) -> Element {
23    props.update_class_attribute();
24
25    let oninput = move |event| props.oninput.call(event);
26
27    rsx! {
28        input {
29            r#type: "radio",
30            checked: props.checked,
31            oninput,
32            ..props.attributes,
33        }
34    }
35}