Skip to main content
DrupalMaze
Free quote

How to upgrade from USWDS 2.x to USWDS 3 without breaking your theme

USWDS 3 changes how packages, tokens, and utilities load. Upgrading cleanly means treating it as a dependency migration, not a find-and-replace — here is the sequence that keeps the theme working.

USWDS 3 reorganized the library into modular packages and moved most projects from a monolithic uswds.css toward Sass module imports and design tokens. Sites that stay on 2.x still work — but they stop receiving improvements, and the gap widens every release. The upgrade is manageable if you treat it as a dependency migration rather than a stylesheet swap.

Step 1 — Inventory what you actually use

Before touching code, list which components, utilities, and mixins your theme imports or calls. A quick way: search your Sass for @import, usa- class usage in templates, and utility classes like grid-row or margin-y-2. This list defines the migration surface — most county themes use a fraction of the library.

Step 2 — Move to the packages build

USWDS 3 expects you to import what you use via @forward and @use instead of pulling the whole library. A minimal entry looks like:

@use "uswds-core" as *;
@forward "uswds-global";
@forward "usa-banner";
@forward "usa-header";
@forward "usa-footer";
@forward "uswds-utilities";

Start with the components from your inventory. If a page looks broken, nine times out of ten a needed package is missing from the forward list — add it rather than rewriting markup.

Step 3 — Migrate settings to theme tokens

USWDS 3 settings move into a uswds-theme configuration: @use "uswds-core" with ($theme-...) variables. Map your old customizations — brand colors, font stacks, banner text — to the equivalent $theme-*-token settings. Put them in one file so the next upgrade is a diff, not an archaeology project.

Step 4 — Diff the markup changes

A few components changed class names and markup between majors — the header, footer, and identifier are the usual suspects. Compare your templates against the current USWDS examples, not your memory of 2.x markup. Templates wrapped in Drupal SDC components make this a one-file change; inline markup makes it a hunt.

Step 5 — Verify with a checklist, not a glance

  • Header nav opens, closes, and traps focus on mobile
  • Skip link, banner accordion, and footer identifier render correctly
  • Forms keep their USWDS validation styling
  • Contrast still passes — token values shifted for some palette entries
  • No 404s for fonts or images the old package referenced

What it costs

On a well-factored theme this is a sprint, not a rebuild — one to two weeks including QA. On a theme with forked components it is closer to four. Either way it is cheaper than the alternative: staying on a frozen version until a forced upgrade lands on a deadline. If your Drupal theme is still on 2.x, this is exactly the kind of work we do.

Bring us your beautifully complicated problem.

↗