Syntax
The syntax of Glaze is straightforward and easy to understand. If you're familiar with Tailwind, you'll find Glaze's approach very similar.
Animation strings are defined in the following order:
- Breakpoint (optional)
- Selector (optional)
- State (required)
- Animation object (required)
Breakpoints
Breakpoints allow you to specify when an animation should run, based on the
breakpoints defined in the configuration. The breakpoint is defined using the
@
symbol, followed by the breakpoint name.
Selectors
By default, animations are applied directly to the element itself. However, you
can target other elements using selectors enclosed in brackets ([]
) before the
state.
The &
symbol refers to the parent element, allowing you to specify a child
selector.
With media queries:
State
The animation state indicates the beginning and end points of the animation:
- from: The initial state of the animation.
- to: The final state of the animation.
If both states are defined, the animation will run from the initial state to the final state. (fromTo in GSAP)
Animation object
The animation object specifies the properties to animate, following the state.
The string is parsed by splitting at the dash (-
), where the first part is the
property name, and the second part is its value. Values are automatically
converted to their appropriate type (string
, number
, or boolean
).
Chaining properties
To combine multiple properties in a single animation, separate them with a pipe
(|
) character.
Nested objects
Access nested object properties by separating keys with a dot (.
) character.
Negative values
For negative values, enclose the value in brackets. ([]
)
Spaces
For values with spaces, use an underscore (_
) character.