Crates.io | leptos_declarative |
lib.rs | leptos_declarative |
version | 0.3.0 |
source | src |
created_at | 2023-03-27 15:11:36.309793 |
updated_at | 2023-06-30 15:55:37.911614 |
description | Declarative components for leptos. |
homepage | https://github.com/jquesada2016/leptos-declarative |
repository | https://github.com/jquesada2016/leptos-declarative |
max_upload_size | |
id | 822234 |
size | 18,331 |
Declarative components to represent control-flow and other useful
constructs in the [leptos
] web framework not directly
provided by default.
This crate provides 2 main components
If
Portal
For more usage examples, please refer to the respective components' documentation, but here's a taste.
use leptos::*;
use leptos_declarative::prelude::*;
let (a, _) = create_signal(cx, true);
let (b, _) = create_signal(cx, false);
view! { cx,
<If signal=a>
<Then>"A is true!"</Then>
<ElseIf signal=b>"B is true!"</ElseIf>
<Else>"Both A and B are false!"</Else>
</If>
};
use leptos::*;
use leptos_declarative::prelude::*;
struct PortalId;
view! { cx,
<PortalProvider>
<div>
<h1>"Portal goes here!"</h1>
<PortalOutput id=PortalId />
</div>
<Portal id=PortalId>
<p>"I went through the portal!"</p>
</Portal>
</PortalProvider>
};