# StatusChip

> A status as an icon and words on a soft tint, never colour alone.

- Import: `import { StatusChip } from '@nyxon/nasim';`
- Server Component: yes, it renders without 'use client'
- Since: 0.5.0; status: stable
- Source: libs/nasim/src/composites/StatusChip.tsx
- Describes: @nyxon/nasim unreleased, after 0.12.0
- Page: https://nasim.nyxon.tech/docs/components/feedback/status-chip

<Example name="status-chip/basic">
  ```tsx title="status-chip/basic.tsx"
  import { StatusChip } from '@nyxon/nasim';

  // A screen reads its words from its own strings module; an example keeps them at the top.
  const copy = { paid: 'پرداخت‌شده' };

  export default function Basic() {
    return <StatusChip tone="success" label={copy.paid} />;
  }
  ```
</Example>

## Import [#import]

```tsx
import { StatusChip } from '@nyxon/nasim';
```

## Usage [#usage]

`StatusChip` is plain markup with plain props, so a Server Component can render it; it needs no
`'use client'`. Pick the `tone` from what the status means for the reader, and pass the words as
`label` from the screen's own strings module.

```tsx
<StatusChip tone="success" label={t.invoice.paid} />
```

## Examples [#examples]

### Tones [#tones]

Five tones: `success`, `warning`, `danger`, `info` and `neutral`. Each has its own icon and tint.

<Example name="status-chip/tones">
  ```tsx title="status-chip/tones.tsx"
  import { StatusChip, type StatusTone } from '@nyxon/nasim';

  // One invoice status per tone. The words carry the meaning; the tint and icon repeat it.
  const statuses: { tone: StatusTone; label: string }[] = [
    { tone: 'success', label: 'پرداخت‌شده' },
    { tone: 'warning', label: 'در انتظار تأیید' },
    { tone: 'danger', label: 'ناموفق' },
    { tone: 'info', label: 'در حال بررسی' },
    { tone: 'neutral', label: 'منقضی‌شده' },
  ];

  export default function Tones() {
    return (
      <div className="flex flex-wrap gap-2">
        {statuses.map(({ tone, label }) => (
          <StatusChip key={tone} tone={tone} label={label} />
        ))}
      </div>
    );
  }
  ```
</Example>

### Long text [#long-text]

A long label wraps inside the chip rather than pushing its column wider. Keep labels short where
you can: a status is read at a glance.

<Example name="status-chip/long-text">
  ```tsx title="status-chip/long-text.tsx"
  import { StatusChip } from '@nyxon/nasim';

  const copy = {
    label: 'در انتظار تأیید پرداخت از سوی بانک صادرکنندهٔ کارت',
  };

  // A long Persian status in a narrow column, as in a table cell on a phone.
  export default function LongText() {
    return (
      <div className="max-w-48">
        <StatusChip tone="warning" label={copy.label} />
      </div>
    );
  }
  ```
</Example>

## Rules [#rules]

* The label says the status in words. The tone's colour and icon repeat it; a reader who cannot
  tell the colours apart, or a screen reader, still gets the whole status.
* Coloured text always sits on its own soft tint, which holds 4.5:1 in both themes
  (`tokens.test.ts`). Do not put a chip's colours on another background.
* `icon` replaces the tone's icon with a more specific one (a clock for «waiting», an hourglass for
  «expired»). It is hidden from screen readers, so the label must still carry the meaning.

## Accessibility [#accessibility]

The chip is a `<span>` with no role: it is read in place as text, and it is not focusable. The icon
is `aria-hidden`. It is not a control; an action next to a status is a button of its own.

## API [#api]

| Prop        | Type                   | Default  | Description                                                                                                     |
| ----------- | ---------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
| `tone`      | `StatusTone`           | required | The tint and the icon. It repeats what `label` says; it never says it alone.                                    |
| `label`     | `string`               | required | The status in words, from the screen's strings module: the chip is never colour alone.                          |
| `size`      | `"lg" \| "md" \| "sm"` | `'md'`   | The chip's height and text size, HeroUI's chip sizes.                                                           |
| `icon`      | `ReactNode`            | —        | Replaces the tone's icon (a clock for «waiting», an hourglass for «expired»). It is hidden from screen readers. |
| `className` | `string`               | —        | Classes added to the chip's own (layout only: margins, alignment).                                              |

`StatusTone` is exported too, for a list of statuses typed by tone.

## Related [#related]

`TrendChip` (the change against the previous period, on the same tints) and `Notice` (an inline
message, for a status that needs a sentence). Neither has a page here yet.