The CSSNode is the foundational class that CSS objects extend from.
The CSSComponent class represents semantically significant objects in CSS. It extends CSSNode and has no direct representation.
{
value: ( CSSNumber | CSSString | CSSIdentifier | CSSDelimiter | CSSBlock )[];
}
The CSSComment class represents comments in CSS. It extends CSSNode.
{
value: string</^\/\*([^*]|\*[^\/])*\*\/$/[1]>;
}
new CSSComment({ value: `some comment` }) // `/*some comment*/`
new CSSComment({ value: ` another comment ` }) // `/* another comment */`The CSSWhitespace class represents groupings of CSS whitespace, including spaces, tabs, form feeds, line feeds, and carriage returns. It extends CSSNode.
{
value: string</^[ \t\n\f\r]+$/>;
}
new CSSWhitespace({ value: `\n \t` }) // `\n \t`The CSSNumber class that represent numerics in CSS, including integers, floats, percentages, and dimensions. It extends CSSComponent.
{
value: string</^[+-]?([0-9]+(\.[0-9]*)?|\.[0-9]+)([Ee]-?[0-9]+)?$/>;
unit: string</^(-?([-A-Z_a-z�-ÿ]|\\[^\n\f\r])([-0-9A-Z_a-z�-ÿ]|\\[^\n\f\r])*)?$/>;
}
new CSSNumber({ value: `1.5`, unit: `em` }) // 1.5em
new CSSNumber({ value: `1.5`, unit: `%` }) // 1.5%
new CSSNumber({ value: `1.5`, unit: `` }) // 1.5The CSSString class represents strings delimited by quotes. It extends CSSComponent.
{
value: string</^("([^"\\\n\f\r]|\\.)*"|'([^'\\\n\f\r]|\\.)*')$/[2|3]>;
delimiter: ( `"` | `'` );
}
new CSSString({ value: `hello world`, delimiter: `"` }) // `"hello world"`
new CSSString({ value: `hello 'world'`, delimiter: `'` }) // `'hello \'world\''`The CSSIdentifier class represents identifying references in CSS. It extends CSSComponent.
{
value: string</^-?([-A-Z_a-z�-ÿ]|\\[^\n\f\r])([-0-9A-Z_a-z�-ÿ]|\\[^\n\f\r])*$/>;
}
new CSSIdentifier({ value: `color` }) // `color`
new CSSIdentifier({ value: `--color` }) // `--color`The CSSHashIdentifier class represents hash-prefixed references in CSS. It extends CSSIdentifier.
{
value: string</^#(([-0-9A-Z_a-z�-ÿ]|\\[^\n\f\r])+)$/[1]>;
}
new CSSIdentifier({ value: `ff0` }) // `#ff0`
new CSSIdentifier({ value: `main` }) // `#main`The CSSAtIdentifier class represents at-prefixed references in CSS. It extends CSSIdentifier.
{
value: string</^@(-?([-A-Z_a-z�-ÿ]|\\[^\n\f\r])([-0-9A-Z_a-z�-ÿ]|\\[^\n\f\r])*)$/[1]>;
}
new CSSAtIdentifier({ value: `media` }) // `@media`
new CSSAtIdentifier({ value: `supports` }) // `@supports`The CSSDelimiter class represents boundaries in CSS. It extends CSSComponent.
{
value: string</^[\W\w]$/>;
}
new CSSDelimiter({ value: `@` }) // `@`
new CSSDelimiter({ value: `%` }) // `%`The CSSBlock class represents groupings of nodes delimited by brackets. It extends CSSComponent.
{
value: CSSNode[];
delimiter: CSSDelimiter<`` | `(` | `[` | `{`>;
}
new CSSBlock({
value: [
new CSSIdentifier({ value: `display` }),
new CSSDelimiter({ value: `:` }),
new CSSWhitespace({ value: ` ` }),
new CSSIdentifier({ value: `grid` })
],
delimiter: new CSSDelimiter({ value: `(` })
}) // `(display: grid)`
new CSSBlock({
value: [ new CSSIdentifier({ value: `class` }) ],
delimiter: new CSSDelimiter({ value: `[` })
}) // `[class]`The CSSFunction class represents groupings of nodes bound by specific references in CSS. It extends CSSBlock.
{
name: CSSIdentifier;
delimiter: CSSDelimiter<`(`>;
value: CSSNode[];
}
new CSSFunction({
name: new CSSIdentifier({ value: `var` }),
value: [
new CSSIdentifier({ value: `--color` }),
new CSSDelimiter({ value: `,` }),
new CSSWhitespace({ value: ` ` })
new CSSIdentifier({ value: `currentColor` })
]
}) // `var(--color, currentColor)`
new CSSFunction({
name: new CSSIdentifier({ value: `calc` }),
value: [
new CSSNumber({ value: `100`, unit: `%` }),
new CSSWhitespace({ value: ` ` }),
new CSSDelimiter({ value: `/` }),
new CSSWhitespace({ value: ` ` })
new CSSNumber({ value: `3`, unit: `` })
]
}) // `calc(100% / 3)`The CSSConstruct is the foundational class that canonical CSS objects extend from. It extends CSSNode and has no direct representation.
The CSSDeclaration class represents a configurable feature in CSS. It extends CSSConstruct.
{
name: CSSIdentifier;
value: CSSComponent[];
important: [
...( CSSWhitespace | CSSComment )[],
CSSDelimiter<`!`>,
CSSIdentifier<`important`>,
...( CSSWhitespace | CSSComment )[],
];
}
new CSSDeclaration({
name: new CSSIdentifier({ value: `color` }),
value: [ new CSSIdentifier({ value: `blue` }) ],
important: [
new CSSWhitespace({ value: ` ` }),
new CSSDelimiter({ value: `!` }),
new CSSIdentifier({ value: `important` })
]
}) // color: blue !importantThe CSSRule class represents a grouping of constructs bound by specific selectors or specific conditions in CSS. It extends CSSNode and has no direct representation.
The CSSStyleRule class represents a grouping of constructs bound by specific selectors in CSS. It extends CSSRule.
{
selectors: CSSSelector[];
value: ( CSSDeclaration | CSSRule )[];
}
new CSSStyleRule({
selectors: [
new CSSSelector({ value: `ul` })
],
value: [
new CSSDeclaration({
name: CSSIdentifier({ value: `list-style` }),
value: [ CSSWhitespace({ value: ` ` })]
})
]
})The CSSAtRule class represents groupings of constructs bound by references and specific conditions in CSS. It extends CSSRule.
{
name: CSSIdentifier;
prelude: CSSSelector[];
value: CSSConstruct[];
}
The CSSSheet class represents groupings of rules in CSS. It extends CSSConstruct.
{
value: ( CSSWhitespace | CSSComment | CSSRule )[];
}
The CSSSelector class represents conditions of elements in CSS. It extends CSSConstruct and has no direct representation.
The CSSSimpleSelector class represents a single condition of an element in CSS. It extends CSSSelector.
{
value: (
[ CSSDelimiter<`*`> ] |
[ CSSIdentifier ] |
[ CSSDelimiter<`#` | `.`>, CSSIdentifier ] |
[ CSSDelimiter<`:`>, ( CSSIdentifier | CSSFunction ) ] |
[ CSSDelimiter<`:`>, CSSDelimiter<`:`>, ( CSSIdentifier | CSSFunction ) ]
);
}
new CSSSimpleSelector({
value: [
new CSSDelimiter({ value: `*` })
]
}) // `*`
new CSSSimpleSelector({
value: [
new CSSIdentifier({ value: `div` })
]
}) // `div`
new CSSSimpleSelector({
value: [
new CSSDelimiter({ value: `:` }),
new CSSIdentifier({ value: `first-child` })
]
}) // `:first-child`The CSSCombinatorSelector class represents a relationship between elements in CSS. It extends CSSSelector.
{
value: [
...( CSSWhitespace | CSSComment )[],
( CSSWhitespace | CSSDelimiter<`>` | `+` | `~` | `||`> ),
...( CSSWhitespace | CSSComment )[],
];
}
new CSSCombinatorSelector({
value: [
new CSSWhitespace({ value: ` ` }),
new CSSDelimiter({ value: `>` }),
new CSSWhitespace({ value: ` ` })
]
}) // ` > `