npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@salesforce-ux/sds-styling-hooks

v1.1.0-alpha.4

Published

Global Styling hooks use CSS custom properties which make it easy to customize application-wide styling.

Downloads

7,720

Readme

@salesforce-ux/sds-styling-hooks

About

Global Styling hooks use CSS custom properties which make it easy to customize application-wide styling.

Table of Contents

Relevant links (external)

Installation

Use npm to install the SDS Global Styling Hooks:

npm install --save-dev @salesforce-ux/sds-styling-hooks

Add SDS Global Hooks in HTML

You can use the HTML <link> to link to SDS Global Styling Hooks as an external resource.

<html>
  <head>
    <link rel="stylesheet" href="/node_modules/@salesforce-ux/sds-styling-hooks/dist/hooks.custom-props.css">
    <!-- Your application's stylesheets go below -->
    <link rel="stylesheet" href="...">
  </head>
  <body>
    <!-- Your application -->
  </body>
</html>

Add SDS Global Hooks in CSS

You can use CSS @imports to pull in SDS Global Styling Hooks.

:root {
  @import "@salesforce-ux/sds-styling-hooks/dist/hooks.custom-props.css";
}

body {
  /* Directly reference SDS Styling Hook */
  background: var(--sds-g-color-neutral-base-50);
}

File Formats

SDS Styling Hooks have 6 different file formats for consumption. All files are located in /dist/.

JSON (*.json)

{
  "PROP_NAME": "PROP_VALUE"
}

Raw JSON (*.raw.json)

{
  "props": {
    "PROP_NAME": {
      "value": "PROP_VALUE",
      "type": "PROP_TYPE",
      "category": "PROP_CATEGORY",
      /* additional metadata */
    }
  }
}

Common JS (*.js)

module.exports = {
  propName: "PROP_VALUE"
};

ES Module (*.js)

export const propName = "PROP_VALUE";

Custom Properties scoped to :root (*.css)

:root {
  --prop-name: PROP_VALUE;
}

Custom Property Registration using CSS Properties and Values API (*.js)

Experimental

This is an experimental technology

Check the Browser compatibility table carefully before using this in production.

For more information, see CSS Properties and Values API Level 1.

if (CSS.registerProperty) {
  CSS.registerProperty({
    name: "--prop-name",
    syntax: "PROP_SYNTAX",
    inherits: false,
    initialValue: "PROP_VALUE",
  });
}

Usage Guidelines

Color

The Salesforce Design System comes with a robust color system and relationships to ensure our UIs meet WCAG 2.1 contrast ratios of 4.5:1. The semantic relationships allow for easy theme switching to handle features such as dark mode or high contrast mode.

Additionally, we generate sets of vibrant color palettes to use as accents in your designs. These values are generated in the HCL color space, which are designed to accord with human perception of color.

Using Color Relationships for UIs

The Salesforce Design System offers a set of neutral and brand color relationships. These two sets are intended to be used on your UI elements to define properties such as backgrounds, borders and text.

Each set, neutral and brand, have 13 color values. The base group defaults to "light" UI elements.

View all system colors →

Neutral

--sds-g-color-neutral-base-100
--sds-g-color-neutral-base-95
--sds-g-color-neutral-base-90
--sds-g-color-neutral-base-80
--sds-g-color-neutral-base-70
--sds-g-color-neutral-base-65
--sds-g-color-neutral-base-60
--sds-g-color-neutral-base-50
--sds-g-color-neutral-base-40
--sds-g-color-neutral-base-30
--sds-g-color-neutral-base-20
--sds-g-color-neutral-base-15
--sds-g-color-neutral-base-10

Brand

--sds-g-color-brand-base-100
--sds-g-color-brand-base-95
--sds-g-color-brand-base-90
--sds-g-color-brand-base-80
--sds-g-color-brand-base-70
--sds-g-color-brand-base-65
--sds-g-color-brand-base-60
--sds-g-color-brand-base-50
--sds-g-color-brand-base-40
--sds-g-color-brand-base-30
--sds-g-color-brand-base-20
--sds-g-color-brand-base-15
--sds-g-color-brand-base-10

Golden Rule for Relationships

Regardless of the set, neutral or brand, there is a golden rule to ensure the color relationships are retained;

Each palette contains a relationship of base and contrasting values. Whatever is the predominate color accent you are trying to achieve WCAG 2.1 color contrast for, you will start in that color palette.

The color system is meant to provide valid color relationships for background to foreground color values. This includes text and non-text glyphs.

The green lines highlight the relationships that pass AAA color contrast requirements and the yellow lines are designated for AA.

If a design crosses into another color palette, it is up to the designer to find the corresponding color value that passes color contrast requirements.

An image showing the neutral color UI relationships

Reference Palettes

View all reference colors →

The Salesforce Design System provide reference color palettes to use in your designs. These values are generated in the HCL color space, which are designed to accord with human perception of color.

Important usage note

If you use a color from these palettes on a UI element, you are responsible to ensure proper contrast ratio between the background and text. Additionally, the color cannot be programmically alter if your application requires different themes such as dark mode or high contrast mode.

Typography

Font Family

View Font Families →

The Salesforce Design System defaults to use system fonts, this improves performance and legibility on the content based on the device being used. We provide two styling hooks for font families, one of the body text content and one for the heading text of your document.

Body Text Content

--sds-g-font-family

Heading Text Content

--sds-s-heading-font-family

Font Stack

font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';

Font Sizes

View Font Sizes →

The Salesforce Design System offers a robust palette of font sizes. Our font sizes are independent of semantics so they are intended to be used for visual hierarchy. The sizes are based off a major second scale, 8:9 scale ratio with the base font size starting at 1rem or 16px. The scale offers 10 font sizes larger than the base and 4 font sizes smaller than the base.