Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@trussworks/react-uswds

trussworks53.5kApache-2.010.0.2TypeScript support: included

React USWDS 3 component library

react, uswds, uswds 3, react component, us web design, design system, component library

readme

@trussworks/react-uswds

All Contributors

npm version uswds version

npm downloads

ReactUSWDS Component Library

This is a frontend component library, built in React with Typescript, based on design patterns defined by the United States Web Design System (USWDS) 3.0. Our primary goal is to document and provide common UI components following the USWDS specification. This library removes a significant amount of overhead UI development for projects based on this standard.

A deployed instance of the ReactUSWDS Storybook is located at: https://trussworks.github.io/react-uswds/

Table of Contents

Install

Install this package with npm or yarn:

yarn add @trussworks/react-uswds

or

npm i @trussworks/react-uswds

Peer Dependencies

This library relies on some peer dependencies. Please verify these peer dependencies were added to your project (if they did not already exist) after adding this library.

Usage

USWDS

It is strongly suggested applications use the same version of USWDS that was used to build the version of ReactUSWDS they're using (see this repo's uswds devDependency in package.json). A version mismatch may result in unexpected markup & CSS combinations. For flexibility, ReactUSWDS will not trigger warnings if consumers choose to use a higher minor version of uswds (hence the careted uswds peerDependency in package.json). If encountering unexpected markup issues when choosing not to use the matching devDependency version of uswds, consumers should check whether aligning the versions resolves their issue(s).

You can import ReactUSWDS components using ES6 syntax:

import { Alert } from '@trussworks/react-uswds'

Warning: Do not include USWDS JS in your project alongside this library (i.e., using import 'uswds'), as that will result in some components that use JS (such as the ComboBox) to initialize twice.

Also make sure to include the following in order to import the compiled CSS from this project:

@import '~@trussworks/react-uswds/lib/index.css';

If you aren't already using USWDS as a dependency, you also need to import USWDS styles. Read more info about using USWDS styles and assets here

Having issues? See FAQs.

NodeJS

We develop on this library with the version of node defined in .node-version. We run the test suite against the major released versions of node that are still in active LTS and not development releases. Specific versions are defined in the workflow: .github/workflows/build-and-test.yml. Those are the versions we expect to support, if you are using a pre-release or development version of node you may run into unexpected issues.

Having issues? See FAQs.

Pre-Release

See prelease.md

Implementation examples

We decided to focus on our storybook over hosting an example/boilerplate implementation, but you can find a few such things from our friends:

You can also check out some open source projects using React-USWDS across federal and state governments:

Background

The primary deliverable is a published npm package that can be included as a dependency in other projects that use USWDS with React. In order for these components to be useful, they should follow best practices for accessible, semantic, markup; be well-tested across browsers and devices; and allow for an appropriate level of customization. We adhere to a set of development guidelines as much as possible and use automation to enforce tests, linting, and other standards.

Non-Goals

This is not meant to be a one-size-fits-all front end solution, We are starting off with the opinionated decision to cater towards projects that use the U.S. Design System 2.0, and encapsulate these specific styles and markup in React components.

In the process, we expect to gain learnings around how to best abstract out UI code from implementation; how to better standardize and document front end code practices; and how to develop, maintain, and distribute a shared JS library in alignment with our company values at Truss.

Active Maintainers

We are starting to rotate Trussel maintainer responsibilities. Check out the maintainers README.

Contributing

Interested in contributing? See our guidelines and dev setup here.

Are you a Trussel and new to this project? Check out our on & offboarding guide made just for you!

This repository is governed by the Contributor Covenant

License

Copyright 2021, TrussWorks, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Suzanne Rozier
Suzanne Rozier

💻 📖
haworku
haworku

💻 📖
Andrew Hobson
Andrew Hobson

💻
John Gedeon
John Gedeon

💻 🚧
Emily Mahanna
Emily Mahanna

💻
Brandon Lenz
Brandon Lenz

💻 📖 🚧 🐛
Jeri Sommers
Jeri Sommers

💻
Erin Stanfill
Erin Stanfill

💻
Barry Morrison
Barry Morrison

💻
Duncan
Duncan

💻
Arianna Kellogg
Arianna Kellogg

💻
Christopher Hui
Christopher Hui

💻
Jim Benton
Jim Benton

💻
Jen Duong
Jen Duong

💻
Kim Allen
Kim Allen

💻 ️️️️♿️
Kyle Hill
Kyle Hill

💻
Mazdak Atighi
Mazdak Atighi

💻
Isaac Garfinkle
Isaac Garfinkle

