Expand description
A Rust macro library for compile-time CSS class name concatenation and processing
§Features
- Zero runtime overhead - everything happens at compile time
- Automatic whitespace handling and normalization
- Support for concatenating multiple class names
- Removes leading/trailing whitespace and collapses multiple spaces
§Examples
Basic usage:
use classnames_const_rs::*;
const BUTTON_CLASS: &str = classnames_concat!("btn", "btn-primary");
assert_eq!(BUTTON_CLASS, "btn btn-primary");
Handling messy whitespace:
use classnames_const_rs::*;
const COMPLEX_CLASS: &str = classnames_concat!("header ", " main ", "footer");
assert_eq!(COMPLEX_CLASS, "header main footer");
Empty strings are handled gracefully:
use classnames_const_rs::*;
const SPARSE_CLASS: &str = classnames_concat!("", "active", "", "highlight");
assert_eq!(SPARSE_CLASS, "active highlight");
Macros§
- classnames_
concat - Concatenates multiple class name strings with automatic whitespace handling
- trim_
format - Formats a string by normalizing whitespace characters