Skip to main content

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.

note

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​

ClassPreviewUse Case Example
cm-badge-blueSampleActive, In Progress, Enabled
cm-badge-yellowSamplePending, Awaiting, Draft
cm-badge-orangeSampleOn Hold, Needs Review, Processing
cm-badge-purpleSampleScheduled, Queued, Resolved
cm-badge-cyanSampleInfo, Beta, Staging
cm-badge-greenSampleCompleted, Approved, Verified
cm-badge-graySampleInactive, Archived, Unknown
cm-badge-redSampleRejected, 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:

RemovedUse Instead
active / active-onecm-badge-blue
active-twocm-badge-yellow
active-threecm-badge-orange
active-fourcm-badge-purple
active-fivecm-badge-cyan
completedcm-badge-green
neutralcm-badge-gray
dangercm-badge-red
warning

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​

  1. Use cm-badge-green for positive terminal states (approved, verified, done)
  2. Use cm-badge-red for negative terminal states (rejected, failed, blocked)
  3. Use cm-badge-gray for inactive or non-significant states (archived, unknown)
  4. Use cm-badge-blue for currently live or enabled items
  5. Use cm-badge-yellow for items awaiting action (pending, draft)
  6. Use cm-badge-orange through cm-badge-cyan to differentiate multiple intermediate states when two or more non-red/green statuses exist
  7. 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" }