💻
Roger Steve Ruiz
Roger Steve Ruiz

💻 📖
Leo Singer
Leo Singer

🐛 💻
Shauna Keating
Shauna Keating

️️️️♿️ 💻
Jacob Capps
Jacob Capps

💻
pearl-truss
pearl-truss

💻
Andrew Nelson
Andrew Nelson

💻 📖 🚧 🐛 ️️️️♿️
Sawyer Hollenshead
Sawyer Hollenshead

💻 🐛
Ryan Delaney
Ryan Delaney

🚧 🚇
Anna Gingle
Anna Gingle

🎨 💻
Abdullah Umer
Abdullah Umer

💻
Muhammad Adeel
Muhammad Adeel

🐛 💻
Vinod Krishna Vellampalli
Vinod Krishna Vellampalli

💻
Joe Kleinschmidt
Joe Kleinschmidt

💻
James Hancock
James Hancock

🐛 💻
Joseph Andersen
Joseph Andersen

💻 🚧 🚇
Courtney Eimerman-Wallace
Courtney Eimerman-Wallace

🚧
Owen Coutts
Owen Coutts

🐛 💻
AJ Farkas
AJ Farkas

💻 🚧 👀
Lea Melendez
Lea Melendez

🐛 💻 🚧 👀
Ali
Ali

💻 🚧
Iverson Diles
Iverson Diles

🐛 💻

This project follows the all-contributors specification. Contributions of any kind welcome!

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

10.0.2 (2025-06-09)

