Badge
Description
A component to display a badge
Badges, Tags, and Chips are small visual elements used to categorize content, highlight status, or display metadata.
They come in various styles: Badges are typically static indicators, Tags are for categorization, and Chips often include interactive elements like a removal button.
API reference
public enum BadgeTonePredefined visual tones used to color the Badge component.
- Namespace
- Tesserae
public abstract class TokenBase<T> : ComponentBase<T, HTMLElement> where T : TokenBase<T>- Namespace
- Tesserae
- Inheritance
- ComponentBase<T, HTMLElement> → TokenBase<T>
Properties
| Name | Description |
|---|---|
| Text | Gets or sets the text shown in the component. |
| Icon | Gets or sets the icon shown by the component. |
| IsPill | Returns a value indicating whether the component is pill. |
| IsOutline | Returns a value indicating whether the component is outline. |
| IsFilled | Returns a value indicating whether the component is filled. |
public string Text { get ; set ; }Gets or sets the text shown in the component.
public string Icon { get ; set ; }Gets or sets the icon shown by the component.
public bool IsPill { get ; set ; }Returns a value indicating whether the component is pill.
public bool IsOutline { get ; set ; }Returns a value indicating whether the component is outline.
Methods
| Name | Description |
|---|---|
| SetText | Sets the text of the component. |
| SetIcon | Sets the icon of the component. |
| Pill | Configures the component to pill. |
| Outline | Configures the component to outline. |
| Filled | Configures the component to filled. |
| Background | Gets or sets the CSS background of the component. |
| Foreground | Gets or sets the CSS color (foreground) of the component. |
| Tone | Configures the component to tone. |
| Primary | Styles the component using the primary tone. |
| Success | Styles the component using the success tone. |
| Warning | Styles the component using the warning tone. |
| Danger | Styles the component using the danger tone. |
| Info | Styles the component using the informational tone. |
| Neutral | Configures the component to neutral. |
| OnRemove | Registers a callback invoked when the remove event fires. |
| Removable | Configures the component to removable. |
| Render | Renders the component's root HTML element. |
public T Background(string color)Gets or sets the CSS background of the component.
public T Foreground(string color)Gets or sets the CSS color (foreground) of the component.
public T OnRemove(Action<T> onRemove)Registers a callback invoked when the remove event fires.
public T Removable(bool value = true)Configures the component to removable.
public sealed class Badge : TokenBase<Badge>- Namespace
- Tesserae
- Inheritance
- TokenBase<Badge> → Badge
Constructors
| Name | Description |
|---|---|
| Badge | Initializes a new instance of this class. |
public sealed class Tag : TokenBase<Tag>- Namespace
- Tesserae
- Inheritance
- TokenBase<Tag> → Tag
Constructors
| Name | Description |
|---|---|
| Tag | Initializes a new instance of this class. |
public sealed class Chip : TokenBase<Chip>- Namespace
- Tesserae
- Inheritance
- TokenBase<Chip> → Chip
Constructors
| Name | Description |
|---|---|
| Chip | Initializes a new instance of this class. |
Samples
Standard Badges
Tags and Chips
Tags and chips support icons, pill shapes, and interactive removal.