 Search
components/badge: Badge components/button: Button components/checkbox: Checkbox components/dialog: Dialog components/input: Input components/popover: Popover components/pre: Pre components/radio: Radio components/separator: Separator components/switch: Switch components/table: Table components/textarea: Textarea components/tooltip: Tooltip components/typography: Typography plugins/plugin-nf: Nerd Font Plugin plugins/theme-catppuccin: Catppuccin Theme plugins/theme-gruvbox: Gruvbox Theme plugins/theme-nord: Nord Theme start/changelog: Changelog start/ascii-boxes: ASCII Boxes start/intro: Introduction start/intro: ## Features start/plugins: Plugins start/plugins: ## Official Plugins start/plugins: ### Themes start/plugins: ## Community Plugins contributing/contributing: Contributing contributing/contributing: ## Local Development contributing/contributing: ## Issues contributing/contributing: ## Pull Requests contributing/style-guide: Style Guide contributing/style-guide: ## CSS Units contributing/style-guide: ## Selectors contributing/style-guide: ## Documentation plugins/plugin-dev: Developing Plugins plugins/plugin-dev: ### Style Layers start/tuis-vs-guis: TUIs vs GUIs start/tuis-vs-guis: ## Monospace Fonts start/tuis-vs-guis: ## Character Cells installation/nextjs: Next.js installation/vite: Vite start/theming: Theming start/theming: ## CSS Variables start/theming: ### Font Styles start/theming: ### Colors start/theming: ### Light & Dark start/theming: ## Theme Plugins start/installation: Installation start/installation: ## Installation start/installation: ## Using CSS start/installation: ## Using ESM start/installation: ## Using a CDN start/installation: ## Full Library Import start/installation: ### CSS start/installation: ### ESM start/installation: ### CDN installation/astro: Astro installation/astro: ## Scoping installation/astro: ### Frontmatter Imports installation/astro: ### <style> tag installation/astro: ### Full Library Import

Badge

Displays a badge

<span is-="badge">Badge</span>

Import

@import "@webtui/css/components/badge.css";

Usage

<span is-="badge">badge</span>

Examples

Variants

Use the variant- attribute to change the color of a badge

<span is-="badge" variant-="foreground1">foreground1</span>
<span is-="badge" variant-="background2">background2</span>
<span is-="badge" variant-="background0">background0</span>
<span is-="badge" variant-="background1">background1</span>
<span is-="badge" variant-="background2">background2</span>
<span is-="badge" variant-="background3">background3</span>
<span is-="badge" variant-="foreground0">foreground0</span>
<span is-="badge" variant-="foreground1">foreground1</span>
<span is-="badge" variant-="foreground2">foreground2</span>

Available variants match the base theme colors

Caps

Use the cap- attribute to customize badges’ end cap styles

<span is-="badge">square</span>
<span is-="badge" cap-="round">round</span>
<span is-="badge" cap-="triangle">triangle</span>
<span is-="badge" cap-="square">square</span>
<span is-="badge" cap-="round">round</span>
<span is-="badge" cap-="triangle">triangle</span>
<span is-="badge" cap-="ribbon">ribbon</span>
<span is-="badge" cap-="slant-top">slant-top</span>
<span is-="badge" cap-="slant-bottom">slant-bottom</span>

Pass two values separated by a space to customize the start and end cap styles

<span is-="badge" cap-="square round">square round</span>
<span is-="badge" cap-="round ribbon">round ribbon</span>
<span is-="badge" cap-="ribbon triangle">ribbon triangle</span>
<span is-="badge" cap-="triangle slant-top">triangle slant-top</span>
<span is-="badge" cap-="slant-top slant-bottom">slant-top slant-bottom</span>
<span is-="badge" cap-="slant-bottom square">slant-bottom square</span>

Reference

Properties

Use the following custom CSS properties to style badges

  • --badge-color: The color of the badge
  • --badge-text: The text color of the badge
#my-custom-badge {
  --badge-color: #ffffff;
  --badge-text: #000000;
}

Using background-color directly will color behind the badge instead of coloring the badge shape

<span is-="badge" cap-="slant-top">badge</span>
span[is-="badge"] {
  --badge-color: var(--foreground0);
  --badge-text: var(--background0);
  background-color: grey;
}

Extending

To extend the Badge stylesheet, define a CSS rule on the components layer

@layer components {
    [is-~="badge"] {
        &[variant-="red"] {
            --badge-color: red;
            --badge-text: white;
        }

        /* ... */
    }
}

Scope

  • All elements with the is-~="badge" selector
[is-~="badge"] { /* ... */ }