Leptos Styling
Leptos Styling is a powerful styling solution for Leptos applications that enables seamless integration of CSS and SCSS stylesheets. It intelligently manages stylesheet embedding in both SSR (Server-Side Rendering) and CSR (Client-Side Rendering) modes.
This crate internally uses turf macros for efficient CSS processing and management.
Features
- CSS/SCSS Support: Write your styles in CSS or SCSS and import them directly into your components
- Smart Bundling: Automatically handles stylesheet embedding based on your rendering mode (SSR/CSR)
- Type-Safe Classes: Generate type-safe CSS class names to prevent runtime errors
- Zero Runtime Overhead: All processing happens at compile time
- Framework Integration: Seamless integration with Axum and other web frameworks
Installation
Add the following to your Cargo.toml:
[]
= "0.2.0"
[]
= ["leptos_styling/ssr"]
Quick Start
Define Your Styles
use *;
use ;
// Import from external CSS file
style_sheet!;
// Or define styles inline
inline_style_sheet!
Use in Components
Setup
Client-Side Setup
Server-Side Setup
async
App Integration
Feature Flags
| Flag | Description |
|---|---|
ssr |
Enable server-side rendering support |
csr |
Enable client-side rendering support |
Version Compatibility
| Leptos Styling | Leptos Version |
|---|---|
| 0.2.x | 0.8 |
| 0.1.x | 0.7 |
Documentation
Contributing
We welcome contributions!
License
This project is licensed under the MIT License - see the LICENSE file for details.