JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4591
  • Score
    100M100P100Q13017F
  • License CC0-1.0

Use common font weights in your CSS

Package Exports

  • postcss-font-weights

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-font-weights) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Font Weights PostCSS Logo

NPM Version Build Status Licensing Changelog Gitter Chat

Font Weights lets you use common font weights in your CSS.

/* before */

.example-1 {
    font-weight: light;
}

.example-2 {
   font: light 100% monospace;
}

/* after */

.example-1 {
    font-weight: 300;
}

.example-2 {
   font: 300 100% monospace;
}

Common font weights are found in the [Font Weight Numeric Values] section of the [W3C CSS Fonts Specification].

Common Weight Numeric Value
thin 100
extralight 200
ultralight 200
light 300
book 400
normal 400
regular 400
roman 400
medium 500
semibold 600
demibold 600
bold 700
extrabold 800
ultrabold 800
black 900
heavy 900

These common font weights are converted to their numeric counterpart.

Options

prefix

Type: String
Default: ""

Adds an optional prefix to the color property (e.g. "x" for -x-color). Wrapping dashes (-) are automatically applied.

custom

Type: Object
Default: undefined

Adds an additional set of keyword and numeric pairs (e.g. custom: { lite: 300 } for font-weight: lite to become font-weight: 300).

Usage

Add Font Weights to your build tool:

npm install postcss-font-weights --save-dev

Node

require('postcss-font-weights').process(YOUR_CSS);

PostCSS

Add PostCSS to your build tool:

npm install postcss --save-dev

Load Font Weights as a PostCSS plugin:

postcss([
    require('postcss-font-weights')()
]).process(YOUR_CSS, /* options */);

Gulp

Add Gulp PostCSS to your build tool:

npm install gulp-postcss --save-dev

Enable Font Weights within your Gulpfile:

var postcss = require('gulp-postcss');

gulp.task('css', function () {
    return gulp.src('./src/*.css').pipe(
        postcss([
            require('postcss-font-weights')()
        ])
    ).pipe(
        gulp.dest('.')
    );
});

Grunt

Add Grunt PostCSS to your build tool:

npm install grunt-postcss --save-dev

Enable Font Weights within your Gruntfile:

grunt.loadNpmTasks('grunt-postcss');

grunt.initConfig({
    postcss: {
        options: {
            use: [
                require('postcss-font-weights')()
            ]
        },
        dist: {
            src: '*.css'
        }
    }
});