Customization

Syntaxes

A guide to customizing declarations, selectors, functions, and at-rules in syntax.

🚧This page is still under construction and some content may not be complete.

Syntaxes

Customize your own Master CSS syntax rules.

export default {
syntaxes: {
foo: {
matcher: /^foo:./,
unit: 'rem',
declare(value, unit) {
return {
width: value + unit
}
}
}
}
}

Use your custom syntax:

<div class="foo:32"></div>

Generated CSS:

.foo\:32 {
width: 2rem;
}
View the default syntaxes
NameUnitVariables
group--
variable--
font-sizerem-
font-weight--
font-family--
font-smoothing--
font-styledeg-
font-variant-numeric--
font-variant--
font-["font-family", "font-variant", "font-weight", "font-size", "font-style", "line-height"]
font-feature-settings--
color-["text"]
margin-leftrem["spacing"]
margin-rightrem["spacing"]
margin-toprem["spacing"]
margin-bottomrem["spacing"]
margin-xrem["spacing"]
margin-yrem["spacing"]
marginrem["spacing"]
margin-inline-startrem["spacing"]
margin-inline-endrem["spacing"]
margin-inlinerem["spacing"]
padding-leftrem["spacing"]
padding-rightrem["spacing"]
padding-toprem["spacing"]
padding-bottomrem["spacing"]
padding-xrem["spacing"]
padding-yrem["spacing"]
paddingrem["spacing"]
padding-inline-startrem["spacing"]
padding-inline-endrem["spacing"]
padding-inlinerem["spacing"]
flex-basisrem-
flex-wrap--
flex-grow--
flex-shrink--
flex-direction--
flex--
display--
widthrem-
heightrem-
min-widthrem-
min-heightrem-
sizerem-
min-sizerem-
max-sizerem-
box-sizing--
box-decoration-break--
contain--
content--
counter-increment--
counter-reset--
letter-spacingem-
line-height--
object-fit--
object-position--
text-align--
text-decoration-color-["text"]
text-decoration-style--
text-decoration-thicknessem-
text-decoration-line--
text-decorationrem["text"]
text-underline-offsetrem["spacing"]
text-underline-position--
text-overflow--
text-orientation--
text-transform--
text-rendering--
text-wrap--
text-indentrem-
vertical-align--
columns--
white-space--
toprem["spacing"]
bottomrem["spacing"]
leftrem["spacing"]
rightrem["spacing"]
insetrem["spacing"]
max-heightrem-
max-widthrem-
opacity--
visibility--
clear--
float--
isolation--
overflow-x--
overflow-y--
overflow--
overscroll-behavior-x--
overscroll-behavior-y--
overscroll-behavior--
z-index--
position--
cursor--
pointer-events--
resize--
touch-action--
word-break--
word-spacingem-
user-drag--
user-select--
text-shadowrem-
text-sizerem-
text-fill-color-["text"]
text-stroke-widthrem-
text-stroke-color--
text-strokerem-
text-truncate--
box-shadowrem-
table-layout--
transform-box--
transform-style--
transform-originpx-
transformpx["spacing"]
transition-property--
transition-timing-function--
transition-durationms-
transition-delayms-
transition--
animation-delayms-
animation-direction--
animation-durationms-
animation-fill-mode--
animation-iteration-count--
animation-name--
animation-play-state--
animation-timing-function--
animation--
border-collapse--
border-spacingrem["spacing"]
border-top-color-["frame"]
border-bottom-color-["frame"]
border-left-color-["frame"]
border-right-color-["frame"]
border-x-color-["frame"]
border-y-color-["frame"]
border-color-["frame"]
border-top-left-radiusrem-
border-top-right-radiusrem-
border-bottom-left-radiusrem-
border-bottom-right-radiusrem-
border-top-radiusrem-
border-bottom-radiusrem-
border-left-radiusrem-
border-right-radiusrem-
border-radiusrem-
border-top-style--
border-bottom-style--
border-left-style--
border-right-style--
border-x-style--
border-y-style--
border-style--
border-top-widthrem-
border-bottom-widthrem-
border-left-widthrem-
border-right-widthrem-
border-x-widthrem-
border-y-widthrem-
border-widthrem-
border-image-repeat--
border-image-slice--
border-image-source--
border-image-widthrem-
border-image-outsetrem-
border-image--
border-toprem["frame"]
border-bottomrem["frame"]
border-leftrem["frame"]
border-rightrem["frame"]
border-xrem["frame"]
border-yrem["frame"]
borderrem["frame"]
background-attachment--
background-blend-mode--
background-color--
background-clip--
background-origin--
background-positionpx-
background-repeat--
background-sizerem-
background-image--
background--
gradient--
mix-blend-mode--
backdrop-filter--
filter--
fill--
stroke-dasharray--
stroke-dashoffset-["spacing"]
stroke-width--
stroke--
x-["spacing"]
y-["spacing"]
cx-["spacing"]
cy-["spacing"]
rx--
ry--
grid-column-start--
grid-column-end--
grid-column-span--
grid-column--
grid-columns--
grid-row-start--
grid-row-end--
grid-row-span--
grid-row--
grid-rows--
grid-auto-columns--
grid-auto-flow--
grid-auto-rows--
grid-template-areas--
grid-template-columnsrem-
grid-template-rowsrem-
grid-template--
grid-area--
grid--
column-gaprem["spacing"]
row-gaprem["spacing"]
gaprem["spacing"]
order--
break-inside--
break-before--
break-after--
aspect-ratio--
column-span--
align-content--
align-items--
align-self--
justify-content--
justify-items--
justify-self--
place-content--
place-items--
place-self--
list-style-position--
list-style-type--
list-style-image--
list-style--
outline-color-["frame"]
outline-offsetrem["spacing"]
outline-style--
outline-widthrem-
outlinerem["outline-width", "outline-style", "outline-offset", "outline-color", "frame"]
accent-color--
appearance--
caret-color-["text"]
scroll-behavior--
scroll-margin-leftrem["spacing"]
scroll-margin-rightrem["spacing"]
scroll-margin-toprem["spacing"]
scroll-margin-bottomrem["spacing"]
scroll-margin-xrem["spacing"]
scroll-margin-yrem["spacing"]
scroll-marginrem["spacing"]
scroll-padding-leftrem["spacing"]
scroll-padding-rightrem["spacing"]
scroll-padding-toprem["spacing"]
scroll-padding-bottomrem["spacing"]
scroll-padding-xrem["spacing"]
scroll-padding-yrem["spacing"]
scroll-paddingrem["spacing"]
scroll-snap-align--
scroll-snap-stop--
scroll-snap-type--
will-change--
writing-mode--
direction--
shape-outside--
shape-marginrem["spacing"]
shape-image-threshold--
clip-path--
quotes--
mask-image--

