shadcn-rust
⚠️ DEVELOPMENT WARNING ⚠️
This package is currently under active development and not ready for production use. APIs, commands, and functionality may change significantly between versions. Use at your own risk and expect breaking changes.
A command-line tool for adding beautiful UI components to Rust web applications. Inspired by shadcn/ui, this CLI works with Dioxus, Leptos, Yew, and Sycamore frameworks.
Features
- 🚀 Quick Setup: Initialize your project with a single command
- 🎨 Multiple Themes: Choose from different UI themes and color schemes
- 🔧 Framework Support: Works with Dioxus, Leptos, Yew, and Sycamore
- 📦 Component Registry: Access to a curated collection of UI components
- 🎯 Tailwind Integration: Automatic Tailwind CSS configuration
- 🔍 Project Diagnostics: Built-in health checks for your configuration
Installation
Quick Start
-
Initialize your project:
-
List available components:
-
Add components to your project:
-
Verify your setup:
Commands
init
Initialize a new project with component configuration.
Options:
--framework <FRAMEWORK>
- Target framework:dioxus
,leptos
,yew
, orsycamore
--theme <THEME>
- UI theme:default
ornew-york
--base-color <COLOR>
- Base color scheme:slate
,gray
,zinc
,neutral
, orstone
--skip-tailwind
- Skip Tailwind CSS setup--yes
- Skip interactive prompts and use defaults--config <FILE>
- Configuration file path (default:components.json
)
Examples:
# Interactive setup
# Non-interactive with specific options
# Skip Tailwind setup
list
List all available components for your framework.
Options:
--config <FILE>
- Configuration file path (default:components.json
)
Example:
add
Add one or more components to your project.
Arguments:
<COMPONENTS>...
- Names of components to add
Options:
--force
- Overwrite existing components--export
- Add component exports to module files--config <FILE>
- Configuration file path (default:components.json
)
Examples:
# Add a single component
# Add multiple components
# Add with export and force overwrite
doctor
Diagnose your project configuration and environment.
Options:
--config <FILE>
- Configuration file path (default:components.json
)
Example:
Configuration
The CLI uses a components.json
file to store project configuration:
Configuration Fields
framework
: The target Rust web framework (dioxus
,leptos
,yew
,sycamore
)style
: UI style variant (default
)tailwind.output
: Where compiled Tailwind CSS should be writtentailwind.baseColor
: Base color scheme for componentsaliases
: Directory mappings for different component typesregistry
: Component registry URL
Supported Frameworks
Dioxus
- Default Tailwind output:
assets/tailwind.css
- Components are written as Dioxus components with
.rs
files
Leptos
- Default Tailwind output:
styles/tailwind.css
- Components use Leptos view macros and reactive primitives
Yew
- Default Tailwind output:
styles/tailwind.css
- Components use Yew's function components and hooks
Sycamore
- Default Tailwind output:
styles/tailwind.css
- Components use Sycamore's view! macro and reactive system
Project Structure
After initialization, your project will have this structure:
your-rust-app/
├── components.json # CLI configuration
├── src/
│ ├── components/
│ │ ├── ui/ # UI components from registry
│ │ └── mod.rs
│ ├── utils/
│ │ └── shadcn/ # Utility functions
│ └── hooks/ # Custom hooks (if applicable)
├── assets/ # (Dioxus) or styles/ (others)
│ └── tailwind.css # Compiled Tailwind CSS
└── tailwind.config.js # Tailwind configuration
Component Registry
Components are fetched from the official Shadcn-Rust registry at https://shadcn-rust.com/registry
. The registry contains:
- Framework-specific component implementations
- Tailwind CSS styles and themes
- TypeScript definitions and utilities
- Documentation and examples
Tailwind CSS Integration
The CLI automatically sets up Tailwind CSS for your project:
- Configuration: Generates
tailwind.config.js
with framework-specific content paths - Base Styles: Creates base CSS files with theme variables
- Component Styles: Includes necessary CSS for added components
- Color Schemes: Supports multiple base color options
Tailwind Configuration Example
/** @type {import('tailwindcss').Config} */
module.exports = ;
Global Options
All commands support these global options:
--config <FILE>
- Specify a custom configuration file path (default:components.json
)--yes
- Skip interactive prompts and use default values--help
- Show help information--version
- Show version information
Troubleshooting
Common Issues
- "Config not found" error: Run
shadcn-rust init
from your project root - "Components folder missing": Ensure your aliases in
components.json
point to valid directories - Network issues: The CLI requires internet access to fetch components from the registry
Getting Help
Use the doctor
command to diagnose configuration issues:
This will check:
- Configuration file validity
- Registry accessibility
- Component directory structure
- Theme availability
Examples
Setting up a new Dioxus project
# Initialize with Dioxus framework
# Add some common components
# Verify everything is working
Adding components to an existing project
# List what's available
# Add specific components with exports
# Force overwrite existing component
Non-interactive usage (CI/CD)
# Set up project without prompts
# Add components in batch
Requirements
- Rust: 1.75.0 or later
- Git: Required for fetching components from the registry
- Internet Connection: Needed to access the component registry
License
MIT © Codegress / Contributors