# Mini bar

A word-sized bar for a table cell, beside `Sparkline`: one measured value against its scale, filled from the start edge (the right, in a right-to-left language). It reads "{label}: {value} of {max}". A missing value draws no bar and says "No data", never an empty bar that reads as zero. A value outside the scale fills to the end it passed, and its name keeps the value as measured.

- Registry name: `mini-bar` (`@candor/mini-bar`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/mini-bar

## Install

```bash
npx candor-ui add mini-bar
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/mini-bar`.
It brings in: data, locale, scale, tokens, utils.

## Example

```tsx
"use client"

import { MiniBar } from "@/components/candor/mini-bar"

const repos: { name: string; failed: number | null }[] = [
  { name: "api", failed: 12 },
  { name: "web", failed: 4 },
  { name: "billing", failed: null },
  { name: "workers", failed: 0 },
]

export default function Example() {
  return (
    <ul className="flex max-w-xs flex-col divide-y rounded-xl border bg-card px-4">
      {repos.map((r) => (
        <li key={r.name} className="flex items-center justify-between gap-4 py-2 text-sm">
          <span className="font-mono text-xs">{r.name}</span>
          <MiniBar value={r.failed} max={20} label={`Failed runs this week, ${r.name}`} showValue />
        </li>
      ))}
    </ul>
  )
}
```

## <MiniBar>

Props:

- `value: number | null`: The measured value; `null` where there's none.
- `max: number`: The scale's end: a full bar.
- `min?: number | undefined` (default `0`): The scale's start: an empty bar. Defaults to 0.
- `label: string`: What the value is, read by assistive tech: "Failed runs, api".
- `format?: ValueFormat | undefined` (default `"number"`): How values are written: number, percent (0–1), currency (USD) or duration (seconds). Defaults to number.
- `width?: number | undefined` (default `64`): The bar's width in pixels. Defaults to 64.
- `showValue?: boolean | undefined` (default `false`): Writes the value beside the bar.
- `className?: string | undefined`: Classes for the root, merged with Candor's.

## Strings (`miniBar`)

The fixed words, English by default. Override any of them under `miniBar` in `<LocaleProvider strings={{ miniBar: { … } }}>`; the table is exported as `miniBarStrings`.

- `name`: {label}: {value} of {max}
- `noData`: {label}: no data
- `noDataShort`: No data

## Types from other items

The props above take these. Each is defined by another item; import it from the path shown.

### ValueFormat

Import: `import type { ValueFormat } from "@/lib/candor/data"` (item `data`, https://candor.themethodic.com/docs/data.md)

```ts
"number" | "percent" | "currency" | "duration"
```

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider`: its fixed strings in `strings`, its nouns in `nouns`; entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
