patternfly_yew/components/card/
expandable_content.rs

1use yew::prelude::*;
2
3use super::CardContext;
4
5#[derive(Debug, Clone, PartialEq, Properties)]
6pub struct CardExpandableContentProperties {
7    /// Content rendered inside the expanded section.
8    #[prop_or_default]
9    pub children: Html,
10    /// Additional classes added to the expanded section.
11    #[prop_or_default]
12    pub class: Classes,
13}
14
15#[function_component(CardExpandableContent)]
16pub fn expandable_content(props: &CardExpandableContentProperties) -> Html {
17    let CardContext { expanded, .. } = use_context().expect("Could not get card context");
18    if !expanded {
19        return html!();
20    }
21    let class = classes!(props.class.clone(), "pf-v5-c-card__expandable-content");
22    html! {
23        <div {class}>
24            {props.children.clone()}
25        </div>
26    }
27}