htmx_components/server/
card.rs1use rscx::{component, html, props};
2
3#[props]
4pub struct CardProps {
5 children: String,
6
7 #[builder(default = false)]
8 padded: bool,
9
10 #[builder(setter(into), default)]
11 class: String,
12}
13
14#[component]
15pub fn Card(props: CardProps) -> String {
16 html! {
17 <div class=format!("overflow-hidden shadow ring-1 ring-black ring-opacity-5 sm:rounded-lg {}", props.class).trim()>
18 <CardContent padded=props.padded>
19 {props.children}
20 </CardContent>
21 </div>
22 }
23}
24
25#[props]
26pub struct CardContentProps {
27 children: String,
28
29 #[builder(default = false)]
30 padded: bool,
31}
32
33#[component]
34pub fn CardContent(props: CardContentProps) -> String {
35 {
36 match props.padded {
37 true => html! {
38 <div class="px-4 py-5 sm:p-6">
39 {props.children}
40 </div>
41 },
42 false => props.children,
43 }
44 }
45}
46
47#[props]
48pub struct CardFooterProps {
49 children: String,
50}
51
52#[component]
53pub fn CardFooter(props: CardFooterProps) -> String {
54 html! {
55 <div class="bg-gray-50 px-4 py-3 text-right sm:px-6">
56 {props.children}
57 </div>
58 }
59}