Version: 1.0.0
This document defines the schema for YCSS YAML files, including validation rules, required properties, and formatting standards.
The root of a YCSS file must contain at least one of these sections:
tokens: Design token definitionscomponents: Component style definitions
Optional fields:
version: Schema version in formatmajor.minor.patch
Example:
version: 1.0.0
tokens:
# Token definitions
components:
# Component definitionsTokens must be defined as key-value pairs where:
- Keys must be kebab-case and start with a letter
- Values must conform to their inferred type
Example:
tokens:
color-primary: "#1f2937"
spacing-lg: "2rem"
font-size-base: "16px"The type of a token is inferred from its prefix:
-
Color Tokens (prefix:
color-)- Valid formats:
- Hex:
#RGBor#RRGGBB - RGB:
rgb(R, G, B)
- Hex:
- Example:
color-primary: "#1f2937"
- Valid formats:
-
Spacing Tokens (prefix:
spacing-)- Valid units: px, rem, em
- Example:
spacing-lg: "2rem"
-
Typography Tokens (prefix:
font-)- Size: Must include unit (px, rem, em)
- Weight: Must be "normal", "bold", or 100-900
- Example:
font-size-lg: "18px"
-
Border Tokens (prefix:
border-)- Format:
<width> <style> <color> - Example:
border-default: "1px solid #000"
- Format:
Components must have:
- A valid component name (kebab-case)
- A
stylessection - Optional
classname - Optional
variantssection
Example:
components:
button:
class: button
styles:
- background-color: "#000"
- padding: "1rem"
variants:
primary:
class: button--primary
styles:
- background-color: "#007bff"Class names must follow either:
- Kebab-case:
my-component - BEM format:
- Block:
block - Element:
block__element - Modifier:
block--modifierorblock__element--modifier
- Block:
Some components have required properties that must be present in their styles:
Required:
background-colorpadding
Recommended:
border-radiusfont-weight
Required:
borderpadding
Recommended:
border-radiuswidth
Required:
paddingbackground-color
Recommended:
border-radiusbox-shadow
Required:
positionbackground-color
Recommended:
widthheightz-index
Required:
display: gridgrid-template-columns
Recommended:
gapwidth
Required:
display: flexflex-direction
Recommended:
justify-contentalign-items
The following CSS properties are validated:
colorbackground-color
# Valid formats
color: "#123456"
color: "#123"
color: "rgb(255, 128, 0)"
color: "var(--color-token)"marginpadding
# Valid formats
margin: "16px"
margin: "1rem"
margin: "1.5em"
margin: "10%"
margin: "var(--spacing-token)"widthheight
# Valid formats
width: "100px"
width: "50%"
width: "100vw"
width: "auto"
width: "var(--width-token)"font-sizefont-weightline-height
# Valid formats
font-size: "16px"
font-weight: "bold"
font-weight: "400"
line-height: "1.5"borderborder-radius
# Valid formats
border: "1px solid #000"
border-radius: "4px"display
# Valid values
display: "block"
display: "inline"
display: "flex"
display: "grid"
display: "none"position
# Valid values
position: "static"
position: "relative"
position: "absolute"
position: "fixed"
position: "sticky"flex-directionjustify-contentalign-items
# Valid values
flex-direction: "row"
flex-direction: "column"
justify-content: "center"
justify-content: "space-between"
align-items: "center"grid-template-columnsgap
# Valid formats
grid-template-columns: "1fr 1fr 1fr"
grid-template-columns: "repeat(3, 1fr)"
gap: "16px"Variants extend or modify base components:
- Must have a valid kebab-case name
- Must include
classname (typically BEM modifier) - Must include
stylessection - Inherit validation rules from parent component
Example:
components:
button:
class: button
styles:
- background-color: "#000"
variants:
primary:
class: button--primary
styles:
- background-color: "#007bff"
outline:
class: button--outline
styles:
- background-color: "transparent"
- border: "1px solid #000"Validation issues are reported with:
- Path to the problematic node
- Descriptive error message
- Severity level (ERROR or WARNING)
Example output:
ERROR components.button: Required property 'background-color' is missing
WARNING components.card: Recommended property 'border-radius' is missing
ERROR tokens.123-invalid: Token name must be kebab-case and start with a letter
-
Token Usage
- Prefer using design tokens via
var(--token-name)over hard-coded values - Follow token naming conventions for better maintainability
- Prefer using design tokens via
-
Component Organization
- Group related components together
- Use consistent naming patterns
- Document component relationships
-
Style Structure
- Order properties logically (layout → box model → visual)
- Keep styles focused and minimal
- Use variants for variations rather than new components
-
Validation
- Run validation before committing changes
- Address all errors and review warnings
- Keep component styles conforming to their required properties