Skip to content

Instantly share code, notes, and snippets.

@paulozoom
Created May 30, 2016 14:38
Show Gist options
  • Save paulozoom/86fa348de1429559b1ea336eec30ad87 to your computer and use it in GitHub Desktop.
Save paulozoom/86fa348de1429559b1ea336eec30ad87 to your computer and use it in GitHub Desktop.
CSS font weight with names
/// Named Font Weights
///
/// @param {string} $name
/// the name of the weight, as such:
/// * thin
/// * extralight
/// * light
/// * book / regular
/// * medium
/// * semibold
/// * bold
/// * extrabold
/// * black
///
/// @return {Number}
///
/// @example scss
/// h1,h2,h3 {
/// font-weight: weight(medium);
/// }
///
/// @example css
/// h1,h2,h3 {
/// font-weight: 500;
/// }
@function weight($name) {
@if $name == thin { @return 100; }
@else if $name == extralight { @return 200; }
@else if $name == light { @return 300; }
@else if $name == book or $name == regular { @return 400; }
@else if $name == medium { @return 500; }
@else if $name == semibold { @return 600; }
@else if $name == bold { @return 700; }
@else if $name == extrabold { @return 800; }
@else if $name == black { @return 900; }
@return 400;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment