feat: Checkbox children can be empty

This commit is contained in:
luoxiao 2024-01-29 17:31:20 +08:00 committed by luoxiaozero
parent b44ba4f143
commit 40e0e51444
2 changed files with 5 additions and 2 deletions

View file

@ -5,6 +5,7 @@ let value = create_rw_signal(false);
view! { view! {
<Checkbox value>"Click"</Checkbox> <Checkbox value>"Click"</Checkbox>
<Checkbox />
} }
``` ```

View file

@ -16,7 +16,7 @@ use leptos::*;
pub fn Checkbox( pub fn Checkbox(
#[prop(optional, into)] value: Model<bool>, #[prop(optional, into)] value: Model<bool>,
#[prop(optional, into)] class: MaybeSignal<String>, #[prop(optional, into)] class: MaybeSignal<String>,
children: Children, #[prop(optional)] children: Option<Children>,
) -> impl IntoView { ) -> impl IntoView {
let theme = use_theme(Theme::light); let theme = use_theme(Theme::light);
mount_style("checkbox", include_str!("./checkbox.css")); mount_style("checkbox", include_str!("./checkbox.css"));
@ -50,7 +50,9 @@ pub fn Checkbox(
</Then> </Then>
</If> </If>
</div> </div>
<OptionComp value=children let:children>
<div class="thaw-checkbox__label">{children()}</div> <div class="thaw-checkbox__label">{children()}</div>
</OptionComp>
</div> </div>
} }
} }