BadgeSerializable via the SerializeAsBadge trait. Once an enum is badge-serializable, Core can render it as a styled badge chip anywhere in the UI — in table columns, page headers, DTOs, and forms — without any per-callsite configuration.
Defining a Badge Enum
app/Enums/CompanyStatus.php
Variants
| Variant | Color | Use case |
|---|---|---|
DEFAULT | Gray | Neutral states |
SECONDARY | Muted | Inactive, disabled |
SUCCESS | Green | Active, completed |
DESTRUCTIVE | Red | Errors, deletions |
WARNING | Yellow | Pending, caution |
INFO | Blue | Informational |
BRAND | Purple | Featured, branded |
Using in a DTO
Use the#[WithCastable] attribute to serialize the enum as BadgeData in your DTO:
status available as a BadgeData object on the frontend, which the <CoreBadge> component renders directly.
Using in a Table Column
Using in a Page Badge
Pass the enum directly to->badge() on a page — no manual BadgeData construction needed:
Rendering in React
data prop accepts the BadgeData object produced by the DTO.