Status Badges
The :badge field type renders a value as a coloured badge. Map each value to a cm-badge-* class with badge_class.
Quick exampleβ
column :status, field_type: :badge, badge_class: { approved: "cm-badge-green", draft: "cm-badge-yellow", rejected: "cm-badge-red" }
field :status, field_type: :badge, badge_class: STATUS_TAG_COLOR,
badge_helper_texts: { rejected: "Check rejection reason" }
badge_helper_texts adds a tooltip icon next to the badge for the given values.
The :tag field type and tag_class option were renamed to :badge and badge_class in v8.0.0. Using :tag raises an error at boot. See the v8.0.0 upgrade guide.
Optionsβ
| Class | Preview | Use Case Example |
|---|---|---|
cm-badge-blue | Sample | Active, In Progress, Enabled |
cm-badge-yellow | Sample | Pending, Awaiting, Draft |
cm-badge-orange | Sample | On Hold, Needs Review, Processing |
cm-badge-purple | Sample | Scheduled, Queued, Resolved |
cm-badge-cyan | Sample | Info, Beta, Staging |
cm-badge-green | Sample | Completed, Approved, Verified |
cm-badge-gray | Sample | Inactive, Archived, Unknown |
cm-badge-red | Sample | Rejected, Failed, Blocked, Deleted |
Removed aliasesβ
The following old class names are no longer supported: they have no styles, and field raises an error at boot if badge_class uses them. Replace them with the Catalyst equivalents:
| Removed | Use Instead |
|---|---|
active / active-one | cm-badge-blue |
active-two | cm-badge-yellow |
active-three | cm-badge-orange |
active-four | cm-badge-purple |
active-five | cm-badge-cyan |
completed | cm-badge-green |
neutral | cm-badge-gray |
danger | cm-badge-red |
Bootstrap badge color classes (bg-success, bg-warning, bg-danger, bg-secondary) are not supported as badge classes. Always use cm-badge-* Catalyst Tags.
Choosing a colourβ
- Use
cm-badge-greenfor positive terminal states (approved, verified, done) - Use
cm-badge-redfor negative terminal states (rejected, failed, blocked) - Use
cm-badge-grayfor inactive or non-significant states (archived, unknown) - Use
cm-badge-bluefor currently live or enabled items - Use
cm-badge-yellowfor items awaiting action (pending, draft) - Use
cm-badge-orangethroughcm-badge-cyanto differentiate multiple intermediate states when two or more non-red/green statuses exist - Never use Bootstrap badge color classes β they are not equivalent and will produce inconsistent styling
Recipesβ
Add a tooltip explaining a stateβ
badge_helper_texts maps values to tooltip text shown on an icon next to the badge:
field :status, field_type: :badge, badge_class: STATUS_TAG_COLOR,
badge_helper_texts: { rejected: "Check rejection reason" }