# WBadge

Inline status or label pill. Composes a pill-shaped `WDiv` (rounded-full, inline-flex) around a `WText` (text-xs). All visual styling is className-driven: the caller supplies tone via `bg-*` and `text-*` tokens (with `dark:` pairs); no colors are baked in.

## Table of Contents

- [Basic Usage](#basic-usage)
- [Props](#props)
- [Constructor](#constructor)
- [Styling Examples](#styling-examples)
- [Related Documentation](#related-documentation)

## Basic Usage

```dart
WBadge(
  'Active',
  className: 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100',
)
```

## Props

| Prop | Type | Default | Description |
|:-----|:-----|:--------|:------------|
| `label` | `String` | **Required** | The text displayed inside the badge. |
| `className` | `String?` | `null` | Caller-supplied utility classes appended after the default layout classes (`inline-flex items-center rounded-full px-2 py-0.5`). Use this to supply `bg-*`, `text-*`, and their `dark:` pairs. |

## Constructor

```dart
WBadge(
  String label, {
  Key? key,
  String? className,
})
```

`label` is a required positional parameter.

## Styling Examples

### Status Tones

Supply tone through `bg-*` + `text-*` + their `dark:` pairs. The default layout provides no background or text color:

```dart
// Success
WBadge('Paid', className: 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100')

// Warning
WBadge('Pending', className: 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100')

// Danger
WBadge('Error', className: 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100')

// Neutral
WBadge('Draft', className: 'bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300')
```

### Inline Beside Text

`WBadge` is `inline-flex` by default, so it sits naturally beside other inline widgets in a `flex-row` container:

```dart
WDiv(
  className: 'flex flex-row items-center gap-2',
  children: [
    WText('Invoice #1042', className: 'text-base font-medium text-gray-900 dark:text-white'),
    WBadge('Paid', className: 'bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-200'),
  ],
)
```

### With a WindRecipe

Use `WindRecipe` to drive tone from a variant axis instead of repeating className strings:

```dart
final badge = WindRecipe(
  base: 'inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium',
  variants: {
    'tone': {
      'success': 'bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200',
      'warning': 'bg-yellow-100 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-200',
    },
  },
  defaultVariants: {'tone': 'success'},
);

WBadge('Deployed', className: badge(variants: {'tone': 'success'}))
WBadge('Pending',  className: badge(variants: {'tone': 'warning'}))
```

## Related Documentation

- [WDiv](https://anilcancakir.com/wind_kit/docs/v1.4/widgets/w-div.md): the pill container `WBadge` delegates to internally.
- [WText](https://anilcancakir.com/wind_kit/docs/v1.4/widgets/w-text.md): the label renderer inside the badge.
- [WindRecipe](https://anilcancakir.com/wind_kit/docs/v1.4/styling/wind-recipe.md): compose badge tone variants without repeating className strings.
