Skip to content

MadsHornbeck/fluid-typography

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@hornbeck/fluid-typography

npm npm npm npm bundle size npm bundle size

Simple configurable fluid typography and dynamic modular font scale in pure css.

Install

npm install --save @hornbeck/fluid-typography

Example

Usage

Import the stylesheet in your solution.

import "@hornbeck/fluid-typography";

Change base configuation variables if needed:

:root {
  /* Point where the smallest font size and scale should be used */
  --ft-width-min: 24; /* em */
  /* Point where the largest font size and scale should be used */
  --ft-width-max: 90; /* em */
  /* Minimum font size on the :root element, in rem */
  --ft-font-min: 1; /* rem */
  /* Maximum font size on the :root element, in rem */
  --ft-font-max: 1.5; /* rem */
  /* The modular scale used at the smallest point */
  --ft-ratio-min: 1.125;
  /* The modular scale used at the largest point */
  --ft-ratio-max: 1.25;
}

Use the fluid sizes in your css for e.g. your font-size or margin:

p {
  font-size: var(--fluid-0);
}

h6 {
  font-size: var(--fluid-1);
}

h5 {
  font-size: var(--fluid-2);
}

h4 {
  font-size: var(--fluid-3);
}

h3 {
  font-size: var(--fluid-4);
}

h2 {
  font-size: var(--fluid-5);
}

h1 {
  font-size: var(--fluid-6);
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages