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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@uswds-wc/forms

v2.5.4

Published

USWDS Form Components - Web Components

Readme

@uswds-wc/forms

USWDS Form Components - Complete form inputs and controls as Web Components.

Overview

The @uswds-wc/forms package provides web component versions of all USWDS form-related components, including inputs, pickers, validation, and more.

Installation

npm install @uswds-wc/forms lit

Components

Text Input (<usa-text-input>)

Standard text input with validation support.

Textarea (<usa-textarea>)

Multi-line text input.

Select (<usa-select>)

Dropdown selection with native semantics.

Checkbox (<usa-checkbox>)

Checkbox input with tile variant.

Radio (<usa-radio>)

Radio button input with tile variant.

Date Picker (<usa-date-picker>)

Calendar-based date selection with USWDS JavaScript behavior.

Date Range Picker (<usa-date-range-picker>)

Select start and end dates with calendar interface.

Time Picker (<usa-time-picker>)

Time selection with dropdown list of times.

Combo Box (<usa-combo-box>)

Searchable select with autocomplete.

File Input (<usa-file-input>)

File upload with drag-and-drop support.

Character Count (<usa-character-count>)

Text input/textarea with live character counter.

Range Slider (<usa-range-slider>)

Slider input for numeric ranges.

Memorable Date (<usa-memorable-date>)

Three-part date input (month/day/year) for memorable dates.

Input Prefix/Suffix (<usa-input-prefix-suffix>)

Text input with prefix or suffix text.

Validation (<usa-validation>)

Form validation feedback component.

Usage Example

import '@uswds-wc/forms';

// Basic text input
const input = document.createElement('usa-text-input');
input.label = 'Email Address';
input.type = 'email';
input.required = true;

Comprehensive Form Example

<form>
  <usa-text-input
    label="Full Name"
    name="fullName"
    required>
  </usa-text-input>

  <usa-text-input
    label="Email Address"
    type="email"
    name="email"
    required>
  </usa-text-input>

  <usa-date-picker
    label="Date of Birth"
    name="dob">
  </usa-date-picker>

  <usa-select
    label="State"
    name="state"
    required>
    <option value="">- Select -</option>
    <option value="CA">California</option>
    <option value="NY">New York</option>
    <option value="TX">Texas</option>
  </usa-select>

  <usa-checkbox
    label="I agree to the terms"
    name="terms"
    required>
  </usa-checkbox>

  <usa-button type="submit">Submit Form</usa-button>
</form>

With Validation

<usa-character-count
  label="Message"
  maxlength="500"
  name="message">
</usa-character-count>

<usa-combo-box
  label="Select a fruit"
  name="fruit">
  <option value="apple">Apple</option>
  <option value="banana">Banana</option>
  <option value="orange">Orange</option>
</usa-combo-box>

<usa-file-input
  label="Upload resume"
  accept=".pdf,.doc,.docx"
  name="resume">
</usa-file-input>

Bundle Size

Gzipped: ~80 KB (largest package due to complex form controls)

Features

  • Complete Form Suite - All 15 USWDS form components
  • Native Form Integration - Works with standard HTML forms
  • Built-in Validation - HTML5 validation + custom USWDS validation
  • Accessibility - Full keyboard navigation and screen reader support
  • Date/Time Pickers - Complex USWDS JavaScript behaviors fully implemented
  • File Upload - Drag-and-drop with preview support
  • TypeScript - Full type definitions included

Form Integration

All form components work seamlessly with native HTML forms:

const form = document.querySelector('form');
form.addEventListener('submit', (e) => {
  e.preventDefault();
  const formData = new FormData(form);
  console.log(Object.fromEntries(formData));
});

Validation Example

<usa-text-input
  label="Password"
  type="password"
  name="password"
  required
  minlength="8"
  pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}"
  hint="Must be at least 8 characters with uppercase, lowercase, and number">
</usa-text-input>

<usa-validation
  for="password"
  error-message="Password does not meet requirements">
</usa-validation>

Browser Support

  • Modern browsers (Chrome, Firefox, Safari, Edge)
  • ES2020+ required
  • Web Components v1 spec

Dependencies

  • @uswds-wc/core - Core utilities and base components
  • lit ^3.0.0 (peer dependency)

Development

# Build the package
pnpm run build

# Run tests
pnpm test

# Type checking
pnpm run typecheck

# Linting
pnpm run lint

Storybook

View live examples and interactive documentation:

USWDS Web Components Storybook

License

MIT

Repository

USWDS Web Components Monorepo

Related Packages

Contributing

See the main repository for contribution guidelines.