{"slug":"badge","name":"Badge","category":"Display & Misc","summary":"A compact label for status, counts, or categories.","status":"stable","since":"0.2.0","import":"import { Badge } from '@elluzion/iv-ui';","usage":["`variant` colors the label; `neutral` stays monochrome.","`dismissible` adds a remove button wired to `ondismiss`.","Badges are not buttons; use `Toggle` for pressable chips."],"props":[{"name":"variant","type":"'neutral' | 'success' | 'error' | 'accent' | 'info'","default":"'neutral'","description":"Status color. `neutral` is the default.","required":false,"bindable":false},{"name":"size","type":"'sm' | 'md'","default":"'md'","description":"Badge size.","required":false,"bindable":false},{"name":"dismissible","type":"boolean","default":"false","description":"Shows a remove button.","required":false,"bindable":false},{"name":"className","type":"string","default":"''","description":"Extra classes merged onto the root element.","required":false,"bindable":false}],"events":[{"name":"dismiss","type":"() => void","default":null,"description":"Called when the remove button is pressed.","required":false,"bindable":false}],"snippets":[{"name":"children","type":"Snippet","default":null,"description":"Badge text.","required":true,"bindable":false}],"types":[],"manual":[],"tokens":["--iv_accent","--iv_badge-h-md","--iv_badge-h-sm","--iv_badge-pad-x-md","--iv_badge-pad-x-sm","--iv_border","--iv_error","--iv_font-mono","--iv_foreground","--iv_foreground-dim","--iv_info","--iv_outline-offset","--iv_outline-width","--iv_radius-sm","--iv_spacing-sm","--iv_spacing-xs","--iv_success","--iv_surface-elevated","--iv_surface-overlay","--iv_text-chips","--iv_text-xs","--iv_weight-semibold"],"cssHooks":["iv-accent","iv-badge","iv-badge-content","iv-badge-dismiss","iv-dismissible","iv-error","iv-info","iv-sm","iv-success"],"accessibility":{"notes":["Color is not the only signal; the text carries the meaning.","The dismiss control is a button with an accessible name.","Keep labels short; the badge truncates instead of wrapping."]},"related":[{"title":"Avatar","summary":"A circular identity image with initials and an optional presence dot.","url":"/components/avatar","kind":"Component"},{"title":"Alert","summary":"An inline message for information, success, warning, or error.","url":"/components/alert","kind":"Component"},{"title":"Shortcut","summary":"Renders a keyboard combination as key caps.","url":"/components/shortcut","kind":"Component"},{"title":"Card","summary":"A bordered surface for grouped content and actions.","url":"/components/card","kind":"Component"}],"examples":[{"id":"variants","title":"Variants","description":"Neutral, success, error, accent, and info.","code":"<script lang=\"ts\">\n\timport { Badge } from '@elluzion/iv-ui';\n</script>\n\n<div class=\"row\">\n\t<Badge>neutral</Badge>\n\t<Badge variant=\"success\">success</Badge>\n\t<Badge variant=\"error\">error</Badge>\n\t<Badge variant=\"accent\">accent</Badge>\n\t<Badge variant=\"info\">info</Badge>\n</div>\n\n<style>\n\t.row {\n\t\tdisplay: flex;\n\t\tflex-wrap: wrap;\n\t\talign-items: center;\n\t\tgap: var(--iv_spacing-sm);\n\t}\n</style>"},{"id":"sizes","title":"Sizes","description":"`sm` and `md` label heights.","code":"<script lang=\"ts\">\n\timport { Badge } from '@elluzion/iv-ui';\n</script>\n\n<div class=\"row\">\n\t<Badge size=\"sm\" variant=\"success\">stable</Badge>\n\t<Badge variant=\"success\">stable</Badge>\n\t<Badge size=\"sm\" variant=\"accent\">beta</Badge>\n\t<Badge variant=\"accent\">beta</Badge>\n</div>\n\n<style>\n\t.row {\n\t\tdisplay: flex;\n\t\tflex-wrap: wrap;\n\t\talign-items: center;\n\t\tgap: var(--iv_spacing-sm);\n\t}\n</style>"},{"id":"dismissible","title":"Dismissible","description":"A trailing remove button calls `ondismiss`.","code":"<script lang=\"ts\">\n\timport { Badge, Button } from '@elluzion/iv-ui';\n\n\tlet tags = $state(['edge', 'cache', 'read-only']);\n\n\tfunction remove(tag: string) {\n\t\ttags = tags.filter((value) => value !== tag);\n\t}\n</script>\n\n<div class=\"stack\">\n\t<div class=\"row\">\n\t\t{#each tags as tag (tag)}\n\t\t\t<Badge variant=\"neutral\" dismissible ondismiss={() => remove(tag)}>{tag}</Badge>\n\t\t{/each}\n\t\t{#if tags.length === 0}<span class=\"empty\">no tags</span>{/if}\n\t</div>\n\t{#if tags.length < 3}\n\t\t<Button size=\"sm\" variant=\"ghost\" onclick={() => (tags = ['edge', 'cache', 'read-only'])}>\n\t\t\tRestore\n\t\t</Button>\n\t{/if}\n</div>\n\n<style>\n\t.stack {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\talign-items: start;\n\t\tgap: var(--iv_spacing-sm);\n\t}\n\n\t.row {\n\t\tdisplay: flex;\n\t\tflex-wrap: wrap;\n\t\talign-items: center;\n\t\tgap: var(--iv_spacing-sm);\n\t}\n\n\t.empty {\n\t\tfont-family: var(--iv_font-mono);\n\t\tfont-size: var(--iv_text-sm);\n\t\tcolor: var(--iv_foreground-dim);\n\t}\n</style>"}],"markdown":"/components/badge.md","page":"/components/badge"}