AllergyBadge
ComplexClinical
<co-allergy-badge>AllergyBadge is the red allergy tag used in banners and lists, with severity in its title and optional label.
import { AllergyBadge } from 'health-components';
Examples
Severities
Compact
Usage
<AllergyBadge substance="Penicillin" severity="severe" reaction="Hives" showSeverity />
When to use
- Anywhere a patient is identified and a drug may be ordered.
When not to use
- Full allergy management: AllergyList.
Variants and states
| Variant | What it is |
|---|---|
| severe | Alert-circle icon. |
| moderate | Alert icon. |
| mild | Amber tone. |
| showSeverity | Adds "(Severe)" to the text. |
Accessibility
- Icon plus the word Allergy; severity in text when shown.
Do and don't
- Do: Show every allergy; wrap.
- Don't: "+2 more" that hides an allergy.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
substance * | string | — | Allergen ("Penicillin"); required |
severity | AllergySeverity | 'moderate' | 'severe' | 'moderate' | 'mild' |
reaction | string | none | Reaction ("Anaphylaxis"), shown in the tooltip and read by screen readers |
showSeverity | boolean | false | Shows the severity in the label ("Allergy: Penicillin (Severe)") |
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-allergy-badge>. 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-allergy-badge substance="…" severity="…" [defaultValue]="defaultValue"></co-allergy-badge>
| Kind | Name | Description |
|---|---|---|
| attribute | substance | Allergen ("Penicillin"); required |
| attribute | severity | 'severe' | 'moderate' | 'mild'; default 'moderate' |
| attribute | reaction | Reaction ("Anaphylaxis"), shown in the tooltip and read by screen readers; default none |
| attribute | show-severity / showSeverity | Shows the severity in the label ("Allergy: Penicillin (Severe)"); default false |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus |