# ProbBar (prob-bar)

> Labelled probability bar that slides in and fills to its value while the number counts up.

- Entry: component
- Category: Motion
- Preview capabilities: replay, player
- Runtime: Remotion
- Needs Remotion: yes
- QA page: https://jbm-ui.bns.studio/c/prob-bar
- JSON: https://jbm-ui.bns.studio/catalog/prob-bar.json
- Registry item: https://jbm-ui.bns.studio/r/prob-bar.json (source code in files[].content)

## Install

```sh
npx shadcn@latest add @jbm/prob-bar
```

Also installs @jbm/tokens, @jbm/motion-hooks, @jbm/pop (registry dependencies install automatically).

## Required setup

1. Add the `@jbm` registry to components.json (keep any entries already there):

   ```json
   {
     "registries": {
       "@jbm": "https://jbm-ui.bns.studio/r/{name}.json"
     }
   }
   ```

2. Map `@/*` to `./src/*` in tsconfig.json `compilerOptions.paths`, so `@/jbm/…` imports resolve to src/jbm/.
3. Install `remotion` and render inside a Remotion `<Composition>` or `<Player>`, not a plain React tree. Timing values are in seconds.

## Files

Each file's source code is in the registry item JSON (https://jbm-ui.bns.studio/r/prob-bar.json, files[].content).

| Source path | Installs to | Import |
| --- | --- | --- |
| `registry/jbm/motion/prob-bar.tsx` | `src/jbm/motion/prob-bar.tsx` | `@/jbm/motion/prob-bar` |

## API

### `ProbBar` (component)

One row: a 24px mono label, a rounded track whose vermilion fill eases to `p` over 0.7 s, and the live value to two decimals. The row pops in from the left by 12px at `at`.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `string` | required | Mono label on the left, in ink. |
| `p` | `number` | required | Target probability, 0–1; the fill ends at p × track width and the value reads p to two decimals. Not clamped: values above 1 overflow the track and are clipped. |
| `at` | `number` | required | Start of the entrance and fill in seconds relative to the enclosing Sequence. |
| `w` | `number` | `520` | Row width budget in stage pixels; the track is w − labelW − 90 wide. |
| `labelW` | `number` | `230` | Width reserved for the label in stage pixels; long labels wrap inside it. |

## Stage

Declared in stage pixels at the documented defaults.

| Orientation | Width | Height |
| --- | --- | --- |
| Landscape (1920×1080) | 546 | 29 |
| Vertical (1080×1920) | 546 | 29 |

Label (labelW 230) + 18 gap + track (w − labelW − 90 = 200) + 18 gap + 80px value gives w + 26 = 546 at w 520. Height is one line of 24px mono text (about 29px at normal line-height; the track itself is 22px). A label that wraps in labelW adds lines. The wrapper is a block element, so it stretches to its container's width while the row content stays w + 26.

## Examples

### One probability

```tsx
import { ProbBar } from "@/jbm/motion/prob-bar"

<ProbBar label="Confianza" p={0.86} at={0.2} />
```

### A ranked list

```tsx
import { ProbBar } from "@/jbm/motion/prob-bar"

{[["gato", 0.72], ["perro", 0.21], ["zorro", 0.07]].map(([label, p], i) => (
  <ProbBar key={label} label={String(label)} p={Number(p)} at={0.4 + i * 0.3} w={720} />
))}
```

## QA

- Step to the first frame (row hidden, value 0.00), mid-fill (partial bar, intermediate value), and the last frame (bar at p, value exactly p to two decimals).
- Check p = 0 and p = 1: an empty track still reads, and a full fill stays inside the rounded track.
- Try a long label: confirm it wraps within labelW and does not push the track; the exact row height at normal line-height is approximate (about 29px) and should be measured if layout depends on it.

## Gallery preview cues

Cue times are seconds on the gallery preview's timeline, which renders the demo below; the Usage examples may use other timings. Map a cue to your own props by its place in the demo. The preview runs at 30 fps for 28 frames (0–27); see them side by side at https://jbm-ui.bns.studio/c/prob-bar?view=strip, or open one frame with ?frame=<frame>.

```tsx
<ProbBar label="Confianza" p={0.86} at={0.2} w={620} />
```

| Frame | Seconds | Shows | What to check |
| --- | --- | --- | --- |
| 0 | 0.00 | Empty stage |  |
| 12 | 0.40 | Bar filling | The bar is part-way to 0.86 and the value readout matches its length. |
| 27 | 0.90 | End |  |

## Related

Installs:

- [Tokens (tokens)](https://jbm-ui.bns.studio/catalog/tokens.md)
- [MotionHooks (motion-hooks)](https://jbm-ui.bns.studio/catalog/motion-hooks.md)
- [Pop (pop)](https://jbm-ui.bns.studio/catalog/pop.md)

## More

- [llms.txt](https://jbm-ui.bns.studio/llms.txt): index of every item
- [catalog.json](https://jbm-ui.bns.studio/catalog.json): every item as JSON
- [Agent contract](https://jbm-ui.bns.studio/docs/agent-contract.md): what each field means
