Skip to main content

nightshade_api/web/base/
card.rs

1use leptos::prelude::*;
2
3/// A bordered content container. When `title` is non-empty it renders a header
4/// row above the `children`, which fill the card body.
5#[component]
6pub fn Card(
7    #[prop(into, optional)] title: String,
8    #[prop(into, optional)] class: String,
9    children: Children,
10) -> impl IntoView {
11    let header = (!title.is_empty())
12        .then(|| view! { <div class="nightshade-card-title">{title.clone()}</div> });
13    view! {
14        <div class=format!("nightshade-card {class}")>
15            {header}
16            <div class="nightshade-card-body">{children()}</div>
17        </div>
18    }
19}