pub fn Show<W>(props: ShowProps<W>) -> impl IntoView
Expand description
A component that will show its children when the when
condition is true
,
and show the fallback when it is false
, without rerendering every time
the condition changes.
The fallback prop is optional and defaults to rendering nothing.
let (value, set_value) = create_signal(0);
view! {
<Show
when=move || value.get() < 5
fallback=|| view! { "Big number!" }
>
"Small number!"
</Show>
}
§Required Props
- children:
ChildrenFn
- The children will be shown whenever the condition in the
when
closure returnstrue
.
- The children will be shown whenever the condition in the
- when: [
W
]- A closure that returns a bool that determines whether this thing runs
§Optional Props
- fallback:
impl Into<ViewFn>
- A closure that returns what gets rendered if the when statement is false. By default this is the empty view.