dioxus_bootstrap_css/
card.rs1use dioxus::prelude::*;
2
3#[derive(Clone, PartialEq, Props)]
19pub struct CardProps {
20 #[props(default)]
22 pub header: Option<Element>,
23 #[props(default)]
25 pub body: Option<Element>,
26 #[props(default)]
28 pub footer: Option<Element>,
29 #[props(default)]
31 pub class: String,
32 #[props(default)]
34 pub body_class: String,
35 #[props(default)]
37 pub children: Element,
38}
39
40#[component]
41pub fn Card(props: CardProps) -> Element {
42 let full_class = if props.class.is_empty() {
43 "card".to_string()
44 } else {
45 format!("card {}", props.class)
46 };
47
48 let body_class = if props.body_class.is_empty() {
49 "card-body".to_string()
50 } else {
51 format!("card-body {}", props.body_class)
52 };
53
54 rsx! {
55 div { class: "{full_class}",
56 if let Some(header) = props.header {
57 div { class: "card-header", {header} }
58 }
59 if let Some(body) = props.body {
60 div { class: "{body_class}", {body} }
61 }
62 {props.children}
63 if let Some(footer) = props.footer {
64 div { class: "card-footer", {footer} }
65 }
66 }
67 }
68}