🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More
Socket
Book a DemoInstallSign in
Socket

modular-scale-css

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

modular-scale-css

Easily customizable modular scale css custom properties (variables) in pure css.

Source
npmnpm
Version
0.0.4
Version published
Weekly downloads
23
109.09%
Maintainers
1
Weekly downloads
 
Created
Source

Modular Scale for CSS

Easily customizable modular scale css custom properties (variables) in pure CSS.

npm npm license

Installation

The easiest way is to grab it via npm or yarn and move/bundle the file in your build step.

npm i modular-scale-css --save

Usage

The default ratio is the golden-ration --golden and the default bases are 1em for the --ms/--msa values and 2.25em for the --msb values.

To change which ratio to use, or update the base simply add the following in your css:

--ms-ratio: var(--major-third);
--ms-base: 10px;

If you are using a double-stranded modular scale simple add an a and a b base.

--ms-ratio: var(--major-third);
--ms-base-a: 10px;
--ms-base-b: 20px;

Now you can use your scale anywhere in your css:

/* single scale */
p{
  font-size: var(--ms0);
  width: var(--ms10);
}
/* double stranded scale */
div{
  font-size: var(--ms_a0); /*use _ to separate the a and b scale*/
  width: var(--msb_10);
  margin: width: var(--ms_b-1); /*minus means a step down*/
}

Custom ratios

If you want to use a custom ratio, you can simply add it as the --ms-ratio value.

--ms-ratio: calc(3/5);

Modular Scale

A modular scale is a measurement system that provides a set of numbers which you can use for your font-sizes, element sizes or negative space. Since it is based on an underlying ration, all numbers in your system are multiples of this ratio and your base, which makes them naturally fit together thus creating a more harmonies layout.

What base should I choose?

A good start is your body text type size. You could also use other font metrics like x-height or an important fixed-width like a sidebar or a major element.

Which ratio is good?

This package includes many ratios from the visual arts, mathematics and music. If you have no reason to favor any of the provided, you can just try some ratios and see which values work best for your design.

To learn more about modular scales, visit modularscale.com.

Included ratios

Below you find a list of the included ratios. The first column is the CSS custom property used to specify the ratio in your css. See usage.

CSS custom property (variable)RatioValue
--minor-second15:161.067
--major-second8:91.125
--minor-third5:61.2
--major-third4:51.25
--fourth3:41.333
--augmented-fourth1:√21.414
--fifth2:31.5
--minor-sixth5:81.6
--phi1:1.6181.618
--golden1:1.6181.618
--major-sixth3:51.667
--minor-seventh9:161.778
--major-seventh8:151.875
--octave1:22
--major-tenth2:52.5
--major-eleventh3:82.667
--major-twelfth1:33
--double-octave1:44

Keywords

css

FAQs

Package last updated on 19 Feb 2017

Did you know?

Socket

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.

Install

Related posts