Package-level declarations

Types

Link copied to clipboard
enum class Combinator : Enum<Combinator>

how a compound selector relates to the one before it

Link copied to clipboard
data class ComplexSelector(val compounds: List<CompoundSelector>, val combinators: List<Combinator>)

A complex selector of CSS: compounds from left to right, with the combinators between them, one fewer than the compounds. The last compound selects the node.

Link copied to clipboard
data class CompoundSelector(val simples: List<SimpleSelector>)

a compound selector: the simple selectors that one node matches, like button.primary:hover

Link copied to clipboard
data class CssDeclaration(val name: String, val value: String, val important: Boolean = false)

a declaration of CSS: the property name with value as text, important when it is marked !important

Link copied to clipboard
data class CssDimension(val value: Double, val unit: String)

a number with a unit of CSS, like 12px, 50%, 1.5em or 2fr; unit is lowercase, empty for numbers

Link copied to clipboard
data class CssKeyframe(val offset: Double, val declarations: List<CssDeclaration>)

a keyframe of an @keyframes rule: its offset from 0 to 1 and its declarations

Link copied to clipboard
enum class CssKeyword : Enum<CssKeyword>

the keywords that every CSS property takes

Link copied to clipboard
data class CssMediaEnvironment(val width: Double, val height: Double, val colorScheme: String = "dark", val type: String = "screen")

What media queries are evaluated against: the size of the viewport in pixels, its preferred colorScheme, dark or light, and the media type

Link copied to clipboard
open class CssProperties

The properties of a style system by their names, and its shorthands: a shorthand is expanded into the declarations of its longhands

Link copied to clipboard
class CssProperty<T>(val name: String, val inherited: Boolean, val initial: T, val parse: (String) -> T?)

A property of CSS: its name, whether it is inherited by default, its initial value, and how a value is parsed from text, null when the text is not a valid value

Link copied to clipboard
data class CssRule(val selectors: List<String>, val block: String, val order: Int, val media: String? = null)

A rule of CSS: its selectors and the text of its block, order is its place in the style sheet; media is the media query of the @media rules it is in, null when it is in none

Link copied to clipboard
interface SelectorTree<N>

How selectors see the nodes of a tree, like the elements of an SVG document or of a user interface: selectors match any tree through this view of it.

Link copied to clipboard
sealed interface SimpleSelector

a simple selector: a type, an id, a class, an attribute or a pseudo-class

Link copied to clipboard
data class Specificity(val ids: Int, val classes: Int, val types: Int) : Comparable<Specificity>

the specificity of a selector: its ids, its classes, attributes and pseudo-classes, and its types

Link copied to clipboard
fun interface TimingFunction

a timing function of CSS, like those of transitions and animations, and the key splines of SMIL

Link copied to clipboard
class Transition<V>(val property: String, val from: V, val to: V, val start: Double, val timing: TransitionTiming)

A transition of property from from to to that starts at start, in seconds

Link copied to clipboard
class Transitions<V>(interpolate: (property: String, a: V, b: V, t: Double) -> V)

The transitions of the properties of one element, of values of type V that interpolate interpolates: a change of a property with a TransitionTiming transitions from the value that is shown, also when another transition of the property runs, to the new value. Transitions of CSS.

Link copied to clipboard
data class TransitionTiming(val duration: Double, val delay: Double = 0.0, val timingFunction: TimingFunction = TimingFunction.EASE)

How a property transitions: over duration seconds, after delay seconds, with timingFunction

Functions

Link copied to clipboard
fun cssBoxSides(value: String): List<String>?

the four sides of a box shorthand of CSS, like margin and padding: top, right, bottom and left; null when invalid

Link copied to clipboard

True when the media query list query matches environment: queries separated by commas, any of which matches, with not, only, a media type, and features joined by and: width, height, aspect-ratio with min- and max-, comparisons like (width >= 600px), orientation and prefers-color-scheme. Features that are not known do not match.

Link copied to clipboard
fun evaluateCssCalc(value: String, leaf: (String) -> Double?): Double?

The value of the calc() expression value: sums, differences, products and quotients of values that leaf evaluates, in parentheses and nested calc(); null when it is not valid or a leaf is not known

Link copied to clipboard

true when name is a named color of CSS

Link copied to clipboard

a CSS angle in degrees: deg, grad, rad, turn or a number of degrees; null when it is not an angle

Link copied to clipboard
fun parseCssColor(text: String): ColorRGBa?

The color of the CSS color text, in sRGB; null when it is not a color. Reads named colors, transparent, hexadecimal colors of 3, 4, 6 or 8 digits, rgb(), rgba(), hsl(), hsla() and the color functions of CSS Color 4 and 5: hwb(), lab(), lch(), oklab(), oklch(), color() with the predefined color spaces, color-mix() and light-dark(). Keywords that depend on where the color is used, like currentcolor, are not colors here.

Link copied to clipboard

the declarations of a block or a style attribute, with !important removed from their values

Link copied to clipboard

the number with a unit text is, null when it is not one

Link copied to clipboard

the @keyframes rules of css, by name, with their keyframes in the order of their offsets

Link copied to clipboard

The value of text in pixels: a length in absolute units, a number, or a calc() expression of them; null when it is not one

Link copied to clipboard

The rules of the style sheet css, in the order they are given, with the rules in @media rules, which have their media queries; other at-rules are left out

Link copied to clipboard

The complex selector text, like g:hover > .item:not(.off); null when it is not valid or not supported, like pseudo-elements and :has()

Link copied to clipboard

the selector list text, like a, b > c; null when a selector in it is not valid or not supported

Link copied to clipboard
fun parseCssTime(value: String): Double?

A time of CSS or a clock value of SMIL, in seconds: 2s, 500ms, 1.5, 01:30, 00:01:30.5, 2min, 1h; null when it is not a time

Link copied to clipboard
fun splitCss(text: String, separator: Char, limit: Int = Int.MAX_VALUE): List<String>

text split at separator, except where the separator is in parentheses or quotes, in at most limit parts

Link copied to clipboard

text split at the commas that are not in parentheses, like the lists of CSS

Link copied to clipboard

text split at whitespace that is not in parentheses or quotes, like the values of shorthands

Link copied to clipboard
fun substituteCssVariables(value: String, variables: (String) -> String?): String?

value with its var() functions replaced by the values of the custom properties that variables gives by their names, like --accent, or by their fallbacks. Null when a custom property is not defined and has no fallback, which makes a declaration invalid at computed-value time, as in CSS.

Link copied to clipboard
fun ColorRGBa.toCssColor(): String

this as a CSS color, rgb() of its sRGB values; parseCssColor reads it back