Expand description
shadcn-rs: A comprehensive UI component library for Rust/WebAssembly
This library provides shadcn/ui compatible components for building modern web applications with Rust and Yew.
§Quick Start
use yew::prelude::*;
use shadcn_rs::{Button, Variant, Size};
#[function_component(App)]
fn app() -> Html {
let onclick = Callback::from(|_| {
web_sys::console::log_1(&"Button clicked!".into());
});
html! {
<Button variant={Variant::Primary} size={Size::Lg} onclick={onclick}>
{ "Click me" }
</Button>
}
}§Features
- 59+ accessible, customizable components
- Full keyboard navigation support
- Dark mode support via CSS variables
- Touch gesture support for mobile
- Type-safe component APIs with Rust enums
§CSS
Include the shadcn-rs CSS file in your HTML:
<link rel="stylesheet" href="shadcn-rs.css">Re-exports§
pub use types::Alignment;pub use types::Color;pub use types::Position;pub use types::Size;pub use types::Variant;pub use utils::Portal;pub use utils::class_if;pub use utils::class_names;pub use utils::generate_id;pub use utils::use_portal;pub use hooks::use_click_outside;pub use hooks::use_click_outside;pub use hooks::use_click_outside_conditional;pub use hooks::use_controllable_bool;pub use hooks::use_controllable_state;pub use hooks::use_controllable_state;pub use hooks::use_controllable_state_optional;pub use hooks::use_escape_key;pub use hooks::use_escape_key;pub use hooks::use_escape_key_conditional;pub use hooks::use_key_press;pub use hooks::use_toggle;pub use hooks::use_toggle;pub use hooks::use_toggle_with_controls;pub use components::*;
Modules§
- components
- UI Components
- hooks
- Custom Yew hooks
- types
- Shared type definitions
- utils
- Utility functions and helpers
Macros§
- class_
list - Helper macro for building class names with conditions
Constants§
- VERSION
- Library version