Skip to main content

PermissionState

ComplexAccess<co-permission-state>

PermissionState renders the four role-based states with the screens' exact wording: lock (view only), denied (no access), patient preview, and hidden.

import { PermissionState } from 'health-components';

Examples​

Showcase​

Storybook

Lock​

Storybook

Denied​

Storybook

Preview​

Storybook

Hidden​

Storybook

PermissionDenied​

Storybook

Usage​

{access === "view" && <PermissionState kind="lock" role="Biller" permission="Edit clinical chart" />}
{access === "none" && <PermissionState kind="denied" role="Front Desk" permission="Manage claims" />}

When to use​

  • Top of any screen the role can only view (lock), in place of a screen the role cannot open (denied), staff looking at portal screens (preview).

When not to use​

  • Errors from the server: Alert error.

Variants and states​

VariantWhat it is
lockView level: banner, fields read-only, save buttons hidden.
deniedNone level reached by link: full card with Go to my home screen and Compare roles.
previewStaff viewing patient screens.
hiddenNone level inside a screen: render nothing. Shown here only as a note.

Accessibility​

  • denied is role alert; lock is role status.

Do and don't​

  • Do: Always name the role and the permission.
  • Don't: Disable buttons without saying why.

Props​

PropTypeDefaultDescription
kindPermissionStateKind'lock''lock' | 'denied' | 'preview' | 'hidden'
role *string—The viewer's role ("Biller", "Front Desk"). Required
permissionstring"Manage claims"Permission the role lacks; required for lock and denied
homestringnoneHref of the staff home: "Back to staff app" (preview) and "Go to my home screen" (denied)
onHome(event: MouseEvent<HTMLElement>) => voidnone"Go to my home screen" (denied) or "Back to staff app" (preview) clicked
onCompareRoles() => voidnone"Compare roles" clicked (denied)

Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, plus className and event handlers on the root element.

Angular, Vue and HTML​

Register the elements once (Angular guide), then use <co-permission-state>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.

Angular template
<co-permission-state kind="…" role="…" [defaultValue]="defaultValue" (co-home)="onHome($event.detail)"></co-permission-state>
KindNameDescription
attributekind'lock' | 'denied' | 'preview' | 'hidden'; default 'lock'
attributeroleThe viewer's role ("Biller", "Front Desk"). Required
attributepermissionPermission the role lacks; required for lock and denied; default "Manage claims"
attributehomeHref of the staff home: "Back to staff app" (preview) and "Go to my home screen" (denied); default none
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus
eventco-home"Go to my home screen" (denied) or "Back to staff app" (preview) clicked; default none (React: onHome)
eventco-compare-roles"Compare roles" clicked (denied); default none (React: onCompareRoles)