API overview
#
Types and value constructorsRosebox has types that correspond to CSS's data-types, for example, Length
which corresponds to CSS's <length>
, Duration
which corresponds to CSS's <time>
, and Color
which corresponds to CSS's <color>
. To construct a value of some type in RB, you need to use one of the type's value constructors. A value constructor is a function that takes zero or more arguments and constructs a value of the type it's associated with. Examples tend to make these less awkward, so let's take a look at the following example:
Following the example above:
ms(300)
constructs a value of typeDuration<"milliseconds">
.rgb(10, 10, 10)
constructs a value of typeRGB
which in its turn is also a union member ofColor
.px(30)
constructs a value of typeLength<"px">
em(5)
constructs a value of typeLength<"em">
.per(50)
constructs a value of typePercentage
.