leptos_use/docs/
boolean_display.rs1use leptos::prelude::*;
2
3#[component]
4pub fn BooleanDisplay(
5 #[prop(into)] value: Signal<bool>,
6 #[prop(optional, into)] class: String,
7 #[prop(default = "true")] true_str: &'static str,
8 #[prop(default = "false")] false_str: &'static str,
9) -> impl IntoView {
10 let true_class = "text-green-600 dark:text-green-500";
11 let false_class = "text-[--brand-color]";
12
13 let class = move || {
14 format!(
15 "{} {} opacity-75",
16 if value.get() { true_class } else { false_class },
17 class
18 )
19 };
20
21 view! { <span class=class>{move || if value.get() { true_str } else { false_str }}</span> }
22}