Scan your whole stack
Are you using @govuk-react/primitives?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.8.0
@govuk-react/primitives was last scanned on 23 Nov 2026 at version 0.8.0. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.8.0 LATEST | 23 Nov 2026 | No rules fired |
| 0.7.0 | 22 Nov 2026 | No rules fired |
| 0.6.0 | 21 Nov 2026 | No rules fired |
| 0.5.0 | 20 Nov 2026 | Not shown |
| 0.4.0 | 20 Nov 2026 | Not shown |
Findings for v0.8.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.8.0; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
Headless behaviour for design system components, as light-DOM custom elements with unstyled React parts over them. It sets no look and ships no GOV.UK markup, so any library can use it. govuk-react's components are the reference implementation, built with govuk-frontend-react's markup.
Each primitive:
value and onValueChange, or open and onOpenChangeonValueChange or onOpenChange, with the new state and { beforeHydration }, rather than a native event such as onToggle. A change the user made before hydration is reported once React hydrates, when there is no event to pass. Native event props still pass through, for changes after hydrationasChild on its parts, so you render your own elements. A Root is the custom elementTrigger, and a text prop ends in Text when it's shown, Label when it's an accessible name and Announcement when only screen readers hear itImport each primitive from its own path, such as @govuk-react/primitives/tabs. Each path defines its element when imported.
Prefer uncontrolled: leave out value and open, start from defaultValue or defaultOpen where there is one, and listen with onValueChange or onOpenChange. The markup then holds the state, so it's the same before hydration, without React and without JavaScript.
Control a primitive only when your app has to set its state, such as closing a menu after navigating. When controlled, a user's action calls the change handler and the primitive changes only when the prop does. That has limits that can't be removed:
close() on a dialog, nor a script calling showModal() before it fired beforetoggle on dialogs (Chrome 132, Firefox 133 and Safari 26). A controlled Modal reports such a change through onOpenChange and, unless open changes within 100ms, puts the dialog back as open says. So it always ends up matching open, but the user can see it change and change back.onValueChange and onOpenChange on Tabs, Accordion, Disclosure, Details and Modal, onQueryChange on Autocomplete, and the handlers of a controlled field, get a second argument, { beforeHydration }. It's true for a change the user made before React hydrated, which is reported once React has hydrated, whether or not the primitive is controlled.
Such a report differs from a live change:
So where one primitive's handler changes another's state, or has side effects, check the argument and decide what a late report should do:
<Tabs.Root
value={tab}
onValueChange={(value, { beforeHydration }) => {
if (beforeHydration) return;
setTab(value);
}}
>
Returning without changing value puts the tabs back to value.
Load the package's stylesheet once, or copy its rules into your own. Its rules only set display:
display: contents, so it adds no box between your markup and its parent, such as a flex or grid container. The rule has no specificity, so a class of yours that sets display on the element wins, and hidden still hides it.import '@govuk-react/primitives/styles.css';
No part renders a style element or attribute, so the primitives work under a strict Content Security Policy.
Each element is also exported on its own, with no React, from @govuk-react/primitives/<name>-element, such as tabs-element. Importing it defines the element, such as <govuk-react-tabs>. Render the same markup as the React parts do: the element finds its parts by data- attributes, takes its options as attributes, and reports changes with bubbling events named after it, such as govuk-react-tabs:change. An attribute sets only where the state starts, such as default-value. A user's change to Tabs, Accordion or Disclosure fires a cancelable change event: cancel it to leave the state as it is. To control the state, use the primitive's controller, kept out of the element so its inline script stays small: TabsController and AccordionController take a value, which for Accordion is an array, and DisclosureController and ModalController take open. Set it back to undefined to stop controlling the state.
import { ModalController } from '@govuk-react/primitives/modal-controller';
const controller = new ModalController(element);
controller.open = true;
The comment at the top of each element's source lists its markup, attributes, properties and events:
accordion, auto-focus, autocomplete, button, character-count, choices, disclosure, exit-this-page, file-upload, focus-links, modal, password-input and tabs.
Each element that changes how its markup shows sets data-upgraded on itself once upgraded, to style it apart from its fallback.
Each element is also built as a small, self-contained classic script, with no imports and no React, at @govuk-react/primitives/inline/<name>-element.js, such as inline/tabs-element.js. Inline the ones your page uses, so the markup is interactive as soon as it loads, before React has downloaded and hydrated. React's parts then pick up from the elements, including anything the user did before hydration. Each element is defined only once, whichever runs first: the inline script or React's bundle. So inline the scripts from the same version of this package as the one in your bundle.
Without its inline script, an element upgrades once your bundle has loaded, and until then the page shows the markup as it is without JavaScript. The accordion, tabs, disclosure and file upload change the page's layout when they upgrade: an accordion's sections all start open, then close. With the script inlined in the head, the element upgrades as it is parsed, before the browser first paints it.
To render them from React on the server, inline-script has each script as a string, and an InlineScript component:
import { InlineScript, tabs } from '@govuk-react/primitives/inline-script';
<head>
<InlineScript script={tabs} nonce={nonce} />
</head>;
The scripts are accordion, autocomplete, autoFocus, button, characterCount, choices, disclosure, exitThisPage, fileUpload, focusLinks, modal, passwordInput and tabs. InlineScript renders only on the server, so the scripts stay out of client bundles: it has no 'use client' directive, and in Astro it needs no client:* directive. A script React adds in the browser doesn't run, and isn't needed, since React's parts define their elements.
import * as Accordion from '@govuk-react/primitives/accordion';
<Accordion.Root defaultValue={['web']}>
<Accordion.Controls>
<Accordion.ShowAll>
<Accordion.ShowAllText />
</Accordion.ShowAll>
</Accordion.Controls>
<Accordion.Item value="web">
<h2>
<Accordion.Fallback>Writing well for the web</Accordion.Fallback>
<Accordion.Trigger>
<Accordion.Label>Writing well for the web</Accordion.Label> <Accordion.ToggleText />
</Accordion.Trigger>
</h2>
<Accordion.Content id="web-content">…</Accordion.Content>
</Accordion.Item>
</Accordion.Root>;
Without JavaScript every section is shown under its Fallback heading. It needs the package's stylesheet. Each section also renders a hidden Trigger with the same heading, which the element shows on upgrade while hiding the fallback. Nothing is moved, so React can keep rendering the markup. Closed content gets hidden="until-found", so find in page opens it. Pass hidden to Content to use plain hidden instead. Labels name the trigger, followed by "Show this section" or "Hide this section".
Once upgraded, each item, trigger and content has data-state ("open" or "closed").
ShowAll opens every section, or closes them all when every one is open. value and onValueChange control the open sections once hydrated, and a section opened before hydration is reported rather than undone. As in govuk-frontend, open sections are remembered for the session by content id, unless rememberExpanded is false. In an island without a Root, pass defaultExpanded to Item.
Like govuk-frontend's accordion, it doesn't use details and summary. They work without JavaScript, so you might expect them to be the better choice, but GOV.UK's research and accessibility audits found problems with them:
summary with standard commands, only by speaking all of its text. GOV.UK decided not to fix this in its details component, because adding role="button" caused problems for some screen readers. The accessibility audit that found it suggested building it as a button, as the accordion is (govuk-design-system#4029, govuk-frontend#5308).details can't be made to show its content when printed (govuk-design-system#6031).summary as a button (govuk-design-system#1259), so a heading inside one isn't reliably announced as a heading. Each section's heading has to stay a heading, so users can find sections with a screen reader's heading navigation. Here the heading holds the button, as in the WAI-ARIA accordion pattern.details hides its content without JavaScript.GOV.UK still uses details for a single, short piece of help that users can open.
import * as Tabs from '@govuk-react/primitives/tabs';
<Tabs.Root defaultValue="past-day">
<Tabs.List>
<Tabs.Trigger value="past-day">Past day</Tabs.Trigger>
<Tabs.Trigger value="past-week">Past week</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="past-day">…</Tabs.Content>
<Tabs.Content value="past-week">…</Tabs.Content>
</Tabs.Root>;
Each panel holds a hidden radio, and the radio group is the source of truth, as in the reference. Choosing a tab checks its radio, and the radio's native change updates the tabs and calls onValueChange.
The root sets how the tabs work without JavaScript, and its parts match it:
Root, with Trigger and Content: each tab links to its panel, and every panel shows.RadiosRoot, with RadiosTrigger and RadiosContent: each tab is a label for a hidden radio in its panel, so tabs switch with no JavaScript when clicked. It needs defaultValue or value. Without JavaScript the labels can't be reached by keyboard, as in the reference. Pass name when tabs render in separate React roots, such as islands. It needs the package's stylesheet.They are separate components rather than a prop, because a prop can change after the first render, and the markup each needs can't.
When controlled with value, a user's choice calls onValueChange and the tab changes only when value does. value applies once hydrated, so tabs still switch before then, and a tab picked before hydration is reported through onValueChange rather than undone.
orientation ("horizontal" or "vertical") sets the axis of the arrow keys. Horizontal arrow keys follow the page's direction, so in right-to-left text the left arrow moves to the next tab. Once upgraded, the root, list, tabs and panels have data-orientation, and the tabs, items and panels have data-state ("active" or "inactive").
media limits the tab behaviour to a media query, and can change. Below it, Root's tabs are a list of links to panels, and RadiosRoot's keep switching through their radios. With Root, the URL hash follows the selected tab, as in govuk-frontend.
Each value is also its panel's id, and its tab links to it, so it must be unique on the page and valid as an id. For another id, pass id to the panel and the matching href to its Trigger.
In an island without a root, pass name and defaultSelected to the triggers and panels. upgradedClass, activeItemClass and hiddenContentClass add classes for styles that key off classes rather than data-state, aria-selected and hidden.
Without React, the markup includes a hidden radio as the first child of each panel.
It follows the Tabs reference in react-design-system-apis.
import * as Disclosure from '@govuk-react/primitives/disclosure';
<nav aria-label="Menu">
<Disclosure.Root media="(min-width: 40.0625em)">
<Disclosure.Trigger>Menu</Disclosure.Trigger>
<Disclosure.Content asChild>
<ul id="navigation">…</ul>
</Disclosure.Content>
</Disclosure.Root>
</nav>;
A button that shows and hides some content, such as a navigation menu on small screens. Without JavaScript the content is shown and the button hidden. While media matches, the content is always shown and the button hidden. Closed content gets plain hidden. Pass hidden="until-found" to Content so find in page can open it.
open and onOpenChange control it once hydrated, such as to close a menu after navigating. A user's click before hydration is reported through onOpenChange rather than undone. defaultOpen starts it open. Once upgraded, the root, button and content have data-state ("open" or "closed"), and "open" while media matches.
detailsLike govuk-frontend's service navigation, it doesn't use details and summary. They work without JavaScript, so you might expect them to be the better choice, but GOV.UK's research and accessibility audits found problems with them:
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.