Skip to main content

RestraintAudit

A development aid: watches the rendered page for the countable rules of the UI guidelines (one accent button per view, no nested cards, no stacked dialogs, no tabs in tabs, four key figures, one banner, 44px touch targets) and reports what breaks them in the console. Renders nothing; does nothing in production.

Signature
Density
Viewport
Theme and light/dark are set in the top bar
Live demo
Open ↗

When to use​

A development aid: watches the rendered page for the countable rules of the UI guidelines (one accent button per view, no nested cards, no stacked dialogs, no tabs in tabs, four key figures, one banner, 44px touch targets) and reports what breaks them in the console.

Accessibility​

Fully keyboard operable: Tab to focus, Enter/Space to activate. The visible focus ring uses --focus-ring — never remove it. Provide an accessible label (aria-label) for icon-only controls.

Install and import​

npx shadcn@latest add @prism/restraint-audit
import { RestraintAudit } from '@/components/prism/RestraintAudit';

In a no-build prototype, read it from the bundle instead: const { RestraintAudit } = window.PrismDesignSystem_39d121;

Props​

PropTypeRequiredDescription
enabledboolean—Run the audit. Default: true in a development build, false in production.
outlineboolean—Outline the offending elements (sets data-restraint="<rule>" on them). Default true.
onReport(findings: RestraintFinding[]) =&gt; void—Called with the findings whenever they change, e.g. to fail an end-to-end test.
rootElement | string—The element, or a selector for it, to audit. Default: the document body.