#yew-component #proc-macro #front-end #webasm #yew-web #web

macro yew-autoprops

proc-macro to automatically derive Properties structs from args for Yew components

6 releases (3 breaking)

0.4.1 Dec 4, 2023
0.4.0 Dec 4, 2023
0.3.0 Oct 30, 2023
0.2.2 May 22, 2023
0.1.0 May 21, 2023

#843 in WebAssembly

Download history 74/week @ 2024-09-18 160/week @ 2024-09-25 85/week @ 2024-10-02 159/week @ 2024-10-09 638/week @ 2024-10-16 738/week @ 2024-10-23 249/week @ 2024-10-30 168/week @ 2024-11-06 185/week @ 2024-11-13 362/week @ 2024-11-20 272/week @ 2024-11-27 472/week @ 2024-12-04 503/week @ 2024-12-11 196/week @ 2024-12-18 440/week @ 2024-12-25 395/week @ 2025-01-01

1,576 downloads per month

MIT/Apache

13KB
245 lines

yew-autoprops

Crate Info API Docs

proc-macro to automatically derive Properties structs from args for Yew components

No more extra one-off Props structs!

Examples

use yew_autoprops::autoprops;
use yew::prelude::*;

#[autoprops]
#[function_component]
fn CoolComponent(#[prop_or_default] hidden: bool, smth: &AttrValue) -> Html {
    html! {
        <div class={classes!(hidden.then_some("hidden"))}>
            <p>{ smth }</p>
        </div>
    }
}
use yew_autoprops::autoprops;
use yew::prelude::*;

#[autoprops(CoolComponentProps)]
#[function_component(CoolComponent)]
fn cool_component(#[prop_or_default] hidden: bool, smth: &AttrValue) -> Html {
    html! {
        <div class={classes!(hidden.then_some("hidden"))}>
            <p>{ smth }</p>
        </div>
    }
}

Dependencies

~200–580KB
~14K SLoC