This is unreleased documentation for Yew Next version.
For up-to-date documentation, see the latest version on docs.rs.
yew::html

Type Alias Children

source
pub type Children = ChildrenRenderer<Html>;
Expand description

A type used for accepting children elements in Component::Properties.

§Example

model.rs

In this example, the Wrapper component is used to wrap other elements.

html! {
    <Wrapper>
        <h4>{ "Hi" }</h4>
        <div>{ "Hello" }</div>
    </Wrapper>
}

wrapper.rs

The Wrapper component must define a children property in order to wrap other elements. The children property can be used to render the wrapped elements.

#[derive(Clone, Properties, PartialEq)]
struct WrapperProps {
    children: Children,
}

impl Component for Wrapper {
    // ...
    fn view(&self, ctx: &Context<Self>) -> Html {
        html! {
            <div id="container">
                { ctx.props().children.clone() }
            </div>
        }
    }
}

Aliased Type§

struct Children { /* private fields */ }