badge() html()
A coloured badge or label with escaped text.
html()->badge($text = '', $extra = [])Options
| Option | Meaning |
|---|---|
type | primary, secondary, success, danger, warning, info, light, dark. |
pill | Rounded. |
class_add, id, title, style, no_escape, data-*, attr | Attributes; no_escape prints HTML. |
Example
primary secondary success danger warning info light dark 12 <b>escaped</b> {braces}
Code
$out = '';
foreach (['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'] as $type) {
$out .= html()->badge($type, ['type' => $type]) . ' ';
}
return $out . html()->badge('12', ['type' => 'danger', 'pill' => 1]) . ' ' . html()->badge('<b>escaped</b> {braces}', ['type' => 'info']);Bootstrap 3 and 5
Bootstrap 5 badge text-bg-<type>, Bootstrap 4 badge badge-<type>, Bootstrap 3 label label-<type> (a pill keeps the colour, not the round corners).
See also: html/button, table/text