patternfly_yew/components/form/
section.rs1use uuid::Uuid;
2use yew::prelude::*;
3
4#[derive(Clone, PartialEq, Properties)]
6pub struct FormSectionProperties {
7 pub title: Option<String>,
8 pub children: Html,
9}
10
11#[function_component(FormSection)]
13pub fn section(props: &FormSectionProperties) -> Html {
14 let id = use_state(|| match props.title.is_some() {
15 true => Some(Uuid::new_v4().to_string()),
16 false => None,
17 });
18
19 html! (
20 <section class="pf-v5-c-form__section" role="group" aria-labelledby={(*id).clone()}>
21
22 if let Some(title) = &props.title {
23 <div id={(*id).clone()} class="pf-v5-c-form__section-title" aria-hidden="true">
24 { title }
25 </div>
26 }
27
28 { props.children.clone() }
29 </section>
30 )
31}