- Prop
variant- Type
"success" | "warning" | "error" | "neutral" | "accent" | undefined- Default
"neutral"- Requirement
- optional
Docs Components Core
Badge
React example follows below.
Vue example follows below.
Angular example follows below.
Svelte example follows below.
Solid example follows below.
- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
const badgeFixture = { id: "badge", items: [ { label: "Stable", variant: "success" }, { label: "Review", variant: "warning" }, ],} satisfies { id: string; items: Array<{ label: string; variant: "success" | "warning" }> }; import { Badge } from "@grassroot/ui-react"; export default function BadgeDemo() { return ( <div> {badgeFixture.items.map((item) => ( <Badge key={item.label} variant={item.variant}> {item.label} </Badge> ))} </div> );}- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
<script setup lang="ts">const badgeFixture = { id: "badge", items: [ { label: "Stable", variant: "success" }, { label: "Review", variant: "warning" }, ],} satisfies { id: string; items: Array<{ label: string; variant: "success" | "warning" }> }; import { Badge } from "@grassroot/ui-vue";</script> <template> <div> <Badge v-for="item in badgeFixture.items" :key="item.label" :variant="item.variant">{{ item.label }}</Badge> </div></template>- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
import { Component } from "@angular/core";const badgeFixture = { id: "badge", items: [ { label: "Stable", variant: "success" }, { label: "Review", variant: "warning" }, ],} satisfies { id: string; items: Array<{ label: string; variant: "success" | "warning" }> }; import { GrassrootBadge } from "@grassroot/ui-angular"; @Component({ selector: "app-badge-demo", standalone: true, imports: [GrassrootBadge], template: ` <div> @for (item of fixture.items; track item.label) { <grassroot-badge [variant]="item.variant">{{ item.label }}</grassroot-badge> } </div> `,})export class BadgeDemoComponent { protected readonly fixture = badgeFixture;} export default BadgeDemoComponent;- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
<script lang="ts"> const badgeFixture = { id: "badge", items: [ { label: "Stable", variant: "success" }, { label: "Review", variant: "warning" }, ], } satisfies { id: string; items: Array<{ label: string; variant: "success" | "warning" }> }; import { Badge } from "@grassroot/ui-svelte";</script> <div> {#each badgeFixture.items as item (item.label)} <Badge variant={item.variant}>{item.label}</Badge> {/each}</div>- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
/** @jsxImportSource solid-js */import { Badge } from "@grassroot/ui-solid";const badgeFixture = { id: "badge", items: [ { label: "Stable", variant: "success" }, { label: "Review", variant: "warning" }, ],} satisfies { id: string; items: Array<{ label: string; variant: "success" | "warning" }> }; import type { JSX } from "solid-js"; export default function BadgeDemo(): JSX.Element { return ( <div> {badgeFixture.items.map((item) => ( <Badge variant={item.variant}>{item.label}</Badge> ))} </div> );}Installation
API Reference
Import
import { Badge } from "@grassroot/ui-react";
Props
Prop
Type
Default
Requirement
variant"success" | "warning" | "error" | "neutral" | "accent" | undefined"neutral"optional
Content regions
children
Native attributes
Standard DOM and ARIA attributes not listed above spread onto the root element.
Import
import { Badge } from "@grassroot/ui-vue";
Props
Prop
Type
Default
Requirement
variant"neutral" | "accent" | "success" | "warning" | "error" | undefined"neutral"optional
- Prop
variant- Type
"neutral" | "accent" | "success" | "warning" | "error" | undefined- Default
"neutral"- Requirement
- optional
Content regions
default
Import
import { Component } from "@angular/core";
import { GrassrootBadge } from "@grassroot/ui-angular";
Props
Prop
Type
Default
Requirement
variant"neutral" | "accent" | "success" | "warning" | "error""neutral"optional
- Prop
variant- Type
"neutral" | "accent" | "success" | "warning" | "error"- Default
"neutral"- Requirement
- optional
Content regions
default
Import
import { Badge } from "@grassroot/ui-svelte";
Props
Prop
Type
Default
Requirement
variant"neutral" | "accent" | "success" | "warning" | "error""neutral"optional
classstring—
optional
- Prop
variant- Type
"neutral" | "accent" | "success" | "warning" | "error"- Default
"neutral"- Requirement
- optional
- Prop
class- Type
string- Default
- —
- Requirement
- optional
Content regions
children
Import
import { Badge } from "@grassroot/ui-solid";
import type { JSX } from "solid-js";
Props
Prop
Type
Default
Requirement
variant"neutral" | "accent" | "success" | "warning" | "error""neutral"optional
classNamestring—
optional
- Prop
variant- Type
"neutral" | "accent" | "success" | "warning" | "error"- Default
"neutral"- Requirement
- optional
- Prop
className- Type
string- Default
- —
- Requirement
- optional
Content regions
children
Native attributes
Standard DOM and ARIA attributes not listed above spread onto the root element.