@css annotation marks global style definitions that are processed at compile-time and rendered as global CSS rules.
Overview
The@css annotation provides a type-safe way to define CSS rules with selectors, nested rules, media queries, and other CSS at-rules. It must be used on global variables, global getters, static fields, or static getters.
Basic Usage
API Reference
css() Method
Create a style rule with a selector:Any valid CSS selector string.
Optional nested rules. Use
& to reference the parent selector.Defining Styles
Chain.styles() to add CSS properties:
Nested Rules
Use the& symbol to reference the parent selector:
Media Queries
Define responsive styles with media queries:MediaQuery Options
Examples
Font Faces
Define custom fonts:Import External Stylesheets
Keyframe Animations
Define CSS animations:Layer Rules
Define cascade layers:Supports Queries
Feature detection:Complex Example
Usage in Components
Styles defined with@css are automatically injected globally. Reference them using class names:
Restrictions
- Must be used on global variables, global getters, static fields, or static getters
- Must be of type
List<StyleRule> - Cannot be used on instance fields or local variables
See Also
- Styles Class - Inline styles API
- Style Component - Render style rules as components
- Styling Guide - Complete styling guide