-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
🎯 Feature Request: Rust-based CSS Generator
Problem Statement
Currently, tailwind-rs-core generates classes at runtime, but Tailwind's JIT compiler only includes classes it finds in source files. This creates a gap where:
- Generated classes from
ClassBuilderaren't visible in the final CSS - Users need external tools or manual CSS management
- No seamless integration between class generation and CSS compilation
Proposed Solution
Integrate a Rust-based CSS generator directly into tailwind-rs-core that:
- Generates comprehensive CSS files with all necessary Tailwind classes
- Works seamlessly with existing
ClassBuilderAPI - Eliminates need for external tools or CDN dependencies
- Provides type-safe, Rust-native CSS generation
Proposed API
use tailwind_rs_core::*;
// Generate classes
let classes = ClassBuilder::new()
.padding(SpacingValue::Integer(4))
.background_color(Color::new(ColorPalette::Blue, ColorShade::Shade100))
.build();
// NEW: Auto-generate CSS with all classes
tailwind_rs_core::generate_css_file("styles.css", &classes)?;
// Advanced usage
let mut generator = CssGenerator::new()
.include_color_palettes(vec!["blue", "gray", "purple"])
.include_spacing(true)
.include_typography(true)
.include_shadows(true);
generator.generate_css_file("comprehensive.css")?;Benefits
- ✅ Seamless integration - No external tools needed
- ✅ Type safety - Everything in Rust
- ✅ Performance - Generate once, serve many
- ✅ Flexibility - Configurable generation
- ✅ Framework agnostic - Works with Leptos, Dioxus, Yew, etc.
Implementation Details
We have already developed a working prototype that:
- Generates comprehensive CSS with all Tailwind classes
- Includes color palettes, spacing, typography, shadows, etc.
- Integrates with existing
ClassBuilderAPI - Provides configuration options for what to include
Use Case Example
// Current workflow (problematic)
let classes = ClassBuilder::new()
.background_color(Color::new(ColorPalette::Blue, ColorShade::Shade100))
.build();
// Classes generated but not visible in final CSS
// Proposed workflow (seamless)
let classes = ClassBuilder::new()
.background_color(Color::new(ColorPalette::Blue, ColorShade::Shade100))
.build();
// Generate CSS file with all necessary classes
tailwind_rs_core::generate_css_file("target/site/pkg/styles.css", &classes)?;
// Now all classes are available in the CSS fileWhy This Belongs in tailwind-rs-core
- Solves a real problem that affects many users
- Fits the crate's purpose of Tailwind + Rust integration
- Complements existing
ClassBuilderfunctionality - Reduces ecosystem fragmentation
- Provides a complete, type-safe solution
Next Steps
- Move CSS generator logic into
tailwind-rs-core - Add proper configuration options
- Write comprehensive tests
- Update documentation with examples
- Release as part of the core crate
This would make tailwind-rs-core a complete solution for Tailwind CSS in Rust applications! 🚀
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request