Framework Integration

Quick start

Leptos
Vanilla JS
Dioxus
Yew

rs-grid-leptos provides a <GridCanvas> component for Leptos CSR applications. It wraps the WASM runtime, canvas lifecycle, event handling, and theming in a single component.

<GridCanvas
    rows=1_000_000_u64
    cols=50_usize
    row_height=32.0_f64     // optional, default 32px
    header_height=40.0_f64  // optional, default 40px
/>

Component API

Leptos
Vanilla JS
Dioxus
Yew

Props

PropTypeDefaultDescription
rowsu64requiredTotal number of data rows
colsusizerequiredTotal number of columns
row_heightf6432.0Height of each data row in CSS pixels
header_heightf6440.0Height of the column header row

Theming

Leptos
Vanilla JS
Dioxus
Yew

The component reads its color palette from CSS custom properties at mount time via rs-grid-web::theme_from_css_vars. Define the variables in your stylesheet:

rs-grid-theme.css
:root {
  --rs-grid-bg:               #0d1117;
  --rs-grid-header-bg:        #161b22;
  --rs-grid-border:           #30363d;
  --rs-grid-text:             #c9d1d9;
  --rs-grid-selection-bg:     rgba(56, 139, 253, 0.15);
  --rs-grid-selection-border: #388bfd;
}

Include the file via your Trunk.toml or a <link> tag in index.html.

Events

Leptos
Vanilla JS
Dioxus
Yew

The Leptos component attaches pointer and wheel listeners to the canvas:

Browser eventGridCommand
pointerdownSelectCell / SelectRow / SelectColumn
pointerdown + ShiftExtendSelection
wheelScrollTo
ResizeObserverResize

Events are translated to GridCommand values and applied on the next animation frame. You do not need to manage the event loop manually.

Full example

Leptos
Vanilla JS
Dioxus
Yew
src/main.rs
use leptos::*;
use rs_grid_leptos::GridCanvas;

#[component]
pub fn App() -> impl IntoView {
    view! {
        <main style="width: 100vw; height: 100vh;">
            <GridCanvas
                rows=500_000_u64
                cols=20_usize
            />
        </main>
    }
}

fn main() {
    leptos::mount_to_body(App);
}
Tip

The reference theme file is at examples/basic-leptos/rs-grid-theme.css. Copy it as a starting point for your own theme.

Limitations

Leptos
Vanilla JS
Dioxus
Yew
  • rs-grid-leptos is CSR-only — SSR is not supported
  • The component expects to be rendered in a browser environment with <canvas> support