### Install Dependencies
Source: https://github.com/uswds/uswds-site/wiki/Contrast-checker-instructions
Run this command if pulling down the project for the first time to install necessary dependencies.
```bash
npm install
```
--------------------------------
### Set up USWDS Development Environment with Fractal
Source: https://github.com/uswds/uswds-site/blob/main/_posts/2017-04-26-fractal-federalist.md
Clone the USWDS repository, install dependencies, and start the development server to use Fractal for component development and testing.
```sh
git clone https://github.com/uswds/uswds.git
cd web-design-standards
npm install
npm start
```
--------------------------------
### Install USWDS Dependencies and Build
Source: https://github.com/uswds/uswds-site/blob/main/README.md
Navigate into the cloned USWDS directory, install its dependencies, and build the project.
```sh
cd uswds
npm install
npm run build
```
--------------------------------
### Start USWDS Development Server and Watch
Source: https://github.com/uswds/uswds-site/blob/main/README.md
Start the USWDS documentation site development server and enable watching for changes.
```sh
npm run serve
npm run watch
```
--------------------------------
### Install USWDS and Compile Tool
Source: https://context7.com/uswds/uswds-site/llms.txt
Install USWDS and the compile tool using npm. Pin USWDS to an exact version for controlled updates.
```bash
# Step 1: Initialize your project
npm init
# Step 2: Install USWDS (pinned to exact version)
npm install @uswds/uswds --save-exact
# Step 3: Install the compile tool
npm install @uswds/compile --save-dev
# After install, USWDS source is at:
# ./node_modules/@uswds/uswds
```
--------------------------------
### Start Local Development Server
Source: https://github.com/uswds/uswds-site/blob/main/README.md
Start the local development server for the USWDS documentation website.
```sh
npm start
```
--------------------------------
### Install Project Dependencies
Source: https://github.com/uswds/uswds-site/blob/main/README.md
Install both npm and Ruby (Bundler) dependencies for the project.
```sh
npm install
bundle install
```
--------------------------------
### Install uswds-compile
Source: https://github.com/uswds/uswds-site/blob/main/pages/documentation/getting-started-developers/phase-two.md
Install the uswds-compile package as a development dependency in your project.
```bash
npm install @uswds/compile --save-dev
```
--------------------------------
### Install USWDS with npm
Source: https://github.com/uswds/uswds-site/blob/main/pages/documentation/getting-started-developers/phase-one.md
Install the USWDS package and save it as an exact dependency in your `package.json` file. This command also handles the installation of all necessary dependencies for USWDS.
```bash
npm install @uswds/uswds --save-exact
# [a lot of notices]
# + uswds@{{ site.uswds_version }} [or another version number]
```
--------------------------------
### USWDS Installation and Initialization
Source: https://context7.com/uswds/uswds-site/llms.txt
This bash script demonstrates the practical adoption path for USWDS, including installation via npm, initialization using gulp, and basic steps for integrating CSS and JavaScript into an HTML project.
```bash
# Practical adoption path
# 1. Install
npm install @uswds/uswds --save-exact
npm install @uswds/compile --save-dev
# 2. Initialize (copies assets, creates Sass entry point, compiles CSS)
npx gulp init
# 3. Add CSS and JS to your HTML
and before
#
#
# 4. Copy component HTML from designsystem.digital.gov/components/
# 5. Customize settings in _uswds-theme.scss
```
--------------------------------
### Install gulp-sass and sass-embedded
Source: https://github.com/uswds/uswds-site/blob/main/pages/documentation/migration-V3.md
Install the recommended Sass compilers for a faster Gulp workflow. Use the `--s` flag for saving to package.json.
```bash
npm install gulp-sass sass-embedded –s
```
--------------------------------
### Project Theme Settings Example (SCSS)
Source: https://github.com/uswds/uswds-site/blob/main/pages/documentation/migration-V3.md
Example of a project-specific SCSS theme settings file. This file consolidates all your custom USWDS theme configurations.
```scss
$theme-image-path: "../uswds/img";
$theme-font-path: "../uswds/fonts";
$theme-show-compile-warnings: false;
$theme-show-notifications: false;
$theme-focus-color: "blue-50v";
$theme-global-paragraph-styles: true;
$theme-global-link-styles: true;
$theme-global-content-styles: true;
$theme-utility-breakpoints: (
"card": false,
"card-lg": true,
"mobile": true,
"mobile-lg": true,
"tablet": true,
"tablet-lg": true,
"desktop": true,
"desktop-lg": true,
"widescreen": true
);
```
--------------------------------
### Stacked Columns at Narrow Widths
Source: https://github.com/uswds/uswds-site/blob/main/_utilities/layout-grid.md
Use responsive prefixes like `tablet:` to create columns that stack at narrower widths and display as columns at the specified breakpoint and wider. For example, `tablet:grid-col-*` creates columns starting at the tablet breakpoint.
```html
.tablet:grid-col
.tablet:grid-col
.tablet:grid-col
.tablet:grid-col-4
.tablet:grid-col-8
```
--------------------------------
### Install USWDS 3.0 Package
Source: https://github.com/uswds/uswds-site/blob/main/pages/documentation/migration-V3.md
Use npm to install the new USWDS 3.0 package. Ensure you use `--save-exact` to pin the version.
```bash
npm install @uswds/uswds --save-exact
```
--------------------------------
### Flex alignment examples
Source: https://github.com/uswds/uswds-site/blob/main/_utilities/flex.md
Demonstrates various flex container alignments.
```html
```
--------------------------------
### Font Scale Examples
Source: https://github.com/uswds/uswds-site/blob/main/pages/design-tokens/typesetting/font.md
Demonstrates the application of various font size utility classes from the USWDS theme and system scales. Each example shows the token name, system scale step, pixel value, and the resulting text with its corresponding utility class.
```html
Tallahassee
```
```html
Tallahassee
```
```html
Tallahassee
```
```html
Tallahassee
```
```html
Tallahassee
```
```html
Tallahassee
```
```html
Tallahassee
```
```html
Tallahassee
```
```html
Utica
```
--------------------------------
### Sticky Header Table Example
Source: https://github.com/uswds/uswds-site/blob/main/_components/table/07-stickyheader-table.md
This is a basic example of a table with a sticky header. Ensure the table has the `usa-table--sticky-header` class applied.
```html
Column one
Column two
Column three
Data 1.1
Data 1.2
Data 1.3
Data 2.1
Data 2.2
Data 2.3
Data 3.1
Data 3.2
Data 3.3
Data 4.1
Data 4.2
Data 4.3
Data 5.1
Data 5.2
Data 5.3
Data 6.1
Data 6.2
Data 6.3
Data 7.1
Data 7.2
Data 7.3
Data 8.1
Data 8.2
Data 8.3
Data 9.1
Data 9.2
Data 9.3
Data 10.1
Data 10.2
Data 10.3
```
--------------------------------
### Install USWDS with Exact Version
Source: https://github.com/uswds/uswds-site/blob/main/pages/documentation/getting-started-developers/phase-one.md
Use the `--save-exact` flag with npm to install USWDS and pin it to the exact version specified in your package.json. This prevents unexpected updates from breaking your project.
```bash
npm install --save-exact @uswds/uswds
```
--------------------------------
### Borderless Table Example
Source: https://github.com/uswds/uswds-site/blob/main/_components/table/03-borderless-table.md
This is a basic example of a borderless table. It's useful when you want the information to feel more a part of the text it accompanies and extends.
```html
Header 1
Header 2
Header 3
Data 1.1
Data 1.2
Data 1.3
Data 2.1
Data 2.2
Data 2.3
Data 3.1
Data 3.2
Data 3.3
```
--------------------------------
### USWDS Basic Header Component Example
Source: https://context7.com/uswds/uswds-site/llms.txt
This example demonstrates the basic header variant for orienting users and providing site navigation. It includes a logo and primary navigation with a dropdown.
```html
```
--------------------------------
### Standard Table Example
Source: https://github.com/uswds/uswds-site/blob/main/_components/table/01-standard-table.md
This is a basic example of a standard table. It includes a caption, header row, and data rows. Ensure your table content is accessible.
```html
Example table caption
Header 1
Header 2
Header 3
Row 1, Header 1
Row 1, Data 1
Row 1, Data 2
Row 2, Header 1
Row 2, Data 1
Row 2, Data 2
Row 3, Header 1
Row 3, Data 1
Row 3, Data 2
```
--------------------------------
### Basic Grid Row Example
Source: https://github.com/uswds/uswds-site/blob/main/_utilities/layout-grid.md
This example demonstrates a basic grid row with three equal-width columns on tablet and larger screens. The columns are centered within a grid container.
```html
tablet:grid-col
tablet:grid-col
tablet:grid-col
```
--------------------------------
### Example Output of Manual Values
Source: https://github.com/uswds/uswds-site/blob/main/_includes/utilities/values-intro.html
This CSS demonstrates the output generated from the `width-manual-values` map, creating a utility class `.width-tab`.
```css
.width-tab { width: 4ch; }
```
--------------------------------
### Stacked Table Example
Source: https://github.com/uswds/uswds-site/blob/main/_components/table/05-stacked-table.md
This is a basic example of a stacked table. It is designed to stack cells vertically on smaller screens for improved readability. No specific setup or imports are required beyond standard HTML structure.
```html
Example table with stacked cells
Column heading
Column heading
Column heading
Column heading
Row 1 data
Data
Data
Data
Row 2 data
Data
Data
Data
Row 3 data
Data
Data
Data
```
--------------------------------
### Initialize Project with npm
Source: https://github.com/uswds/uswds-site/blob/main/pages/documentation/getting-started-developers/phase-one.md
Initialize your project to create a `package.json` file, which is necessary for managing project dependencies with npm. This command starts an interactive prompt to configure your project's metadata.
```bash
npm init
# This utility will walk you through creating a package.json file.
# It only covers the most common items, and tries to guess sensible defaults.
# ...
```
--------------------------------
### Package.json Dependency Entry
Source: https://github.com/uswds/uswds-site/blob/main/pages/documentation/getting-started-developers/phase-one.md
After installation, your package.json file will list the installed USWDS version under dependencies. This entry reflects the exact version pinned during installation.
```json
"dependencies": {
"@uswds/uswds": "{{ site.uswds_version }}" [or another version number]
}
```
--------------------------------
### Initialize USWDS project with gulp init
Source: https://github.com/uswds/uswds-site/blob/main/pages/documentation/getting-started-developers/phase-two.md
Run `npx gulp init` to initialize your project. This command copies USWDS assets, adds a project Sass entry point, and compiles USWDS into CSS. Use this command only once during project setup.
```bash
npx gulp init
```
--------------------------------
### Typeset Mixin Usage Examples
Source: https://github.com/uswds/uswds-site/blob/main/pages/design-tokens/typesetting/overview.md
Demonstrates various ways to use the `typeset()` mixin with different token combinations, including using `null` to fallback to theme defaults.
```scss
typeset('ui', 'micro', 1)
```
```scss
typeset('ui', null, 3)
```
```scss
typeset('ui', xs)
```
```scss
typeset('ui')
```
--------------------------------
### Install Specific USWDS Commit
Source: https://github.com/uswds/uswds-site/blob/main/README.md
Install a specific commit of the USWDS repository as a dependency.
```sh
npm install --save "uswds/uswds#commit-hash"
```
--------------------------------
### Flex wrap and no-wrap examples
Source: https://github.com/uswds/uswds-site/blob/main/_utilities/flex.md
Demonstrates the use of `flex-wrap` and `flex-no-wrap` utilities to control how flex items wrap onto new lines. Useful for responsive design where content might overflow.
```html
```
--------------------------------
### Install Specific USWDS Version Tag
Source: https://github.com/uswds/uswds-site/blob/main/README.md
Install a specific version tag of the USWDS repository as a dependency.
```sh
npm install --save "uswds/uswds#v1.3.1"
```
--------------------------------
### List Project Contents
Source: https://github.com/uswds/uswds-site/blob/main/pages/documentation/getting-started-developers/phase-one.md
Verify that the `package.json` file has been created in your project's root directory after running `npm init`.
```bash
ls
# package.json
# [other directory contents...]
```
--------------------------------
### Apply USWDS Background Colors with Sass Mixins (Example)
Source: https://github.com/uswds/uswds-site/blob/main/pages/design-tokens/color/theme-tokens.md
Example of using the `u-bg()` Sass mixin with the 'primary-vivid' token.
```scss
@include u-bg('primary-vivid')
```
--------------------------------
### USWDS Banner Component Example
Source: https://context7.com/uswds/uswds-site/llms.txt
The banner identifies official U.S. government websites. This example shows the default customizable variant.
```html
An official website of the United States government
Here's how you know
```
--------------------------------
### Responsive Utility Classes
Source: https://context7.com/uswds/uswds-site/llms.txt
Shows how to use USWDS responsive prefixes (e.g., `tablet:`, `desktop:`) with utility classes to apply styles at different screen sizes. The `width-card-lg` class is an example of a responsive width utility.
```html
Responsive width
```
--------------------------------
### Access USWDS Color Tokens in Sass Functions (Example)
Source: https://github.com/uswds/uswds-site/blob/main/pages/design-tokens/color/theme-tokens.md
Example of using the `color()` Sass function with a specific token like 'primary-vivid'.
```scss
color: color('primary-vivid')
```
--------------------------------
### Navigate to Project Directory
Source: https://github.com/uswds/uswds-site/blob/main/README.md
Change your current directory to the cloned uswds-site folder.
```sh
cd uswds-site
```
--------------------------------
### Opacity Utility Classes (HTML)
Source: https://github.com/uswds/uswds-site/blob/main/_utilities/display.md
Apply opacity to elements using these utility classes. The examples show how to apply different opacities to elements, demonstrating visual effects with background colors.
```html
```
--------------------------------
### Sass Entry Point for USWDS
Source: https://context7.com/uswds/uswds-site/llms.txt
Set up your main Sass file to load USWDS settings, the USWDS source, and custom project styles in the correct order.
```scss
/* styles.scss — Sass entry point */
@forward "uswds-theme"; // 1. Load settings
@forward "uswds"; // 2. Load USWDS source
@forward "project-custom-styles"; // 3. Load project custom Sass
```
--------------------------------
### Line Chart Example
Source: https://github.com/uswds/uswds-site/blob/main/_components/data-visualizations/data-visualizations.md
An example of an SVG line chart used to display search interest trends over time. Includes styling and structural elements for the chart.
```svg