Selectors

By tokenizing selectors, you can simplify your markup.

export default {
selectors: {
_headings: '_:where(h1,h2,h3,h4,h5,h6)'
}
}

Simplify your existing markup in HTML:

<article class="font:bold_:where(h1,h2,h3,h4,h5,h6)"></article>
<article class="font:bold_headings"></article>
View the default selectors
NameReplace with
::scrollbar"::-webkit-scrollbar"
::scrollbar-button"::-webkit-scrollbar-button"
::scrollbar-thumb"::-webkit-scrollbar-thumb"
::scrollbar-track"::-webkit-scrollbar-track"
::scrollbar-track-piece"::-webkit-scrollbar-track-piece"
::scrollbar-corner"::-webkit-scrollbar-corner"
::slider-thumb["::-webkit-slider-thumb", "::-moz-range-thumb"]
::slider-runnable-track["::-webkit-slider-runnable-track", "::-moz-range-track"]
::resizer"::-webkit-resizer"
::progress"::-webkit-progress"
:first":first-child"
:last":last-child"
:even":nth-child(2n)"
:odd":nth-child(odd)"
:nth(":nth-child("
:only":only-child"

Functions

Customize the behavior and rules of functions.

export default {
functions: {
translate: { unit: 'rem' }
}
}

Apply your custom functions:

<div class="translate(2rem)"></div>
<div class="translate(32)"></div>
View the default functions
NameUnitNative Name
$()-$
calc()-calc
translate()remtranslate
translateX()remtranslateX
translateY()remtranslateY
translateZ()remtranslateZ
translate3d()remtranslate3d
skew()degskew
skewX()degskewX
skewY()degskewY
skewZ()degskewZ
skew3d()degskew3d
rotate()degrotate
rotateX()degrotateX
rotateY()degrotateY
rotateZ()degrotateZ
rotate3d()degrotate3d
blur()remblur
drop-shadow()remdrop-shadow
hue-rotate()deghue-rotate
rgb()-rgb
rgba()-rgba
hsl()-hsl
hsla()-hsla
color()-color
color-contrast()-color-contrast
color-mix()-color-mix
hwb()-hwb
lab()-lab
lch()-lch
oklab()-oklab
oklch()-oklch
light-dark()-light-dark
clamp()-clamp
repeat()-repeat
linear-gradient()-linear-gradient
radial-gradient()-radial-gradient
conic-gradient()-conic-gradient
repeating-linear-gradient()-repeating-linear-gradient
repeating-radial-gradient()-repeating-radial-gradient
repeating-conic-gradient()-repeating-conic-gradient
matrix()-matrix
matrix3d()-matrix3d
scale()-scale
scale3d()-scale3d
scaleX()-scaleX
scaleY()-scaleY
scaleZ()-scaleZ

At-rules

In native CSS, it's not possible to reuse queries through CSS variables. By tokenizing media queries, feature queries, container queries, and even responsive breakpoints, and applying them with flexible syntax within the markup.

export default {
at: {
landscape: 'media (orientation:landscape)' // @landscape
}
}

You wouldn't want to write full media queries within the markup.

<div class="aspect:2/1@media(orientation:landscape)"></div>

Employ concise yet semantically meaningful markup.

<img class="aspect:2/1@landscape" />
Generated CSS
@media (orientation:landscape) {
.aspect\:2\/1\@landscape {
aspect-ratio: 2/1
}
}
View the default at-rules
NameValue
all"media all"
print"media print"
screen"media screen"
speech"media speech"
landscape"media (orientation:landscape)"
portrait"media (orientation:portrait)"
motion"media (prefers-reduced-motion:no-preference)"
reduced-motion"media (prefers-reduced-motion:reduce)"

Add a media query

Create a media query token, such as @landscape, to represent landscape orientation.

export default {
at: {
landscape: 'media (orientation:landscape)' // @landscape
}
}

When displayed in landscape orientation, the image is presented in a 2:1 aspect ratio.

<img class="aspect:2/1@landscape" />
Generated CSS
@media (orientation:landscape) {
.aspect\:2\/1\@landscape {
aspect-ratio: 2/1
}
}

The landscape is the default token.

Add a feature query

Create a feature query token, such as @support-backdrop, to apply styles based on backdrop-filter support.

export default {
at: {
support: {
backdrop: 'supports (backdrop-filter:blur(0px))' // @support-backdrop
}
}
}

Applies translucent background only when backdrop-filter is supported.

<div class="bg:white/.8@support-backdrop"></div>
Generated CSS
@supports (backdrop-filter:blur(0px)) {
.bg\:white\/\.8\@support-backdrop {
background-color: rgb(255 255 255/.8)
}
}

Future

Getting Started
Introduction to Master CSS

The CSS language and framework for rapidly building modern and high-performance websites.

© Aoyue Design LLC.