# ContextRing

> How much of the context window is gone, in the space of a favicon: a donut that fills as the conversation grows, the compact count beside it, and an optional popover breaking the total down by what is holding it.

- Package: `fancy-ui-react` (React 18/19 + Tailwind CSS v4)
- Category: AI Chat
- Tags: ai, chat, tokens, context, indicator
- Types: `ContextRingProps`
- Docs: https://fancy-ui.rama.app/docs/components/context-ring
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/react/src/components/context-ring

## Import

```tsx
import { ContextRing } from 'fancy-ui-react';
```

Setup (once per project): `npm install fancy-ui-react`, then put these lines in your main CSS file (the stylesheet import goes right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-react/tailwind.css";
```

and import the component styles once in the app entry: `import "fancy-ui-react/styles.css";`. Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in React; when one differs from the Svelte name, the Svelte name follows in parentheses. `class` becomes `className`, a callback takes the name the React port declares (`onclick` becomes `onClick`), snippets become `ReactNode` props (render functions when they take arguments) and the default snippet is `children`. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/react#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `usage` (required) | `TokenUsageData` | — | Context-window consumption: tokens used, out of how many, and optionally the breakdown rows the popover lists |
| `size` | `number` | `28` | Outer diameter of the ring, in pixels; drives the viewBox and the radius |
| `strokeWidth` | `number` | `3` | Thickness of the track and the arc, in pixels; clamped to the radius so a thick ring cannot eat its own centre |
| `showLabel` | `boolean` | `true` | Whether the compact "12.4k / 200k" figure is shown beside the ring — exact under a thousand, one decimal under 100k, rounded above |
| `warnAt` | `number` | `0.75` | Fraction at which the ring leaves the quiet band and takes the running colour |
| `criticalAt` | `number` | `0.9` | Fraction at which the ring takes the error colour. Floored at warnAt, so a threshold set below the warning cannot create a band that never wins |
| `label` | `string` | `"Context usage"` | Accessible name for the meter, and — when expandable — for the button that contains it |
| `expandable` | `boolean` | `false` | Turns the ring into a button that toggles a popover listing usage.breakdown; closes on Escape, on a click outside, or on a second press |
| `sound` | `boolean` | `false` | Plays open/close on the breakdown popover, once the user has enabled sound |

## Example

No React example is published for this component yet: start from the import above and the props table. The full examples are Svelte-only, on https://fancy-ui.rama.app/docs/components/context-ring.md.
