| Crates.io | leptos-shadcn-ui-wasm |
| lib.rs | leptos-shadcn-ui-wasm |
| version | 0.2.1 |
| created_at | 2025-09-21 09:14:51.077834+00 |
| updated_at | 2025-09-21 10:00:01.835517+00 |
| description | 🚀 WASM-optimized ShadCN UI components for Leptos 0.8+ with minimal dependencies. 50+ components, 70% fewer deps, feature flags for optimal bundle size. Perfect for WebAssembly applications! |
| homepage | https://github.com/cloud-shuttle/leptos-shadcn-ui |
| repository | https://github.com/cloud-shuttle/leptos-shadcn-ui |
| max_upload_size | |
| id | 1848636 |
| size | 116,816 |
🚀 A WASM-optimized version of ShadCN UI components for Leptos 0.8+ with minimal dependencies.
This package is specifically designed for WebAssembly environments and excludes dependencies that are not WASM-compatible, providing a clean, fast, and lightweight solution for web applications.
Add this to your Cargo.toml:
[dependencies]
leptos-shadcn-ui-wasm = "0.1"
use leptos::prelude::*;
use leptos_shadcn_ui_wasm::prelude::*;
#[component]
pub fn App() -> impl IntoView {
view! {
<div class="p-4">
<Button>"Click me"</Button>
<Input placeholder="Enter text..." />
<Card>
<CardHeader>
<CardTitle>"Hello WASM!"</CardTitle>
</CardHeader>
<CardContent>
<p>"This is a WASM-optimized component."</p>
</CardContent>
</Card>
</div>
}
}
Each component supports:
Control which components to include in your bundle:
[dependencies]
leptos-shadcn-ui-wasm = { version = "0.1", default-features = false, features = ["button", "input", "card"] }
button - Button componentinput - Input componentcard - Card componentslabel - Label componentbadge - Badge componentavatar - Avatar componentsseparator - Separator componentskeleton - Skeleton componentalert - Alert componentsalert-dialog - Alert dialog componentsall-components - All components (default)The package includes WASM-specific utilities:
use leptos_shadcn_ui_wasm::{wasm_utils, bundle_utils};
// Initialize WASM-specific features
wasm_utils::init_wasm();
// Get bundle information
let bundle_info = bundle_utils::get_bundle_info();
println!("Bundle: {}", bundle_info);
// Log to browser console
wasm_utils::log("Hello from WASM!");
// Get current timestamp
let timestamp = wasm_utils::now();
This package is optimized for minimal bundle size:
mio, tokio, proptest, etc.| Package | Bundle Size | Dependencies |
|---|---|---|
leptos-shadcn-ui |
~2.5MB | 150+ deps |
leptos-shadcn-ui-wasm |
~800KB | 25 deps |
# Build the WASM package
cargo build --target wasm32-unknown-unknown -p leptos-shadcn-ui-wasm
# Build with specific features
cargo build --target wasm32-unknown-unknown -p leptos-shadcn-ui-wasm --no-default-features --features "button,input"
# Run WASM tests
cargo test --target wasm32-unknown-unknown -p leptos-shadcn-ui-wasm
# Run with wasm-bindgen-test
wasm-pack test --headless --firefox
Perfect for:
If you're migrating from the main leptos-shadcn-ui package:
Update Dependencies:
# Before
leptos-shadcn-ui = "0.9"
# After
leptos-shadcn-ui-wasm = "0.1"
Update Imports:
// Before
use leptos_shadcn_ui::prelude::*;
// After
use leptos_shadcn_ui_wasm::prelude::*;
Enable Features:
leptos-shadcn-ui-wasm = { version = "0.1", features = ["button", "input", "card"] }
Check out the live demo at wasm-demo/ to see all components in action!
cd wasm-demo
wasm-pack build --target web
python -m http.server 8000
# Open http://localhost:8000
#[component]
fn ContactForm() -> impl IntoView {
let (name, set_name) = signal(String::new());
let (email, set_email) = signal(String::new());
view! {
<Card class="max-w-md mx-auto">
<CardHeader>
<CardTitle>"Contact Us"</CardTitle>
</CardHeader>
<CardContent class="space-y-4">
<div>
<Label>"Name"</Label>
<Input
value=name
on:input=move |ev| set_name.set(event_target_value(&ev))
placeholder="Your name"
/>
</div>
<div>
<Label>"Email"</Label>
<Input
value=email
on:input=move |ev| set_email.set(event_target_value(&ev))
placeholder="your@email.com"
/>
</div>
<Button class="w-full">"Submit"</Button>
</CardContent>
</Card>
}
}
#[component]
fn Dashboard() -> impl IntoView {
let (count, set_count) = signal(0);
view! {
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<Card>
<CardHeader>
<CardTitle>"Counter"</CardTitle>
</CardHeader>
<CardContent>
<div class="text-2xl font-bold">{count}</div>
<Button on:click=move |_| set_count.update(|c| *c += 1)>
"Increment"
</Button>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>"Status"</CardTitle>
</CardHeader>
<CardContent>
<Badge class="bg-green-100 text-green-800">"Online"</Badge>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>"User"</CardTitle>
</CardHeader>
<CardContent>
<Avatar>
<AvatarImage src="/avatar.jpg" />
<AvatarFallback>"JD"</AvatarFallback>
</Avatar>
</CardContent>
</Card>
</div>
}
}
We welcome contributions! Please see our Contributing Guide for details.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ for the Rust and WebAssembly community