marianoguerra/css/value does not have a README file

    Color

    pub(all) enum Color {
    Hex(String)
    Named(String)
    Function(String, Array[
    ComponentValue
    ])
    } derive(Eq,
    Debug
    )

    A colour, as far as the syntax can say.

    Syntactic rather than numeric, and that is the point. lightningcss quantises every colour to RGBA{u8,u8,u8,u8}, which is right for a minifier and makes #fff, #ffffff and white the same value -- so a formatter built on it cannot give a stylesheet back the way it arrived. to_rgba below is available for a caller that wants the numbers; the tree keeps the text.

    Dimension

    pub(all) struct Dimension {
    value : Double
    unit : String
    kind : UnitKind
    } derive(Eq,
    Debug
    )

    A dimension: a number and the unit it was written with.

    Specificity

    pub(all) struct Specificity {
    ids : Int
    classes : Int
    elements : Int
    } derive(Eq,
    Debug
    )

    The three counts CSS compares, most significant first.

    A triple rather than a packed integer: the packed form overflows on absurd input and reads as a magic number when it does not, and comparing three fields is not the expensive part of anything.

    Specificity::add

    fn Specificity::add(self : Specificity, other : Specificity) -> Specificity

    Specificity::beats

    fn Specificity::beats(self : Specificity, other : Specificity) -> Bool

    Whether this selector wins against that one.

    Specificity::to_triple

    fn Specificity::to_triple(self : Specificity) -> (Int, Int, Int)

    (a, b, c), the way CSS writes it.

    Specificity::zero

    fn Specificity::zero() -> Specificity

    UnitKind

    pub(all) enum UnitKind {
    Length
    Angle
    Time
    Frequency
    Resolution
    Flex
    Unknown
    } derive(Eq,
    Debug
    )

    What kind of quantity a unit measures.

    The grouping is the one CSS's own grammars use: a property takes a length, or an angle, or a time -- never "a dimension".

    as_color

    The colour a value is, if it looks like one.

    "Looks like" is honest about the limit: this cannot know whether a caller's property takes a colour, only whether the value could be one. An identifier is a colour if it is a known name, because red is and auto is not.

    as_dimension

    The dimension a value is, if it is one.

    as_function

    The arguments of a function call by this name, if that is what this is.

    Case-insensitive, because CSS function names are.

    as_integer

    The integer a value is, if it is exactly one.

    is_int rather than a floor: 2.0 is written as a number with a fractional part, and a grammar asking for an integer should not silently accept it.

    as_keyword

    fn as_keyword(v :
    ComponentValue
    , allowed : Array[String]) -> String?

    The keyword a value is, lower-cased, if it is one of allowed.

    The membership test is the caller's list, because "is this a keyword" has no answer without knowing which property is being read.

    as_length

    The length a value is.

    A bare 0 counts: CSS lets a zero length omit its unit, and a caller asking for a length would otherwise have to special-case the one number that is always allowed.

    as_number

    The number a value is, if it is one.

    A percentage is deliberately NOT a number: 50% and 50 mean different things everywhere in CSS, and folding them here would make every caller re-check which it had.

    as_percentage

    The percentage a value is, as its face value: 50% gives 50, not 0.5.

    Face value because that is what the source said, and a caller dividing by a hundred is doing so for a reason this package cannot know.

    as_url

    The url a value names, quoted or not -- both are the same node.

    as_var

    The custom property a var() reads, and its fallback.

    max_specificity

    The specificity of a selector LIST, which is not the sum.

    A list has no single specificity -- each arm has its own, and the cascade compares whichever one matched. This returns the highest, which is what :is() and :not() contribute and what a caller asking "how specific is this rule" almost always means.

    specificity

    The specificity of a selector.

    to_rgba

    fn to_rgba(c : Color) -> (Int, Int, Int, Int)?

    A hex colour as its channels, if it is one this can resolve.

    Only the hex form: resolving oklch() means implementing a colour space, and resolving red means carrying the named-colour table's values. Both are real work with real answers, and neither belongs behind a function that looks this cheap.

    unit_kind

    fn unit_kind(unit : String) -> UnitKind

    What a unit measures. Case-insensitive, as CSS units are.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io