Crates.io | leptos-resize |
lib.rs | leptos-resize |
version | 0.2.0 |
created_at | 2025-01-03 00:33:41.185074+00 |
updated_at | 2025-01-06 21:00:34.070416+00 |
description | Simple user-resizable split view for Leptos |
homepage | |
repository | https://github.com/zortax/leptos-resize |
max_upload_size | |
id | 1502016 |
size | 60,331 |
This crate provides a simple user-resizable split container for the Leptos web framework. Horizontal and vertical splits are both supported.
#[component]
fn MyComponent() -> impl IntoView {
view! {
<ResizableSplit>
<div>"First"</div>
<div>"Second"</div>
</ResizableSplit>
}
}
(See examples
directory for a full CSR example)
Crate version | Compatible Leptos version |
---|---|
0.1 - 0.2 | 0.7 |
RwSignal
The split direction can be changed by setting the direction
property.
#[component]
fn MyComponent() -> impl IntoView {
view! {
// split the container horizontally
<ResizableSplit direction=SplitDirection::Column>
<div>"First"</div>
<div>"Second"</div>
</ResizableSplit>
}
}
The size percentages can be bound to a RwSignal
by setting the percentages
property. The RwSignal
should contain a Vec
with one element less than the
amount of children you pass. The last percentage will always be calculated.
The values sum should be less than 100
.
#[component]
fn MyComponent() -> impl IntoView {
// the last childs size will be calculated (in this case 40.)
let percentages = RwSignal::new(vec![20., 40.]);
view! {
<ResizableSplit percentages>
<div>"First"</div>
<div>"Second"</div>
<div>"Third"</div>
</ResizableSplit>
}
}
The <ResizableSplit>
container can also be nested to create more complex
resizable layouts.
#[component]
fn MyComponent() -> impl IntoView {
view! {
<ResizableSplit>
<div>"First"</div>
<ResizableSplit direction=SplitDirection::Column>
<div>"Second"</div>
<div>"Third"</div>
</ResizableSplit>
</ResizableSplit>
}
}