maomi
Introduction
Guide
Documents

Style Constants

Constant value

It is able to define constants in stylesheets.

stylesheet! {
const TEXT_COLOR: value = rgb(32, 32, 32);
class my_class {
color = TEXT_COLOR;
}
}

The constant can be any CSS token, but should only be a single token.

stylesheet! {
// cannot be multiple tokens
const SIZE: value = Px(1) Px(2);
}

Keyframes definition

Keyframes can be declared as a special type of constants.

stylesheet! {
const MY_ANIMATION: keyframes = {
from {
opacity = 1;
}
50% {
opacity = 0.5;
}
to {
opacity = 1;
}
};
class my_class {
animation_name = MY_ANIMATION;
animation_duration = S(2);
}
}