Socket
Socket
Sign inDemoInstall

postcss-fontstack

Package Overview
Dependencies
3
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-fontstack

easy insertion of font stacks into font-family declarations


Version published
Weekly downloads
5
increased by66.67%
Maintainers
1
Install size
1.30 MB
Created
Weekly downloads
 

Readme

Source

PostCSS Fontstack Build Status

Easy insertion of font stacks into font-family declarations

body {
  font-family: 'Open Sans', fontstack('Arial');
}

h2 {
  font-family: fontstack('');
}

/* results */
body {
  font-family: 'Open Sans', Arial, "Helvetica Neue", Helvetica, sans-serif;
}

h2 {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

Usage

Add PostCSS Fontstack in your project.

npm i postcss-fontstack -D

Use PostCSS Fontstack to process your CSS:

import FontStack from 'postcss-fontstack'

FontStack.process(YOUR_CSS /*, processOptions, pluginOptions */);

Or use it as a PostCSS Plugin:

import postcss from 'postcss';
import FontStack from 'postcss-fontstack';

postcss([
  FontStack(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);

PostCSS Stack runs with Webpack

Add PostCSS Loader to your project:

npm i postcss-loader -D

Use PostCSS Fontstack in your Webpack configuration:

const FontStack = require('postcss-fontstack');

module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'style-loader',
          { loader: 'css-loader', options: { importLoaders: 1 } },
          {
            loader: 'postcss-loader',
            options: {
              ident: 'postcss',
              plugins: [
                FontStack(/* pluginOptions */)
              ]
            }
          }
        ]
      }
    ]
  }
}

Options

fontstacks

You can custom the fontstacks by the fontstacks option.

FontStack({
  fontstacks: {
    'Tomo': '"Tomo Regular", Arial, sans-serif',
  }
})
body {
  font-family: fontstack('Tomo');
}

/* results */
body {
  font-family: 'Tomo Regular', Arial, sans-serif;
}

Misc

the default fontstacks

  default: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif',

  // Sans-serif
  'Arial': 'Arial, "Helvetica Neue", Helvetica, sans-serif',
  'Arial Black': '"Arial Black", "Arial Bold", Gadget, sans-serif',
  'Arial Narrow': '"Arial Narrow", Arial, sans-serif',
  'Gill Sans': '"Gill Sans", "Gill Sans MT", Calibri, sans-serif',
  'Tahoma': 'Tahoma, Verdana, Segoe, sans-serif',
  'Verdana': 'Verdana, Geneva, sans-serif',

  // Serif
  'Georgia': 'Georgia, Times, "Times New Roman", serif',
  'Palatino': 'Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif',
  'Times New Roman': 'TimesNewRoman, "Times New Roman", Times, Baskerville, Georgia, serif',

  // Monospaced
  'Courier New': '"Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace',
  'Lucida Sans Typewriter': '"Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace',

  // Fantasy
  'Copperplate': 'Copperplate, "Copperplate Gothic Light", fantasy',
  'Papyrus': 'Papyrus, fantasy',

  // Script
  'Brush Script MT': '"Brush Script MT", cursive'

Keywords

FAQs

Last updated on 26 May 2020

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc