Role Preview

Role Preview is a copy-paste React component that stops gave a teammate admin by mistake before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/role-preview
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsGave a teammate admin by mistake

Was this component page useful?

How do I install Role Preview?

pnpm dlx shadcn@latest add @bollard/role-preview

The files land in your project. They're yours to edit.

How do I use Role Preview in React?

role-preview-usage.tsx
import { RolePreview } from "@/components/ui/role-preview"

<RolePreview
  roles={roles}
  capabilities={capabilities}
  matrix={matrix}
  defaultValue="admin"
  currentRole="viewer"
  personName="Priya"
  label="Priya's role in Acme Corp"
/>

What input mistakes does Role Preview catch?

  • Permissions gained and lost versus the current role
  • Dangerous capabilities (cost money, destroy data, widen access) marked
  • A smaller role that drops the dangerous extras, with one-tap switch

What props does Role Preview accept?

RolePreview props
PropTypeDefault
roles* (required)

Roles in order from least to most access.

RoleOption[]—
capabilities* (required)

Everything a role can grant, in the order to list it.

Capability[]—
matrix* (required)

Permissions matrix: role id to the capability ids it grants.

Record<string, string[]>—
value

The selected role id (controlled).

string—
defaultValue

The initially selected role id when uncontrolled.

string—
onValueChange

Called with the role id the user picks, including from the suggestion.

(roleId: string) => void—
currentRole

The person's role today, used to show what changes. Omit for new invites.

string—
personName

Who you're choosing for, e.g. "Priya".

string—
label

Visible label of the role group.

string"Role"
currentBadge

Badge on the person's current role.

string"Current"
sensitiveBadge

Badge on dangerous capabilities.

string"Sensitive"

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Role Preview accessible?

  • Role select has a visible label
  • Diff list has an aria-label and renders in a polite live region
  • Can/Cannot prefixes and "Can no longer" are text, not colour alone; icons are aria-hidden

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Authorize role changes on the server and check permissions per request; this only previews the role.

  • Only as accurate as the role matrix you pass
  • Suggestion is mechanical least-privilege; it doesn't know what the person actually needs

What expensive mistakes does Role Preview stop?

Gave a teammate admin by mistake

Also known as

roles · permissions · rbac · team members · invite · admin · access control · member settings

What dependencies does Role Preview require?

Role Preview facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameRole Preview
Registry identifier@bollard/role-preview
Install commandnpx shadcn@latest add @bollard/role-preview
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Role Preview

What form validation mistake does Role Preview catch?

Role Preview prevents gave a teammate admin by mistake. Shows what a chosen role can and can't do, the diff from the current role, and a smaller role when the pick adds risky permissions. Catches: Permissions gained and lost versus the current role, Dangerous capabilities (cost money, destroy data, widen access) marked, A smaller role that drops the dangerous extras, with one-tap switch. Limitation: validate role-preview schemas on backend.

How do I install role-preview with shadcn?

Run `npx shadcn@latest add @bollard/role-preview`. Sources added: registry/default/role-preview/role-preview.tsx. Package requirements: lucide-react.

What props customize Role Preview?

Role Preview accepts `roles`, `capabilities`, `matrix`, `value`, `defaultValue`. Configures roles, permissions, rbac behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of role-preview?

Only as accurate as the role matrix you pass. Suggestion is mechanical least-privilege; it doesn't know what the person actually needs Server requirement: Authorize role changes on the server and check permissions per request; this only previews the role.

How does Role Preview meet accessibility guidelines?

Role select has a visible label. Diff list has an aria-label and renders in a polite live region. Can/Cannot prefixes and "Can no longer" are text, not colour alone; icons are aria-hidden. Minimizes errors: gave too many permissions, admin role by mistake.

Which components pair with Role Preview?