Resource

Resource Collection

Resources are defined inside a resource collection. The syntax of a resource collection is as follows:

/* Normal resources. */
::res {
    /* Resource here. */
}

/* Resources is available when accent is blue. */
::res[accent=blue] {
    /* Resource here. */
}

/* 
Resource is available when accent is blue. 
And description is "Resources description". 
*/
::res[accent=blue][desc=Resources description] {
    /* Resource here. */
}

/* 
Resource is available when theme is light and accent is blue. 
And description is "Resources description". 
*/
::res[theme=light][accent=blue][desc=Resources description] {
    /* Resource here. */
}

For resource collections, we currently only support the desc, accent and theme attributes. The desc is a normal attribute. The accent and theme are filtered attributes. The valid reference for the accent filter is the configuration parameter in IAcssConfigration, and the valid reference for the theme filter is Avalonia's ThemeVariant.

Note

We plan to provide more filtering attributes for Acss' filtering control in the future.

Resource Syntax

The syntax of a resource definition takes the following form:

Custom Resources

The custom resource syntax is the same as the built-in resource syntax, and the form is as shown in the resource syntax. Custom resources refer to extended resources.

Color

Acss supports a wide range of colour expressions, including common colour names, RGB, RGBA, HSL, HSV and more.

Acss supports additional definition of transparency for all expressions of values, which allows us to define colour resources more flexibly. Example:

Brush

Brush supports all value expressions supported by Color, including common colour names, RGB, RGBA, HSL, HSV, etc., as well as additional transparency definitions.

Brushes also support applying dynamic resources to their colour property. Additional transparency property can still be added when applying dynamic resources.

Linear Brush

Currently our support for Linear Brush is not complete. The initial usage is shown in the following code.

Double & Int

Thickness

Transition

Acss supports defining Transition resources for easy reuse, which Avalonia does not have. Avalonia supports defining Transitions resources, which we don't support at the moment.

BoxShadows

We have imperfect support for shadow resources for the time being, and only support the following forms of definitions.

Last updated

Was this helpful?