Socket
Socket
Sign inDemoInstall

@rsmdc/typography

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @rsmdc/typography

Typography classes, mixins, and variables for rsmdc.


Version published
Weekly downloads
12
decreased by-20%
Maintainers
1
Install size
23.0 kB
Created
Weekly downloads
 

Readme

Source

Typography

Material Design's text sizes and styles were developed to balance content density and reading comfort under typical usage conditions.

RS Typography is a foundational module that applies these styles to RS Web components. The typographic styles in this module are derived from thirteen styles:

  • Headline 1
  • Headline 2
  • Headline 3
  • Headline 4
  • Headline 5
  • Headline 6
  • Subtitle 1
  • Subtitle 2
  • Body 1
  • Body 2
  • Caption
  • Button
  • Overline

Design & API Documentation

  • Material Design guidelines: Typography
  • Demo

Installation

npm install ../typography

Basic Usage

HTML Structure

We recommend using Roboto from Google Fonts:

<head>
  <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
</head>
<body class="rs-typography">
  <h1 class="rs-typography--headline1">Big header</h1>
</body>

Styles

@import "../typography/rs-typography";

Style Customization

CSS Classes

Some components have a set typographic style. For example, a raised RS Card uses Body 1, Body 2, and Headline styles.

If you want to set the typographic style of an element, which is not a Material Design component, you can apply the following CSS classes.

CSS ClassDescription
rs-typographySets the font to Roboto
rs-typography--headline1Sets font properties as Headline 1
rs-typography--headline2Sets font properties as Headline 2
rs-typography--headline3Sets font properties as Headline 3
rs-typography--headline4Sets font properties as Headline 4
rs-typography--headline5Sets font properties as Headline 5
rs-typography--headline6Sets font properties as Headline 6
rs-typography--subtitle1Sets font properties as Subtitle 1
rs-typography--subtitle2Sets font properties as Subtitle 2
rs-typography--body1Sets font properties as Body 1
rs-typography--body2Sets font properties as Body 2
rs-typography--captionSets font properties as Caption
rs-typography--buttonSets font properties as Button
rs-typography--overlineSets font properties as Overline

Sass Variables and Mixins

MixinDescription
rs-typography-baseSets the font to Roboto
rs-typography($style)Applies one of the typography styles, including setting the font to Roboto
rs-typography-overflow-ellipsisTruncates overflow text to one line with an ellipsis
rs-typography-baseline-top($distance)Sets the baseline height of a text element from top.
rs-typography-baseline-bottom($distance)Sets the distance from text baseline to bottom. This mixin should be combined with rs-typography-baseline-top when setting baseline distance to following text element.

A note about rs-typography-overflow-ellipsis, rs-typography-overflow-ellipsis should only be used if the element is display: block or display: inline-block.

$style Values

These styles can be used as the $style argument for the rs-typography mixin.

  • headline1
  • headline2
  • headline3
  • headline4
  • headline5
  • headline6
  • subtitle1
  • subtitle2
  • body1
  • body2
  • caption
  • button
  • overline
Overriding Styles

All styles can be overridden using Sass global variables before the component is imported by setting a global variable named $rs-typography-styles-{style}. The variable should be assigned a map that contains all the properties you want to override for a particular style.

Example: Overriding the button font-size and text-transform properties.

$rs-typography-styles-button: (
  font-size: 16px,
  text-transform: none,
);

@import "../button/rs-button";

Example: Overriding the global font-family property.

$rs-typography-font-family: "Arial, Helvetica, sans-serif";

...
@import ...

Example: Overriding the font-family property for headline1 and font-family and font-size for headline2.

$rs-typography-styles-headline1: (
  font-family: unquote("Arial, Helvetica, sans-serif")
);
$rs-typography-styles-headline2: (
  font-family: unquote("Arial, Helvetica, sans-serif"),
  font-size: 3.25rem
);

...
@import ...

Keywords

FAQs

Last updated on 18 Jun 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