# Budget brake

A budget that stops the agent: the bar hits the cap like a wall and a lock drops on.

Also called: spend limit animation, budget cap.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: A budget that stops the agent. The bar fills as the run spends and turns amber near the cap; at the cap it runs into the end, a lock drops on and the run pauses. Preview: https://chatcn.dev/preview/budget-brake-demo

The bar fills as the run spends and turns amber in its last fifth. When it reaches the cap it runs into the end like a wall: the fill gives a little and settles, a lock drops onto the end of the track, and the line says the run is paused with what you can do next.

## Installation

```bash
npx shadcn@latest add @chatcn-pro/budget-brake
```

## Usage

```tsx
import { BudgetBrake } from "@/components/ui/chatcn/pro/budget-brake"

<BudgetBrake spent={run.spent} budget={20} onRaise={raise} onStop={stop} />
```

## Examples

### Levels

Example: Under, close, braked. The same budget at a third spent, close to the limit, and at the limit with the brake on. Preview: https://chatcn.dev/preview/budget-brake-levels

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `spent` / `budget` | `number` | Reaching the budget pauses |
| `currency` | `string` | Default "USD" |
| `scope` | `string` | Default "this run" |
| `onRaise` / `raiseLabel` | `() => void` / `string` | Default label doubles the cap |
| `onStop` | `() => void` | Shows End run |

## Accessibility

- The title is a status that changes to Paused at the budget; the bar is a labelled `meter`.

## Motion

- The fill is a heavy spring; the hit is a 380 ms press; the lock drops 420 ms. Reduced motion: the bar jumps.

Source: https://chatcn.dev/docs/components/budget-brake