Derive Macro tailwind_fuse::TwVariant
source · #[derive(TwVariant)]
{
// Attributes available to this derive:
#[tw]
}
Expand description
Represents a customizable property (variant) of a UI element. Each variant must be an enum with a default case.
Use .to_class() to get the class for the variant and .with_class() to append a class.
§Example
use tailwind_fuse::*;
#[derive(TwVariant, Debug)]
// Optional base class
#[tw(class = "hover:brightness-50")]
enum BtnColor {
#[tw(default, class = "bg-blue-500 text-blue-100")]
Default,
#[tw(class = "bg-red-500 text-red-100")]
Red,
}
assert_eq!(BtnColor::Default.to_class(), "hover:brightness-50 bg-blue-500 text-blue-100");
let red_with_class = BtnColor::Red.with_class("flex");
assert_eq!(red_with_class, "hover:brightness-50 bg-red-500 text-red-100 flex");