
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
responsive-modular-scale.css
Advanced tools
Responsive typography using CSS variables
This implements a basic Modular Scale system using CSS variables. Use this with postcss-cssnext and postcss-import.
# using Yarn
yarn add --exact responsive-modular-scale.css
# using npm
npm install --save --save-exact responsive-modular-scale.css
responsive-modular-scale.css can be used in 3 different ways:
postcss-extend-rule)See § Usage as functional selectors.
.title {
@extend %ms-font-size-2;
}
postcss-apply).title {
@apply --ms-font-size-2;
}
.title {
composes: msFontSize2 from 'responsive-modular-scale.css/modularscale.module.css';
}
To use it, use any of the provided --font-size-# custom property sets:
div {
@apply --font-size-4;
}
This applies a font-size: 2.0736rem declaration for desktops—the default ratio is 1.2, so that's 1rem * 1.2 ^ 4. For mobiles and tablets, it will use a different ratio (1.15 and 1.17 by default).
div {
font-size: 1.74901rem;
}
@media (min-width: 481px) {
div {
font-size: 1.87389rem;
}
}
@media (min-width: 769px) {
div {
font-size: 2.0736rem;
}
}
Set up a variables.css with your configuration. Consider placing this wherever you put your common variables (eg, color palettes and font names). See: defaults.css.
:root {
--ms-ratio-sm: 1.15;
--ms-ratio-md: 1.17;
--ms-ratio-lg: 1.2;
--ms-base: 1rem;
--ms-base-sm: var(--ms-base);
--ms-base-md: var(--ms-base-sm);
--ms-base-lg: var(--ms-base-md);
}
@custom-media --ms-viewport-md (width > 480px);
@custom-media --ms-viewport-lg (width > 768px);
To use this as functional selectors (ie, @extend), you'll need these PostCSS plugins:
Configure PostCSS to load these plugins and import your variables. Here's an example config:
/* postcss.config.js */
module.exports = ctx => {
return {
plugins: [
// ...
require('postcss-prepend-imports')({
files: [
require.resolve(
'responsive-modular-scale.css/responsive-modular-scale.css'
)
]
}),
require('postcss-extend-rule')(),
require('postcss-preset-env')({
importFrom: [require.resolve('./your/path/to/variables.css')]
})
// ...
]
}
}
You'll then be able to use them with @extend in your CSS.
.title {
@extend %ms-font-size-2;
}
These selectors will become available:
@extend %ms-font-size--1 (negative 1)@extend %ms-font-size-0 (applies the base font size)@extend %ms-font-size-1@extend %ms-font-size-2@extend %ms-font-size-20You can also apply modular scale font sizes using CSS property sets (aka, @apply). You'll need these PostCSS plugins:
Configure PostCSS to load these plugins and import your variables. Here's an example config:
/* postcss.config.js */
module.exports = ctx => {
return {
plugins: [
// ...
require('postcss-prepend-imports')({
files: [
require.resolve(
'responsive-modular-scale.css/responsive-modular-scale.css'
)
]
}),
require('postcss-extend-rule')(),
require('postcss-preset-env')({
importFrom: [require.resolve('./your/path/to/variables.css')]
})
// ...
]
}
}
You'll then be able to use them with @apply in your CSS.
.title {
@apply --ms-font-size-2;
}
These property sets will become available:
@apply --font-size--1 (negative 1)@apply --font-size-0 (applies the base font size)@apply --font-size-1@apply --font-size-2@apply --font-size-20:warning: Experimental - You can apply modular scale font sizes using CSS modules.
To use this as functional selectors (ie, @extend), you'll need these PostCSS plugins:
Configure PostCSS to load these plugins and import your variables. Here's an example config:
/* postcss.config.js */
module.exports = ctx => {
return {
plugins: [
// ...
require('postcss-preset-env')({
importFrom: [require.resolve('./your/path/to/variables.css')]
})
// ...
]
}
}
You'll then be able to use them with composes in your CSS.
.myButton {
composes: msFontSize2 from 'responsive-modular-scale.css/modularscale.module.css';
}
These CSS classes are available:
msFontSizeMinus1 (negative 1)msFontSize0 (applies the base font size)msFontSize1msFontSize2msFontSize20Learn more about the composes: property from the CSS modules documentation.
postcss-modular-scale is a PostCSS plugin. However, it doesn't support responsive ratios, and the syntax is non-standard CSS.
modularscale-sass is, in my opinion, the gold standard modular scale implementation. It only supports Sass, however.
responsive-modular-scale.css © 2019, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors (list).
ricostacruz.com · GitHub @rstacruz · Twitter @rstacruz
FAQs
Responsive typography using CSS variables
We found that responsive-modular-scale.css demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.