项目 / uswds/uswds

uswds/uswds

行业推荐
语言 JavaScript标签 design-systemsdesigngovernmentuswds数据更新 2026-11-24 06:50:13 · 仓库 2026-11-23

一段话介绍

美国网页设计系统(USWDS)是一套原则、指南与代码工具包,提供面向美国联邦政府网站、也可用于其他场景的开源界面组件库和视觉样式指南。本仓库存放设计系统代码本身,文档与站点在 [uswds-site](https://github.com/uswds/uswds-site),在线文档为 [https://designsystem.digital.gov](https://designsystem.digital.gov)。当前主要大版本为 USWDS 3.0,自 3.0.0 起代码按功能包(通常对应组件)组织;软件包里既有 `dist` 下的编译产物,也有 `packages` 下的组件源码。推荐用 npm 安装 [`@uswds/uswds`](https://www.npmjs.com/package/@uswds/uswds),也可直接从 GitHub 安装。设计师和开发者可分别查看[设计师入门](https://designsystem.digital.gov/documentation/getting-started-for-designers/)和[开发者入门](https://designsystem.digital.gov/documentation/getting-started-for-developers/);也可用 [USWDS Tutorial](https://github.com/uswds/uswds-tutorial) 做一次完整练习。设计系统的大部分内容以 CC0 1.0 释出到公共领域,少数部分的许可与署名见仓库 `LICENSE.md`。说明见[官方站点](https://designsystem.digital.gov)和[仓库 README](https://github.com/uswds/uswds)。

本站整理,非 GitHub 官方 description。

官方 description(GitHub API 原样)
The U.S. Web Design System helps the federal government build fast, accessible, mobile-friendly websites.
7,250累计星
1,124Fork
—峰值日增
0上榜次数
总榜
暂未入榜
日榜
暂未入榜
周榜
暂未入榜
月榜
暂未入榜

官方快照(gh_history.db,2026-11-25):总榜 未进 Top50 · 日榜 未进 Top50 · 周榜未满 7 天基线(官方不生成) · 月榜暂无官方口径;下方四卡为站内趋势聚合(周卡按上榜次数,非官方 7 日增量窗)。

行业与场景

按行业选型 →

政务事项办理与一网通办

适配系统:政务服务平台、工作流引擎 · 得分 1.4

以事项流程编排与表单驱动为核心,可支撑跨部门联办与办件全流程跟踪。

更多信息

以下三段按该项目自己的 GitHub README 章节摘录(可合理截断并标明);README 没有对应章节的留空,不编造。

我的用法
安装或使用说明见 https://github.com/uswds/uswds-tutorial。
特点或设计要点
项目说明文档见 https://github.com/uswds/uswds-site。
局限和适用边界
USWDS 的 Sass 编译需满足三个条件:支持 Sass Module 语法的现代编译器、按指定 .browserslistrc 做 Autoprefix,以及将加载路径指向包内 /packages 目录。
星标走势还差一天的数据,明天就能看到曲线
每天 10:30 记一次星标,连续两天后自动生成曲线
首次发现 — · 最近在榜 2026-11-04 · 语言 JavaScript · 贡献者 —
javascript

GitHub 项目主页介绍

来自 GitHub 仓库 README / 主页介绍正文,正文较长,已截断:保留前 20000 字符(原始 32,405 字节),完整内容见 GitHub 仓库。

# United States Web Design System

[![CircleCI Build Status](https://img.shields.io/circleci/build/gh/uswds/uswds/develop?style=for-the-badge&logo=circleci)](https://circleci.com/gh/uswds/uswds/tree/develop) [![npm Version](https://img.shields.io/npm/v/@uswds/uswds?style=for-the-badge)](https://www.npmjs.com/package/@uswds/uswds) [![npm Downloads](https://img.shields.io/npm/dt/@uswds/uswds?style=for-the-badge)](https://www.npmjs.com/package/@uswds/uswds) [![GitHub issues](https://img.shields.io/github/issues/uswds/uswds?style=for-the-badge&logo=github)](https://github.com/uswds/uswds/issues) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4?style=for-the-badge)](https://github.com/prettier/prettier)

The [United States Web Design System](https://designsystem.digital.gov) is a toolkit of principles, guidance, and code — a library of public domain and open source user interface components and a visual style guide designed for U.S. federal government websites, but useful in many other applications.

This repository is for the design system code itself. We maintain [another repository for the documentation and website](https://github.com/uswds/uswds-site). To see the design system and its documentation on the web, visit [https://designsystem.digital.gov](https://designsystem.digital.gov).

## Contents

- [Recent updates](#recent-updates)
- [Getting started](#getting-started)
- [What's included in USWDS](#whats-included-in-uswds)
  - [Directory structure](#directory-structure)
  - [Package contents](#package-contents)
- [Installing the design system](#installing-the-design-system)
- [Using USWDS CSS and JavaScript in your project](#using-uswds-css-and-javascript-in-your-project)
- [Compiling USWDS Sass into CSS](#compiling-uswds-sass-into-css)
  - [Sass compilation requirements](#sass-compilation-requirements)
  - [Sass and theme settings](#sass-and-theme-settings)
- [JS customization](#js-customization)
- [Style theming and tokens](#style-theming-and-tokens)
- [CSS architecture](#css-architecture)
- [Browser support](#browser-support)
- [Accessibility](#accessibility)
- [Long-term support of v1.x](#long-term-support-of-v1x)
- [Long-term support of v2.x](#long-term-support-of-v2x)
- [Need installation help?](#need-installation-help)
- [Contributing to the code base](#contributing-to-the-code-base)
- [Reuse of open-source style guides](#reuse-of-open-source-style-guides)
- [Licenses and attribution](#licenses-and-attribution)
- [Contributing](#contributing)

## Recent updates

Information about the most recent release of the design system can always be found in the [release history](https://github.com/uswds/uswds/releases). We include details about significant updates and any backward-incompatible changes along with a list of **all** changes.

**USWDS 3.0 is our most recent major release.**
- [Read about what's new in USWDS 3.0](https://designsystem.digital.gov/whats-new/updates/2022/04/28/introducing-uswds-3-0/)
- [Read our USWDS 3.0 Migration Guide](https://designsystem.digital.gov/documentation/migration)

## Getting started

So glad you’re interested — here’s how you can get started:

- **Designers:** Check out our [Getting started for designers information](https://designsystem.digital.gov/documentation/getting-started-for-designers/).
- **Developers:** Check out our [Getting started for developers information](https://designsystem.digital.gov/documentation/getting-started-for-developers/). If your project doesn't use npm for package management, follow the instructions in this README to [install the design system without npm.](#installing-the-design-system)
- **Everyone and anyone:** The [USWDS Tutorial](https://github.com/uswds/uswds-tutorial) can be helpful. Follow the instructions in that GitHub repo to clone a sample project, install USWDS, customize it, and add USWDS components. It should take about an hour, and is a good introduction to USWDS concepts. You can also learn from [this live tutorial](https://designsystem.digital.gov/about/monthly-calls/#march-2024-building-with-uswds-tools).

## What's included in USWDS
The USWDS package includes compiled assets in a `dist` directory and component source files in a `packages` directory.

As of USWDS 3.0.0, the USWDS codebase is centered around functional packages, typically components. You can [see our Packages documentation](https://designsystem.digital.gov/components/packages) for more about USWDS package organization. In each of the following examples, `[package]` represents a specific package. For example, component Sass is located in `packages/[package]/src/styles`. For an accordion, this would be `packages/usa-accordion/src/styles`.

- **Fonts** are located in both `dist/fonts` and `packages/uswds-core/src/assets/fonts`. The fonts in `dist` are simply a copy of the files in `uswds-core`.
- **Images** and icons are located in: `dist/img`. The source for component-specific images can be found in a package's `src/img` directory.
- **JavaScript** for components is located in `packages/[package]/src/index.js`. General JavaScript utilities are located in the `uswds-core` package: `packages/uswds-core/src/js`
- **Sass** component-specific stylesheets are located in: `packages/[package]/src/styles`. Many components also have a component entry point at `packages/[package]/_index.scss` that includes references to all dependencies for that component. **Compiled CSS** is located in `dist/css`.
- **Template** markup for the components is located in: `packages/[package]/src/[package.twig]` in the site root. These, however, are written in the templating language Twig. It's best to get HTML source markup directly from [designsystem.digital.gov/components](https://designsystem.digital.gov/components).

### Directory structure
Here's what's inside the USWDS package:

```
[uswds package]
├── .storybook/
├── dist/
│   ├── css/
│   │   ├── uswds.css
│   │   ├── uswds.min.css
│   │   └── uswds.min.css.map
│   ├── fonts/
│   │   ├── merriweather/
│   │   ├── public-sans/
│   │   ├── roboto-mono/
│   │   └── source-sans-pro/
│   ├── img/
│   │   ├── usa-icons/
│   │   ├── material-icons/
│   │   ├── uswds-icons/
│   │   ├── usa-icons-bg/
│   │   ├── sprite.svg
│   │   ├── [individual images]
│   │   ...
│   ├── js/
│   │   ├── uswds-init.js
│   │   ├── uswds-init.min.js
│   │   ├── uswds-init.min.js.map
│   │   ├── uswds.js
│   │   ├── uswds.min.js
│   │   └── uswds.min.js.map
│   ├── scss/
│   │   └── stylesheets/
│   │       └── uswds.scss
│   └── theme/
│       ├── _uswds-theme.scss
│       ├── _uswds-theme-custom-styles.scss
│       └── styles.scss
├── packages/
│   ├── usa-component/
│   │   ├── src/
│   │   │   ├── content/
│   │   │   ├── styles/
│   │   │   │   ├── _index.scss
│   │   │   │   └── component.scss
│   │   │   ├── test/
│   │   │   │   ├── component.spec.js
│   │   │   │   └── template.html
│   │   │   ├── index.js
│   │   │   ├── usa-component.stories.js
│   │   │   └── usa-component.twig
│   │   └── _index.scss_/
│   ├── usa-component/
│   ├── usa-component/
│   ├── uswds-bundle/
│   ├── uswds-bundle/
│   ...
├── src/
│   ├── img/
│   ├── stylesheets/
│   └── test/
└── tasks/
```

### Package contents
Here's what's in each of the directories and files in the USWDS package:

- `/.storybook`: Storybook configuration files (not used in USWDS projects)
- `/dist`: Compiled or collected files
- `/dist/css`: Precompiled CSS files with USWDS defaults
- `/dist/fonts`: Default fonts available to the design system
- `/dist/img`: All USWDS images collected into a single directory
- `/dist/img/usa-icons`: All icons collected into the USWDS icon sprite (`sprite.svg`)
- `/dist/img/material-icons`: All Material Icons
- `/dist/img/uswds-icons`: All icons created by USWDS
- `/dist/img/sprite.svg`: Precompiled icon sprite with default icon set
- `/dist/js`: Precompiled JavaScript files
- `/dist/scss/stylesheets/uswds.scss`: Backwards compatible USWDS Sass entry point
- `/dist/scss/theme`: Example theme files
- `/dist/scss/theme/_uswds-theme.scss`: Example theme settings file
- `/dist/scss/theme/_uswds-theme-custom-styles.scss`: Example custom settings file
- `/dist/scss/theme/styles.scss`: Example project Sass entry point
- `/packages`: Source files for USWDS components and other functionality
- `/packages/usa-[component]`: Each package has a name like `usa-[component]` that matches its class name in the design system, like `usa-accordion`
- `/packages/usa-[component]/_index.scss`: Sass entry point for the package
- `/packages/usa-[component]/src`: Package source files
- `/packages/usa-[component]/src/index.js`: Package javascript
- `/packages/usa-[component]/src/usa-component.stories.js`: Storybook setup
- `/packages/usa-[component]/src/usa-component.twig`: Component template
- `/packages/usa-[component]/src/index.js`: Package javascript
- `/packages/usa-[component]/src/content`: Package template content
- `/packages/usa-[component]/src/test`: Package unit tests
- `/packages/usa-[component]/src/styles`: Package source Sass

- `/packages/uswds`: The package most projects include by default. This bundle includes all USWDS components and functionality.
- `/packages/uswds-[bundle]`: Other non-component functionality is included in `uswds-`-prefixed packages. These bundles might collect common component packages (`uswds-form-controls`) or important internal functionality (`uswds-core`).
- `/src`: Placeholders included for backwards compatibility. Typically you should avoid using the contents of this directory.
- `/tasks`: Internal build process files (not used in USWDS projects)

## Installing the design system
There are two ways to install the design system on a project:
- Installing it as a project dependency using Node and npm
- Installing the package directly from GitHub

**We recommend using npm to make it as straightforward as possible to install the design system and update it as we release new versions.**

### Install using Node and npm
Use the npm package manager for Node-based projects. USWDS maintains the [`@uswds/uswds` package](https://www.npmjs.com/package/@uswds/uswds) that includes both the pre-compiled and compiled files. We rely on npm packages to easily update and install the design system from the command line.

1. Install `Node/npm`. Be sure to use the right install method for your operating system:

   - Node (see [.nvmrc](https://github.com/uswds/uswds/blob/develop/.nvmrc) for version number), [Installation guides](https://nodejs.org/en/download)

   **Note for Windows users:** If you're using Windows but aren't familiar with Node or npm, we recommend following [Team Treehouse's tutorial](http://blog.teamtreehouse.com/install-node-js-npm-windows) for more information.

2. Make sure you installed it correctly:

   ```shell
   npm -v
   6.13.0 # This line may vary depending on which version of Node you've installed.
   ```

3. Create a `package.json` file. You can do this manually, but it's easier to use the `npm init` command, which will prompt you with a few questions to create your `package.json` file.

4. Add `@uswds/uswds` to your project’s `package.json`:

   ```shell
   npm install --save @uswds/uswds@latest
   ```

The `@uswds/uswds` module is now installed as a dependency. You can use the compiled files found in the `node_modules/@uswds/uswds/dist/` directory or the source files in the `node_modules/@uswds/uswds/packages/` directory.

**Note:** We do _not_ recommend directly editing the design system files in `node_modules`. If you do that, you'll lose one of the major benefits of using a package manager — its ease of upgrade and installation. If you customize files in the package, any upgrade or re-installation will wipe out those changes.

### Install the package directly from GitHub
If you’re using a framework or package manager that doesn’t support npm, you can find the source files in this repository and use them in your project. Otherwise, we recommend that you follow the steps outlined in this section.

1. Download the [USWDS package](https://github.com/uswds/uswds/releases) directly from the latest USWDS release and uncompress that file.

2. Copy these files and folders into a relevant place in your project's code base. Here's an example structure:

   ```
   example-project/
   ├── assets/
   │   ├── uswds/
   │   │   ├── dist/
   │   │   ├── packages/
   │   │   └── src/
   │   ├── stylesheets/
   │   ├── images/
   │   └── javascript/
   └── index.html
   ```

   You'll notice in this example that we also outline a `stylesheets`, `images` and `javascript` folder in your `assets` folder. These folders help organize any assets that are unique to your work and separate from the design system assets.

    <!--
      This note also exists on the USWDS Site download page, which is maintained in the USWDS-Site repo.
      If any changes are made, make sure to update there as well.
    -->
    **Note:** Files in the downloadable USWDS package will show a "last modified" date of October 26, 1985. This is [intentional](https://github.com/npm/npm/issues/20439#issuecomment-385121133). This default date is set by npm on all its packages to ensure builds will be identical.

## Using USWDS CSS and JavaScript in your project

The three files critical to any USWDS project are the **stylesheet**, the **JavaScript**, and the **initializer**. Most projects require all of these to function properly.

- **Stylesheet:** This is the compiled CSS stylesheet that describes how design system components look. To start, reference either `uswds.css` or `uswds.min.css` in the `<head>` of your document. Find this file in `/dist/css`. Most projects will want to compile their own CSS from USWDS source Sass instead of using the precompiled version. For more about this, see [Compiling USWDS Sass into CSS](#compiling-uswds-sass-into-css), below.
- **Library:** This is the compiled JavaScript that controls component interactivity. Reference either `uswds.js` or `uswds.min.js` at the end of the `<body>` of your document. Find this file in `/dist/js`.
- **Initializer:** This small JavaScript file (less than 1 KB minified) helps the browser know if the USWDS JavaScript library is loading properly. This prevents component content from "flashing" or "shifting" while the page loads. Reference `uswds-init.min.js` in the `<head>` of your page, or inline its contents directly into the `<script>` tag. Find this file in `/dist/js`.

Reference the stylesheet, library, and initializer in each HTML page or dynamic template in your project.

Here's an example of how to reference these assets in your `index.html` file:

```html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Example Project</title>
    <script src="assets/uswds/dist/js/uswds-init.min.js"></script>
    <link rel="stylesheet" href="assets/uswds/dist/css/uswds.min.css" />
  </head>
  <body>
    <script src="assets/uswds/dist/js/uswds.min.js"></script>
  </body>
</html>
```

And that’s it — you should now be able to copy our code samples into your `index.html` and start using the design system.

## Compiling USWDS Sass into CSS

If you want to take full advantage of USWDS custom settings and add build new styles and components with the USWDS toolset, you'll need a way to access the assets in the USWDS package and compile custom CSS from the USWDS source files.

USWDS uses the task manager [Gulp](http://gulpjs.com/) as a way to add USWDS assets to a project and compile our CSS from the package source. Gulp is a useful and powerful tool, but it can be hard to set up if you're new to it.

The [USWDS Compile package](https://github.com/uswds/uswds-compile) is made for developers new to Gulp or those who just want a simple setup to compile USWDS Sass. The repo contains files and instructions for setting up the compiler, initializing USWDS, and compiling CSS from the source files.

### Sass compilation requirements

USWDS Sass needs three things to compile properly:
- **Sass Module syntax:** USWDS requires a modern Sass compiler that can parse Sass Module syntax
- **Autoprefixing:** USWDS requires Autoprefixing your CSS with a specific `.browserslistrc`
- **Sass Load Paths:** USWDS requires Sass compilers use Load Paths that reference the `/packages` directory in the USWDS package

**Note: Using a compiler package like [USWDS Compile](https://github.com/uswds/uswds-compile) is a good way to do this more easily.**

#### Autoprefixing

The design system requires autoprefixing to work properly. Don't add vendor prefixes to your custom styles manually — it's more reliable to use autoprefixing. Autoprefixing services like [gulp-autoprefixer](https://github.com/sindresorhus/gulp-autoprefixer) automatically add vendor prefixes to CSS rules. We use the following autoprefixer settings via `.browserslistrc` config:

```
> 2%
last 2 versions
not dead
```

#### Sass Load Paths

USWDS 3.0 and newer require the use of [Sass Load Paths](https://sass-lang.com/documentation/at-rules/use#load-paths) to compile properly.

USWDS 3.0 load paths must include a path to the `/packages` directory in the USWDS package, typically by updating an `IncludePaths` setting to include `node_modules/@uswds/uswds/packages`.

Here's how this might look in Gulp and in Webpack:

##### Gulp

```js
.pipe(
  sass({
    includePaths: [
      "./node_modules/@uswds/uswds/packages",
    ],
  })
```

##### Webpack

```js
loader: "sass-loader",
options: {
  sassOptions: {
    includePaths: [
      "./node_modules/@uswds/uswds/packages"
    ],
  },
},
```


#### Other useful compiler postprocessing

- **Minification:** We recommend using a **minifier** like [csso](https://github.com/css/csso) to compress your final compiled CSS
- **Sourcemaps:** We recommend using a **sourcemap** tool like [`gulp-sourcemaps`](https://www.npmjs.com/package/gulp-sourcemaps) to assist debugging by keeping track of source Sass locations

### Sass and theme settings

The design system is customizable using the power of [Sass (Syntactically Awesome Style Sheets)](http://sass-lang.com/). The critical files you'll need are the ones in `dist/scss/theme`:

- `_uswds-theme.scss`: custom theme settings
- `_uswds-theme-custom-styles.scss`: additional project CSS for customizing or adding to what USWDS provides
- `styles.scss`: The Sass entry point, which is the primary Sass file that you'll compile. It collects theme settings, USWDS source files, and custom CSS

`styles.scss` looks something like the following code. It adds all the project theme settings, then adds USWDS source, and finally adds your project's custom styles:

```scss
@forward "uswds-theme";
@forward "uswds";
@forward "uswds-theme-custom-styles";
```

**Technical note:** The `@forward 'uswds'` statement above references the `uswds` package in `node_modules/@uswds/uswds/packages`. The compile functions included in [`uswds-compile`](https://github.com/uswds/uswds-compile) automatically look for USWDS packages in the proper directory using `includePaths`.

## JS customization

**Unfortunately, customizing the JavaScript for USWDS currently requires NodeJS and a module bundler like Browserify or Webpack. We're working to change this in a future release.**

USWDS JavaScript is separated into components (just as with the CSS and HTML) and initialized with event handlers when the DOM is ready. These components are accessible as CommonJS modules that can be required in other JavaScript files, then built for the browser. The components are not accessible in the global browser scope, but can be extended to be included by requiring `components` and setting it to a global scope:

```js
window.uswds = require("./components");
```

Each component has a standardized interface that can be used to extend it further. The components store an HTML class (like `.usa-accordion__
↑