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!("hover:brightness-50 bg-blue-500 text-blue-100", BtnColor::Default.as_class());
assert_eq!("hover:brightness-50 bg-red-500 text-red-100", BtnColor::Red.as_class());