| Crates.io | twust_macro |
| lib.rs | twust_macro |
| version | 1.1.0 |
| created_at | 2025-01-17 20:37:31.226589+00 |
| updated_at | 2025-01-19 11:36:50.672171+00 |
| description | Zero-config Static type-checker for Tailwind CSS |
| homepage | |
| repository | https://github.com/Oyelowo/twust |
| max_upload_size | |
| id | 1520971 |
| size | 368,435 |
twustTwust is a powerful static checker in Rust for TailwindCSS class names at compile-time. It ensures correctness by validating class names before runtime, preventing errors and improving developer experience.
twust
[dependencies]
twust = "1.0.7"
Enable optional features (e.g., daisyui support):
[dependencies]
twust = { version = "1.0.7", features = ["daisyui"] }
tw! - Compile-time Type-Checked Tailwind Classesuse twust::tw;
let class = tw!("bg-red-500 text-lg");
assert_eq!(class, "bg-red-500 text-lg");
// You can also separate classnames by space, these will be merged
let classes_list = tw!["bg-blue-500 hover:bg-blue-700", "bg-purple", "py-sm md:py-md tablet:py-sm lg:py-lg xl:py-xl"];
assert_eq!(classes_list, "bg-blue-500 hover:bg-blue-700 bg-purple py-sm md:py-md tablet:py-sm lg:py-lg xl:py-xl")
// You can override/extend color/background color in tailwind.config.json
tw!("bg-taxvhiti bg-tahiti-500 bg-tahiti bg-midnight bg-purple bg-red-50 bg-tahiti-800 border-s-tahiti-800");
tw!("md:text-red-50 text-slate-50 text-purple text-tahiti-500");
tw!("py-sm md:py-md tablet:py-sm lg:py-lg xl:py-xl");
tw!("group");
tw!("hover:-translate-y-0.5 transition motion-reduce:hover:translate-y-0 motion-reduce:transition-none");
tw!("group/edit block invisible md:hover:bg-slate-200 group-hover/item:visible");
tw!("group-[:nth-of-type(3)_&]:block group-hover/edit:text-gray-700 group-[:nth-of-type(3)_&]:block");
tw!("scroll-m-15 group-aria-[sort=ascending]:rotate-0");
// Even scroll margin can also be configured, here we add, sm and md under the Spacing/scrollMargin field in the config file
tw!("scroll-mx-sm scroll-mx-md");
tw!("px-[-45px] px-[-45cm] px-[-45rem] px-[-45em] px-[-45%] px-[-45vh]");
tw!("m-4 last:first:invalid:last:first:p-4 last:m-4 pb-[calc(100%-34px)] pb-[23px] [mask-type:luminance]
[mask-type:luminance] hover:[mask-type:alpha] lg:[--scroll-offset:44px] oyelowo oyedayo break-after-avoid"
);
tw!("h-full border-2 border-opacity-60 rounded-lg overflow-hidden");
tws! - Compile-time Checked Array of Classesuse twust::tws;
let class_list = tws!["bg-red-500", "text-lg", "p-4"];
assert_eq!(class_list, ["bg-red-500", "text-lg", "p-4"]);
tw1! - Single Tailwind Class Onlyuse twust::tw1;
let class = tw1!("bg-red-500");
assert_eq!(class, "bg-red-500");
tws1! - Array of Single-Class Items Onlyuse twust::tws1;
let class_list = tws1!["text-xl", "border", "m-4"];
assert_eq!(class_list, ["text-xl", "border", "m-4"]);
tailwind.config.json Overview{
"corePlugins": {},
"allowedLists": {
"classes": [],
"modifiers": []
},
"theme": {
"extend": {}
},
"variants": {},
"plugins": {}
}
TailwindCSS offers developers a flexible utility-first approach to styling web applications. However, its flexibility can also lead to potential pitfalls:
Twust addresses these challenges by offering:
tailwindcss-to-rusttwustTwust is licensed under MIT/Apache-2.0. See LICENSE for details.
Email: oyelowo.oss@gmail.com
If you find Twust useful, give it a ⭐ on GitHub!