Bug Fixes

  • Correctly pass down classname props to Combobox component (#3143) (2086ab8)

10.0.1 (2025-05-16)

Bug Fixes

  • Fix an issue where the built package was not included in the published release artifact #3161 (cfe7a6d)

10.0.0 (2025-05-15)

⚠ BREAKING CHANGES

Features

Bug Fixes

Documentation & Examples

9.1.0 (2024-08-26)

Features

  • Enable custom on click handler passed via accordion item (#2998) (420483a)

Bug Fixes

Documentation & Examples

9.0.0 (2024-03-21)

⚠ BREAKING CHANGES

  • fix various 8.0.0 issues (#2820)

Bug Fixes

Documentation & Examples

  • added docs for breaking changes and using withDeprecationWarning (#2763) (305e116)

8.0.0 (2024-03-06)

⚠ BREAKING CHANGES

  • Webpack/Jest to Vite/Vitest migration (#2716)

Features

Bug Fixes

Documentation & Examples

  • Made storybook docs available again, small org changes elsewhere (#2795) (e77fe30)
  • removed circleci references (#2777) (b3e79f2)

7.0.0 (2024-02-22)

⚠ BREAKING CHANGES

  • React 18 Upgrade (#2714)
  • Uncouple uswds style (#2532)

Features

Bug Fixes

6.2.0 (2024-01-08)

Features

Bug Fixes

  • Remove image role attribute from Banner Icon component (#2663) (8ddf443)

6.1.0 (2023-11-27)

Features

Bug Fixes

  • a11y: move aria-label from svg icon to button (#2640) (fa18032)
  • adding labels in combo box (default combo box, with default value) (#2636) (7714d14)

6.0.0 (2023-10-31)

⚠ BREAKING CHANGES

  • <TimePicker> implementations must specify a label prop
  • Dropdown has been removed use <Select> instead

Features

Bug Fixes

  • Label is mandatory for TimePicker component (#2629) (c7f00d3)
  • readme quick links (#2646) (d4c0b4e)
  • Updates sign in stories to fix aria-controls issue of show password button (#2627) (67c1114)

Documentation & Examples

5.5.0 (2023-10-20)

Features

Bug Fixes

  • Language selector: add prop for display lang for bug fix (#2622) (df68d0d)
  • Sass modules bug (#2555) (a1ed9f7)
  • storybook: password label set to password input field id on sign in (#2618) (eae195e)
  • storybook: sufficient color contrast set in custom class button (#2619) (2878822)
  • Updates file input stories to set appropriate html for value of label (#2628) (7f51150)

Documentation & Examples

  • add design PR review documentation (#2615) (2892424)
  • adds in information on how to test PRs in GitHub Codespaces (#2617) (ef944f8)

5.4.0 (2023-09-29)

Features

  • deps: Allow consumers to use newer uswds minor versions (#2600) (36c1c8a)

5.3.1 (2023-09-08)

Bug Fixes

5.3.0 (2023-08-29)

Features

5.2.0 (2023-08-14)

Features

Bug Fixes

  • Adds story using validation prop for Alert component (#2504) (c5176c9)
  • Improve character count component's SR experience (#2550) (c612a1b)
  • moved overrides to let us use utilities (#2553) (45e1430)

Documentation & Examples

5.1.1 (2023-07-17)

Bug Fixes

  • Set alternative text on SVG img icon in menu close button (#2500) (ebdca5b)

5.1.0 (2023-07-14)

Features

  • added customizable text control to file input (#2417) (0a387be)
  • adds unbounded functionality to pagination (#2418) (f9e7957)

Bug Fixes

  • a11y: adds css to hide search clear button that causes accessibility issues (#2467) (d19527f)
  • added error param, test, story (#2488) (42da85d)

5.0.0 (2023-06-06)

⚠ BREAKING CHANGES

  • Unify icon usage (#2411)
    • As a part of this change, the previously exported BannerLockIcon component has been removed. Consumers building custom Banner components for their applications should use the Icon.Lock (with appropriate aria attributes) as shown in our Storybook example

Features

Bug Fixes

  • Adds validation styles to DatePicker (#2398) (161a931)
  • Allow CharacterCount value ^ defaultValue (#2397) (9de5b9d)
  • Rename Dropdown component to Select (#2415) (75e9369)
    • Note: Dropdown is now marked as deprecated, and will be removed in a future release
  • Fix FileInput in SSR (#2367) (3d4845e)
  • Fix misapplied aria attribute (#2396) (dafbb4e)
  • Unify icon usage (#2411) (ef2be8d)

Documentation & Examples

  • Add documentation for how we use All Contributors (#2378) (5aa9bda)

4.2.1 (2023-04-24)

4.2.0 (2023-04-03)

Features

Documentation & Examples

  • fix typo and add alt download instructions (#2281) (7508dfb)
  • Update old references from USWDS 2.0 to USWDS 3.0 (#2317) (6232c5c)

4.1.1 (2023-02-23)

4.1.0 (2023-02-17)

Features

Bug Fixes

4.0.0 (2022-11-08)

Features

Documentation & Examples

3.2.0 (2022-09-27)

Features

3.1.0 (2022-07-13)

Features

Bug Fixes

  • Danger contributors check (#2167) (c05fe06)
  • Emit headingLevel type and do not emit type declarations for tests (#2134) (a4501dd)
  • export SummaryBoxHeading and SummaryBoxContent (#2100) (141ba8e)

Documentation & Examples

3.0.2 (2022-05-13)

Bug Fixes

  • Fixes an issue where Type definitions were not properly packaged (#2053) (febcd65)

3.0.1 (2022-05-09)

Bug Fixes

  • Attempted to fixes an issue where Type definitions were not properly packaged

3.0.0 (2022-04-25)

⚠ BREAKING CHANGES

  • Previous deprecated features and props have been removed. Please see the following guidance for affected components:
    • Accordion: Default heading level has been removed. Consumers must now specify via the headingLevel prop.
    • Alert: Default heading level has been removed. Consumers must now specify via the headingLevel prop.
    • Button:
      • accent has been removed. Use accentStyle instead.
      • big, small, and size="small" have been removed. Use size="big" or do not define the size prop for default sizing.
    • CollectionHeading: Default heading level has been removed. Consumers must now specify via the headingLevel prop.
    • Footer/Address: big, medium, and slim props have been removed. Use the size prop instead.
    • Footer/Footer: big, medium, and slim props have been removed. Use the size prop instead.
    • Footer/FooterNav: big, medium, and small props have been removed. Use the size prop instead.
    • Footer/Logo: big, medium, and small props have been removed. Use the size prop instead.
    • Search: big, and small props have been removed. Use the size prop instead.
    • Fieldset: legendSrOnly has been removed. Use legendStyle="srOnly" instead.
    • TextInput: error, and success props have been removed. Use the validationStatus prop instead.
    • header/NavList: primary, secondary, subnav, megamenu, and footerSecondary props have been removed. Use the type prop instead.
    • StepIndicator: Default heading level has been removed. Consumers must now specify via the headingLevel prop.
  • SummaryBox now exposes sub-components (SummaryBoxHeading and SummaryBoxContent) for a more compositional API. Consumers will need to update their implementation to match.
  • In order to accommodate IconList as a named component, Icons themselves needed to be refactored. All use of ReactUSWDS icons now follows the following syntax: <Icon.{IconName} /> instead of <Icon{IconName />. Furthermore, icons are no longer imported individually. Instead, Icon (the class) is imported to then use any <Icon.{IconName}> consumers require.

Features

  • Remove 1.x.x and 2.x.x deprecated properties (#1988) (5dfadb1)

Documentation & Examples

2.9.0 (2022-04-14)

Features

  • Add ability to pass through StepIndicator heading props (#1895) (3830814)
  • Adds headingLevel prop for Alert component (#1928) (ce6de61)
  • Deprecate default heading levels (#1947) (512a901)

Bug Fixes

2.8.0 (2022-02-18)

Features

  • Accept Accordion headingLevel in items prop (#1905) (5090110)

Documentation & Examples

2.7.2 (2022-02-14)

Bug Fixes

  • Fix modal causing body padding to increase when unmounted (#1899) (fb46e88)

2.7.1 (2022-01-27)

Bug Fixes

  • Render modal outside app root by default. (#1890) (0828351)

2.7.0 (2022-01-12)

Features

Bug Fixes

Documentation & Examples

2.6.0 (2022-01-07)

Features

2.5.0 (2022-01-03)

Features

  • Allow intrinsic elements to be passed to Fieldset (#1862) (85a0092)

2.4.1 (2021-10-29)

  • Fix build artifact containing unused type definitions (#1726)

2.4.0 (2021-10-27)

Features

  • Add InputPrefix and InputSuffix components (#1713) (95ac139)

Bug Fixes

  • Control ComboBox scroll with scrollTop instead of scrollIntoView (#1715) (600d53b)
  • Add ComboBox status text and aria-activedescendant values (#1716) (29919bf)

2.3.0 (2021-10-19)

Features

Documentation & Examples

  • Update ADR-0001 name to match it's title/outcome (#1652) (d3bd12c)

2.2.0 (2021-10-08)

Features

2.1.0 (2021-09-29)

Features

2.0.0 (2021-06-15)

⚠ BREAKING CHANGES

  • Expose FileInput component ref with a clearFiles method (#1165)
  • Expose ComboBox component ref with a clearSelection method (#1236)
  • deps-dev: Update Typescript to 4.0+ (#1214)
  • Modal component has been removed. The USWDS Modal will be added when reaching parity with USWDS 2.11.x
  • Accordion component default behavior was updated to match USWDS. To continue to use the multiselectable behavior, use the multiselectable prop.

Features

  • Collection Component (#1133) (cdc200f)
  • Deprecate the Modal component (#956) (7ae4e30)
  • Expose ComboBox component ref with a clearSelection method (#1236) (e90e4df)
  • Expose FileInput component ref with a clearFiles method (#1165) (0bc0b54)
  • Update Accordion component default behavior to match USWDS (#922) (c063047)

Bug Fixes

1.17.0 (2021-05-05)

Features

1.16.0 (2021-04-22)

Features

Documentation & Examples

  • adr: Increase ReactUSWDS version when updating USWDS version (#1045) (59f6720)

1.15.0 (2021-04-12)

Features

Documentation & Examples

  • Add guidance for PR titles and testing in an application (#1028) (be3bed4)

1.14.0 (2021-03-22)

Features

Documentation & Examples

  • Update documentation. Show component description and prop defaults in storybook (#1008) (a8d267f)

1.13.2 (2021-03-11)

Bug Fixes

1.13.1 (2021-03-08)

Bug Fixes

  • set CombBox focusMode to BLUR when focus is outside of the component (#989) (fa468a0)

1.13.0 (2021-02-26)

Features

Documentation & Examples

  • Add All-Contributors section to README (#954) (fe23df1)

1.12.2 (2021-02-22)

Bug Fixes

  • add ActionType.CLEAR_FOCUS to indicate a user has left the field (#902) (58159d7)

1.12.1 (2021-02-22)

Bug Fixes

1.12.0 (2021-02-18)

Features

Bug Fixes

  • prevent dependabot version updates (+ husky 5 fixes) (#867) (4529d89)

1.11.0 (2021-02-08)

Features

Documentation & Examples

  • Add request for implementation issue template (#726) (93300e8)
  • cleanup storybook examples and clear warnings (#736) (4b0f7aa)
  • Reorganize Storybook sidebar nav to better reflect USWDS docs (#785) (a9ff49f)
  • Update license to 2021 (#767) (82329da)

1.10.0 (2020-12-29)

Features

Bug Fixes

  • Add className handling to header and footer subcomponents (#735) (808b290)

1.9.3 (2020-11-13)

Bug Fixes

  • Happo automation should skip dependabot PRs (#453) (dc5bffc)
  • Require Typescript 3.8+ (#521) (53efe5d)
  • update example app deps to fix security issue (#476) (00fd70a)

Documentation & Examples

1.9.2 (2020-09-10)

Bug Fixes

  • Change happo command to check for github user (#451) (cd0add9)

Documentation & Examples

  • storybook: Upgrade to 6.0.12 (#418) (65d91cc)
  • Improve documentation for new contributors, trussels (#402) (0849a30)

1.9.1 (2020-08-18)

Bug Fixes

1.9.0 (2020-08-10)

Features

  • ButtonGroup: Add new component ButtonGroup (#382) (a7b84d6)
  • CharacterCount: Add new component CharacterCount (#383) (cc12034)
  • add addon-viewports using the included INITIAL_VIEWPORTS list as default for all stories (#376) (9683b40)
  • Validation: Add new Validation components (#351) (2b2369a)

Bug Fixes

  • Button: Deprecate icon, size small properties (#362) (23a2e4b)
  • webpack: support browsers and node

Documentation & Examples

  • Even more info and emphasis on conventional commits (#350) (1301cc4)
  • Point users to react-fontawesome for icons (#364) (3de50ef)

1.8.0 (2020-07-27)

Features

  • danger: Block PR if yarn audit has high or critical, do not run on dependabot, no warn on version (#327) (ee13281), closes #324
  • storybook: switch to addon-docs (#323) (ccae95d), closes #119
  • storybook: upgrade to 5.3.0, prepare for addon-docs (#322) (1f1fc6a), closes #119

Bug Fixes

  • correct version syntax in deploy-storybook worflow(#321) (4eb7d2c)
  • Export NavDropDownButton (91f9ca7)
  • remove commitizen; upgrade example app dependencies (#335) (9c5aea2)

Documentation & Examples

1.7.0 (2020-07-15)

Features

Bug Fixes

  • address all lint warnings (#319) (95a12a3)
  • refactor menu, megamanu; removes deprecation warnings from tests (#313) (42e2481)

1.6.1 (2020-07-13)

Bug Fixes

  • standard-version: use -t flag correctly, autocommit changelog and release bump (#310) (a96591e)
  • Use JSX.ImplicitElements to derive valid property names (#267) (2eba792)

Documentation & Examples

  • Update releasing instructions with current flow (#297) (87515bc)

1.6.0 (2020-06-29)

Features

  • Address: convert to enum size prop, deprecate boolean (#269) (952bb71), closes #265
  • button: size enum on Button, add deprecationWarning util (#229) (3b3f4e7), closes #187
  • card: add card component (89cf241)
  • example app: add modals page example 204 (#250) (1054469)
  • Footer,FooterNav: use size prop, deprecate boolean sizes (#239) (c5abdc4), closes #233
  • Logo: use size prop, deprecate boolean types (#268) (ea88c50), closes #264
  • NavList: use type prop, deprecate boolean types (#262) (7c83154), closes #234
  • Search: add size enum prop, deprecate big,small boolean props (#270) (c5daf8d), closes #266
  • TextInput: use enum props, deprecate booleans (#284) (6565be6), closes #283

Bug Fixes

  • card: add card components to export (d57eefc)

Documentation & Examples

1.5.0 (2020-06-03)

Bug Fixes

  • expand required node version range to 10.x - 12.x (#215) (0be79d3)

Documentation & Examples

  • example-app: add create-react-app example app (#206) (cf28086)

1.4.0 (2020-05-28)

Features

Bug Fixes

  • accept id and name props for Search component input field (#183) (c39c085), closes #162
  • export Search component (2508829)
  • extends header menu to accept list props for corresponding id (#188) (85a1780), closes #165
  • removes the usa-search class name from the form component (#184) (8cb5121), closes #163
  • update gov banner to uswds version 2.7.0 (c5bd62c)

1.3.0 (2020-05-19)

Features

  • Add header component #83 (#102) (4281b11)
  • Add search component
  • Add Grid, GridContainer components

1.2.0 (2020-04-30)

Features

  • Add new Alert styles (slim, no icon) and allow the Alert to accept div attributes as props
  • Add additional CSS utility classes for background colors and text colors

Docs

  • Add additional examples of Form templates (Sign In form, Reset Password form) to Storybook

1.1.0 (2020-03-19)

Features

  • Add initial set of USWDS form components (Checkbox, Dropdown, ErrorMessage, Fieldset, Form, FormGroup, Label, Radio, TextInput, Textarea)
  • Add native HTML attributes to existing Tag & Button components in order to support custom CSS classes
  • Add new Modal component (designed by Truss) and related Overlay and ModalContainer components

1.0.0 (2019-01-10)

Features

  • Initial set of USWDS components (Accordion, Alert, Button, GovBanner, SideNav, Table, Tag)
  • Initial documentation and dev configuration for contributing & usage