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.
Samples
Standard Badges
Tags and Chips
Tags and chips support icons, pill shapes, and interactive removal.
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. |
| Tint | Tints the token with any CSS colour: a translucent fill and border of it, and text mixed from it and the page's foreground, so it stays readable in light and dark mode - the way an issue tracker draws a label whose colour a user picked. Pass null to remove the tint. |
| 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. |
| AI | Styles the component using the AI tone - the filled purple-to-blue gradient, or the tint and accent when combined with Outline. A badge is small enough that the tint alone would not read, which is why this one fills. |
| 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 Tint(string color)Tints the token with any CSS colour: a translucent fill and border of it, and text mixed from it and the page's foreground, so it stays readable in light and dark mode - the way an issue tracker draws a label whose colour a user picked. Pass null to remove the tint.
public T AI(bool strongEffect = false)Styles the component using the AI tone - the filled purple-to-blue gradient, or the tint and accent when combined with Outline. A badge is small enough that the tint alone would not read, which is why this one fills.
Parameters
- strongEffect
- Asks for the louder form of the AI styling. A custom theme that tones the AI look down (e.g. Tesserae.Themes.Curiosity) brings more of it back for this element; the default theme draws both forms the same today. Sets the
tss-ai-strongclass.
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. |