# Badge

Highlight information like status, category, or count.

```tsx
import { Badge } from '@fluxui-dev/react';

<Badge color="lime">New</Badge>
```

## Sizes

Choose between three different sizes for your badges with the `size` prop.

```tsx
<Badge size="sm">Small</Badge>
<Badge>Default</Badge>
<Badge size="lg">Large</Badge>
```

## Icons

Add icons to badges with the `icon` and `iconTrailing` props, passed as components.

```tsx
import { DocumentTextIcon, UserCircleIcon, VideoCameraIcon } from '@fluxui-dev/react/icons';

<Badge icon={UserCircleIcon}>Users</Badge>
<Badge icon={DocumentTextIcon}>Files</Badge>
<Badge iconTrailing={VideoCameraIcon}>Videos</Badge>
```

## Rounded

Display badges with a fully rounded border radius using the `rounded` prop.

```tsx
import { UserIcon } from '@fluxui-dev/react/icons';

<Badge rounded icon={UserIcon}>Users</Badge>
```

## As button

Make the entire badge clickable by wrapping it in a button element.

```tsx
import { PlusIcon } from '@fluxui-dev/react/icons';

<Badge render={<button type="button" />} rounded icon={PlusIcon} size="lg">Amount</Badge>
```

## With close button

Make a badge removable by appending a close button.

```tsx
<Badge>
    Admin <Badge.Close aria-label="Remove" />
</Badge>
```

## Colors

Choose from an array of colors to differentiate between badges and convey emotion.

```tsx
<Badge color="zinc">Zinc</Badge>
<Badge color="red">Red</Badge>
<Badge color="orange">Orange</Badge>
<Badge color="amber">Amber</Badge>
<Badge color="yellow">Yellow</Badge>
<Badge color="lime">Lime</Badge>
<Badge color="green">Green</Badge>
<Badge color="emerald">Emerald</Badge>
<Badge color="teal">Teal</Badge>
<Badge color="cyan">Cyan</Badge>
<Badge color="sky">Sky</Badge>
<Badge color="blue">Blue</Badge>
<Badge color="indigo">Indigo</Badge>
<Badge color="violet">Violet</Badge>
<Badge color="purple">Purple</Badge>
<Badge color="fuchsia">Fuchsia</Badge>
<Badge color="pink">Pink</Badge>
<Badge color="rose">Rose</Badge>
```

## Solid variant

Bold, high-contrast badges for more important status indicators or alerts.

```tsx
<Badge variant="solid" color="zinc">Zinc</Badge>
<Badge variant="solid" color="red">Red</Badge>
<Badge variant="solid" color="orange">Orange</Badge>
<Badge variant="solid" color="amber">Amber</Badge>
<Badge variant="solid" color="yellow">Yellow</Badge>
<Badge variant="solid" color="lime">Lime</Badge>
<Badge variant="solid" color="green">Green</Badge>
<Badge variant="solid" color="emerald">Emerald</Badge>
<Badge variant="solid" color="teal">Teal</Badge>
<Badge variant="solid" color="cyan">Cyan</Badge>
<Badge variant="solid" color="sky">Sky</Badge>
<Badge variant="solid" color="blue">Blue</Badge>
<Badge variant="solid" color="indigo">Indigo</Badge>
<Badge variant="solid" color="violet">Violet</Badge>
<Badge variant="solid" color="purple">Purple</Badge>
<Badge variant="solid" color="fuchsia">Fuchsia</Badge>
<Badge variant="solid" color="pink">Pink</Badge>
<Badge variant="solid" color="rose">Rose</Badge>
```

## Inset

If you're using badges alongside inline text, you might run into spacing issues because of the extra padding around the badge. Use the `inset` prop to add negative margins to the top and bottom of the badge to avoid this.

```tsx
import { Heading, Text } from '@fluxui-dev/react';

<Heading>
    Page builder <Badge color="lime" inset="top bottom">New</Badge>
</Heading>

<Text className="mt-2">Easily author new pages without leaving your browser.</Text>
```

## Reference

### Badge

**Prop:**

- `color` - Badge color: `zinc`, `gray` (the same as `zinc`), or one of the 17 chromatic Tailwind colors (e.g., `red`, `blue`). Default: `zinc`.
- `size` - Badge size. Options: `sm`, `base` (default), `lg`.
- `rounded` - If `true`, makes the badge fully rounded instead of slightly rounded corners.
- `variant` - Badge style variant. Options: `default`, `solid`. Default: `default`.
- `icon` - Icon to display before the badge text: a component, such as `UserIcon` from `@fluxui-dev/react/icons`, or an element, such as `<img />`, rendered as is.
- `iconTrailing` - Icon to display after the badge text: a component or an element.
- `iconVariant` - Icon variant. Options: `outline`, `solid`, `mini`, `micro`. Default: `micro`.
- `label` - The badge's content, used when it has no children.
- `render` - Element to render instead of the `span`, such as `<button type="button" />`, with the badge's props merged in. Also accepts a function that receives the props and returns an element.
- `inset` - Add negative margins to all or specific sides. Options: `true` (all sides), `top`, `bottom`, `left`, `right`, or a space-separated combination such as `"top bottom"`.

**CSS:**

- `className` - Additional CSS classes applied to the badge.

**Attribute:**

- `data-flux-badge` - Applied to the root element for styling and identification.

### Badge.Close

**Prop:**

- `icon` - Icon to display, a component or an element. Default: an x-mark icon.
- `iconVariant` - Icon variant. Options: `outline`, `solid`, `mini`, `micro`. Default: `micro`.
- `aria-label` - Accessible name for the button, such as `Remove`. The button has none by default.
- `onClick` - Callback fired when the button is clicked; removing the badge is up to your app.
- `render` - Element to render instead of the `button`, with the close button's props merged in. Also accepts a function that receives the props and returns an element.

**Attribute:**

- `data-flux-badge-close` - Applied to the button for styling and identification.
