LiveStyle.Types (LiveStyle v0.13.1)
View SourceTyped CSS custom property helpers for @property rule generation.
These functions create type specifications for CSS custom properties, enabling smooth transitions and animations on custom properties.
This module aligns with StyleX's stylex.types API.
Examples
import LiveStyle.Types
vars [
rotation: angle("0deg"),
progress: percentage("0%"),
scale: number(1)
]Generated CSS
@property --rotation {
syntax: "<angle>";
inherits: true;
initial-value: 0deg;
}
Summary
Functions
Angle type (<angle>).
Any type (*).
Color type (<color>).
Creates a property with a custom syntax.
Custom identifier type (<custom-ident>).
Image type (<image>).
Integer type (<integer>).
Length type (<length>).
Length or percentage type (<length-percentage>).
Creates a non-inheriting property type.
Number type (<number>).
Percentage type (<percentage>).
Resolution type (<resolution>).
String type (<string>).
Time type (<time>).
Transform function type (<transform-function>).
Transform list type (<transform-list>).
URL type (<url>).
Types
Functions
@spec angle(String.t()) :: property_type()
Angle type (<angle>).
Accepts values like 0deg, 90deg, 0.5turn.
@spec any(String.t()) :: property_type()
Any type (*).
Accepts any value. Note: properties with * syntax cannot be animated.
@spec color(String.t()) :: property_type()
Color type (<color>).
Accepts any valid CSS color value.
@spec custom(String.t(), String.t() | number()) :: property_type()
Creates a property with a custom syntax.
Use this for complex or union types.
Examples
Types.custom("<length> | auto", "auto")
@spec custom_ident(String.t()) :: property_type()
Custom identifier type (<custom-ident>).
Accepts custom identifiers (unquoted strings).
@spec image(String.t()) :: property_type()
Image type (<image>).
Accepts url(), gradient functions, etc.
@spec integer(integer()) :: property_type()
Integer type (<integer>).
Accepts whole numbers only.
@spec length(String.t()) :: property_type()
Length type (<length>).
Accepts values like 0px, 1rem, 10vh.
@spec length_percentage(String.t()) :: property_type()
Length or percentage type (<length-percentage>).
Accepts lengths or percentages.
@spec no_inherit(property_type()) :: property_type()
Creates a non-inheriting property type.
By default, all properties inherit. Use this to create one that doesn't.
Examples
Types.length("0px") |> Types.no_inherit()
@spec number(number()) :: property_type()
Number type (<number>).
Accepts any numeric value (integers or decimals).
@spec percentage(String.t()) :: property_type()
Percentage type (<percentage>).
Accepts percentage values like 50%, 100%.
@spec resolution(String.t()) :: property_type()
Resolution type (<resolution>).
Accepts values like 96dpi, 2dppx.
@spec string(String.t()) :: property_type()
String type (<string>).
Accepts quoted string values.
@spec time(String.t()) :: property_type()
Time type (<time>).
Accepts values like 0ms, 1s, 300ms.
@spec transform_function(String.t()) :: property_type()
Transform function type (<transform-function>).
Accepts a single transform function like rotate(45deg).
@spec transform_list([String.t()]) :: property_type()
Transform list type (<transform-list>).
Accepts a list of transform functions.
Examples
Types.transform_list([
Functions.rotate(Units.deg(45)),
Functions.scale(1.5)
])
@spec url(String.t()) :: property_type()
URL type (<url>).
Accepts URL values.