# Badge usage guidelines

> Discover Cimpress UI's badge component.

Source: https://ui.cimpress.io/components/badge/

Badges can be used to display small pieces of information, such as a status or a category. Placed near relevant content, they help capture user attention.

### When to use

- To indicate a status ("Active", "Shipped", "Canceled") or a priority ("Urgent")
- To categorize information (e.g., surface, color)
- To show feature flags, version numbers, or priority levels
- To highlight relevant information with a specific tone

### When not to use

- Use [buttons](/components/button) or [tags](/components/tag-group) for scenarios that require user interaction.
- Use [tags](/components/tag-group) for content that is user-generated and/or customizable.
- For long descriptions or complex information.

**Badges vs. tags**\
Badges and tags may look similar, but they serve different purposes:

- Badges are non-interactive, purely informational, and can be used on their own. They are a better fit for presenting predefined content.
- Tags are usually interactive, and can only be used as part of a group. They are a better fit for presenting user-generated content.

## Properties

### Size

```tsx
import { Badge, Stack } from '@cimpress-ui/react';

export default function Demo() {
  return (
    <Stack direction="horizontal" gap={16} align="center" wrap>
      <Badge size="small">Small</Badge>
      <Badge size="medium">Medium</Badge>
      <Badge size="large">Large</Badge>
    </Stack>
  );
}
```

| Value            | Use cases                                                                                                                                         |
| :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------ |
| Small            | Small badges should be used sparingly in compact UI areas. They do not include icons due to their size. They work well for indicators like "New". |
| Medium (default) | Medium badges are the default size in the design system and should be used in most cases.                                                         |
| Large            | Large badges are suitable when space allows but should not overpower higher-priority elements to maintain visual hierarchy.                       |

### Tone

```tsx
import { Badge, Stack } from '@cimpress-ui/react';

export default function Demo() {
  return (
    <Stack direction="vertical" gap={32}>
      <Stack direction="horizontal" gap={16} wrap>
        <Badge tone="base">Base</Badge>
        <Badge tone="success">Success</Badge>
        <Badge tone="info">Info</Badge>
        <Badge tone="warning">Warning</Badge>
        <Badge tone="critical">Critical</Badge>
      </Stack>

      <Stack direction="horizontal" gap={16} wrap>
        <Badge tone="lime">Lime</Badge>
        <Badge tone="emerald">Emerald</Badge>
        <Badge tone="indigo">Indigo</Badge>
        <Badge tone="purple">Purple</Badge>
        <Badge tone="pink">Pink</Badge>
        <Badge tone="brown">Brown</Badge>
      </Stack>
    </Stack>
  );
}
```

| Value                                           | Use cases                                                                                                                         |
| :---------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------- |
| Base (default)                                  | Base badges are neutral and used for non-critical information that doesn't require much attention.                                |
| Success                                         | Success badges indicate a successful status or completed action.                                                                  |
| Info                                            | Info badges highlight important details without implying positivity or negativity. They are often used for in-progress statuses.  |
| Warning                                         | Warning badges signal a sub-optimal but non-critical status with a slightly negative tone.                                        |
| Critical                                        | Critical badges highlight errors or issues that require user attention.                                                           |
| Support tones\:LimeEmeraldIndigoPurplePinkBrown | Support badges are mainly for categorization and don't explicitly indicate system status, though they can be used for edge cases. |

## Formatting and layout

### Placement

Place badges next to the relevant element to clearly indicate status or information. Avoid using them in isolation. In tables, use badges within columns to represent status or activity.

**Do:**

```tsx
import { Badge, Stack, Text } from '@cimpress-ui/react';
import {
  Wireframe,
  WireframeGrid,
  WireframeGridItem,
  WireframeSection,
} from '../../../components/wireframes/wireframe.js';

export default function Demo() {
  return (
    <Wireframe>
      <WireframeSection>
        <Stack gap={8} direction="horizontal">
          <Text as="span" variant="medium" tone="base">
            All products
          </Text>
          <Text as="span" variant="medium" tone="critical" aria-hidden>
            *
          </Text>
        </Stack>
      </WireframeSection>

      <WireframeSection>
        <WireframeGrid>
          <WireframeGridItemWithBadge />
          <WireframeGridItem tone="base" />
          <WireframeGridItemWithBadge />
          <WireframeGridItem tone="base" />
          <WireframeGridItem tone="base" />
          <WireframeGridItemWithBadge />
        </WireframeGrid>
      </WireframeSection>
    </Wireframe>
  );
}

function WireframeGridItemWithBadge() {
  return (
    <WireframeGridItem tone="base">
      <Badge tone="success" UNSAFE_style={{ position: 'absolute', top: '4px', right: '4px' }}>
        Published
      </Badge>
    </WireframeGridItem>
  );
}
```

**Don't:**

```tsx
import { Badge, Stack, Text } from '@cimpress-ui/react';
import { IconCheckCircle } from '@cimpress-ui/react/icons';
import {
  Wireframe,
  WireframeGrid,
  WireframeGridItem,
  WireframeSection,
} from '../../../components/wireframes/wireframe.js';

export default function Demo() {
  return (
    <Wireframe>
      <WireframeSection>
        <Stack gap={16} direction="horizontal" justify="space-between" align="center">
          <Stack gap={8} direction="horizontal">
            <Text as="span" variant="medium" tone="base">
              All products
            </Text>
            <Text as="span" variant="medium" tone="critical" aria-hidden>
              *
            </Text>
          </Stack>

          <Badge tone="success" iconStart={<IconCheckCircle />}>
            Published
          </Badge>
        </Stack>
      </WireframeSection>

      <WireframeSection>
        <WireframeGrid>
          <WireframeGridItem />
          <WireframeGridItem />
          <WireframeGridItem />
          <WireframeGridItem />
          <WireframeGridItem />
          <WireframeGridItem />
        </WireframeGrid>
      </WireframeSection>
    </Wireframe>
  );
}
```

### Icons

For status indicators use standard icons that clearly suggest the meaning. A badge can use any icon from our library, but you should ensure that the icon's message is consistent with the label.

**Do:**

```tsx
import { Badge, Stack } from '@cimpress-ui/react';
import { IconCheckCircle, IconWarning, IconWarningCircleFill } from '@cimpress-ui/react/icons';

export default function Demo() {
  return (
    <Stack gap={16}>
      <Badge tone="success" iconStart={<IconCheckCircle />}>
        Delivered
      </Badge>
      <Badge tone="warning" iconStart={<IconWarning />}>
        Shipment delayed
      </Badge>
      <Badge tone="critical" iconStart={<IconWarningCircleFill />}>
        Payment overdue
      </Badge>
    </Stack>
  );
}
```

**Don't:**

```tsx
import { Badge, Stack } from '@cimpress-ui/react';
import { IconBarcode, IconCategoryPackage, IconTextStrikethrough } from '@cimpress-ui/react/icons';

export default function Demo() {
  return (
    <Stack gap={16}>
      <Badge tone="success" iconStart={<IconCategoryPackage />}>
        Delivered
      </Badge>
      <Badge tone="warning" iconStart={<IconTextStrikethrough />}>
        Shipment delayed
      </Badge>
      <Badge tone="critical" iconStart={<IconBarcode />}>
        Payment overdue
      </Badge>
    </Stack>
  );
}
```

## Content writing

- Use clear and concise labels with one or two words.
- Don't use action language, as this can make users think that a badge is interactive. Use words like "Urgent" instead of "Take action".

## Behaviors

### Non-interactive

A badge is a static (non-interactive) element. It only conveys information, and doesn't provide any actions.
