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

@ni/nimble-tokens

v8.5.0

Published

Design tokens for the NI Nimble Design System

Downloads

929

Readme

Nimble Tokens

NPM Version

NI base design tokens. Design tokens are primitive elements of component style like color, typography, and spacing. These should generally not be consumed directly by applications. See below for guidance.

Getting Started

If you are using one of the following frameworks you should consume tokens via components implemented in the following libraries. These libraries provide styled components that use the design tokens to implement several color themes.

  1. Angular: See the nimble-angular documentation.
  2. Blazor WebAssembly or Blazor Server: See the nimble-blazor documentation.
  3. Vanilla / Frameworkless: See the nimble-components documentation.

Using Theme-Aware Tokens

The above libraries also offer a theming system which is independent of other components from the library. Adopting this theming system can be a cheaper way to update a legacy application to approximate the NI brand without the development and testing burden of adopting a new component library.

Applications should typically use this theming system rather than depending on nimble-tokens directly. See the theming documentation in nimble-components for more information.

Using Nimble Base Tokens Directly

In limited special cases, you may consume base Nimble tokens directly. This is only recommended in cases where the theme-aware tokens don't work (for example desktop applications or legacy browsers that don't support custom elements) as these tokens are unaware of themes and don't contain guidance mapping them to specific component parts.

To add the Nimble tokens package to your application, install it from the public NPM registry by running npm install @ni/nimble-tokens.

Understanding Base Color Tokens

You can view the available color tokens here. To understand their meaning, explore other pages of the document in Specs Mode (click the </> icon on the right side) and view how color tokens are applied to Nimble components.

Using Base Tokens

The tokens are available in several formats:

CSS and SCSS variables

Tokens like colors, font families, and spacing are available as CSS and SCSS variables.

  1. Assuming your application uses the Webpack css-loader, in your application CSS, add @import url('@ni/nimble-tokens/dist/styledictionary/css/variables.css'); (replacing css with scss as needed).
  2. Use the variables from that file to style your UI:
body { background-color: var(--ni-nimble-base-white); }

JavaScript and TypeScript

Tokens like colors, font families, and spacing are also available as JavaScript and TypeScript string constants.

  • colors are represented as hex RGB strings like: #ff8126
  • font families and fallbacks are represented as comma separated strings like: Roboto, Microsoft YaHei, Hiragino Kaku Gothic Pro, sans-serif
  • spacing is represented in CSS units like: 12px

In your application JavaScript or TypeScript code, import the token strings you want to use:

import { White } from '@ni/nimble-tokens/dist/styledictionary/js/tokens';

Icons

Icons are included in the nimble-tokens package, but (like tokens) icons should primarily consumed through framework-specific components.

Font Faces

Nimble provides font definitions for every font family used by a token. To ensure these fonts are available to your application, include @ni/nimble-tokens/dist/fonts/css/fonts.css in your application code.

Contributing

Follow the instructions in CONTRIBUTING.md to modify this library.