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

@18f/identity-design-system

v9.4.0

Published

The global style of Login.gov

Downloads

10,132

Readme

Login.gov Design System

The Login.gov Design System is an extension of the U.S. Web Design System used on Login.gov sites to consistently identify the Login.gov brand.

This documentation describes how to use the Login.gov Design System in a new project. Read CONTRIBUTING.md to learn more about contributing to the design system itself.

Installation

Node.js is required to use the Login.gov Design System. You should install this first if it's not already available.

Next, install the package using NPM from your project's directory:

npm install @18f/identity-design-system

Usage

As an extension of the U.S. Web Design System (USWDS), the Getting started for developers guide can be a useful resource. The Login.gov Design System aims to be a drop-in replacement for the USWDS, so that all of its documentation would apply for the Login.gov Design System. The only change you're required to make is to update any references of @uswds/uswds with @18f/identity-design-system.

Styles

The Login.gov Design System uses Sass to generate stylesheets. While you can use any Sass compilation process, we recommend @18f/identity-build-sass, since it supports any environment where Node.js is already available, and it comes prebundled with default behaviors which are well-suited for the design system.

Here's an example stylesheet that imports the design system:

@use 'uswds-core';
@forward 'uswds';

The only requirements for Sass compilation are:

  • Your Sass load paths must include node_modules/@18f/identity-design-system/packages
  • You must be using the Dart Sass implementation of Sass

If you're using @18f/identity-build-sass, the following command will compile a CSS file to build/styles.css:

npx build-sass path/to/styles.css.scss --out-dir=build

Browser-Ready CSS Bundles

While it's recommended to import the Login.gov Design System as a Sass module to support optimization options, a precompiled CSS bundle is made available for convenience or for projects where it's not possible to include a Sass build process.

These files are found within dist/assets/css of the published NPM package. When installed locally, this is found at node_modules/@18f/identity-design-system.

<html>
  <head>
    <!-- ... -->
    <link rel="stylesheet" href="/path/to/identity-design-system/dist/assets/css/styles.css">
  </head>
  <body>
    <!-- ... -->
  </body>
</html>

JavaScript

As an NPM package, you can import the Login.gov Design System anywhere in your projects imports:

import '@18f/identity-design-system';

By default, this will include JavaScript for every component, which can increase load times for users and build times for developers. Refer to the Options section below to learn how to optimize JavaScript imports.

Browser-Ready JavaScript Bundles

While it's recommended to import the Login.gov Design System as an NPM package to support optimization options, a precompiled JavaScript bundle is made available for convenience or for projects where it's not possible to include a JavaScript build process.

These files are found within dist/assets/js of the published NPM package. When installed locally, this is found at node_modules/@18f/identity-design-system.

<html>
  <head>
    <!-- ... -->
    <script src="/path/to/identity-design-system/dist/assets/js/init.js"></script>
  </head>
  <body>
    <!-- ... -->
    <script src="/path/to/identity-design-system/dist/assets/js/main.js"></script>
  </body>
</html>

Options

Optimization

If your project is not using every component of the design system, it is recommended that you optimize your build by cherry-picking the individual components that you are using.

In Sass, you can do this by replacing the forwarded 'uswds' module with the packages of the individual components:

@use 'uswds-core';
- @forward 'uswds';
+ @forward 'usa-accordion';

You can find the package name on each component's documentation (e.g. Accordion → Package).

In JavaScript, you can import named members of the JavaScript package. If you are using a bundler which supports dead code elimination, any unused components will be removed from the compiled output. Each named import includes a on method to initialize the component on the page.

- import '@18f/identity-design-system';
+ import { accordion } from '@18f/identity-design-system';
+ accordion.on();

Theme Variables

The Login.gov Design System configures USWDS theme variables to provide defaults designed to be used across all Login.gov sites. These should almost always work well out-of-the-box, and not require further configuration.

If needed, you can extend these using the documented process for configuring settings, providing variables when importing the uswds-core package:

- @use 'uswds-core';
+ @use 'uswds-core' with (
+   $theme-body-font-size: 'sm'
+ );

License

See LICENSE for licensing information.