Components
Candlestick chart
NativePrice candles, volume, a market ticker and a depth order book drawn without chart dependencies.
NOVA
Nova Technologies · illustrative data
↑ +$3.25 (+1.77%)
NOVA · 5 minute candles
Filled: up · Outline: downUse left and right arrows to explore candles. Home and End jump to the first and last candle.
| Time | Open | High | Low | Close | Volume |
|---|---|---|---|---|---|
| 09:30 | $184.20 | $184.51 | $183.12 | $183.45 | 6417 |
| 09:35 | $183.45 | $183.80 | $182.63 | $182.87 | 6409 |
| 09:40 | $182.87 | $183.07 | $182.17 | $182.46 | 12706 |
| 09:45 | $182.46 | $183.80 | $182.12 | $183.15 | 13564 |
| 09:50 | $183.15 | $183.92 | $182.99 | $183.31 | 14501 |
| 09:55 | $183.31 | $183.71 | $182.40 | $182.55 | 9475 |
| 10:00 | $182.55 | $183.61 | $182.31 | $183.49 | 5164 |
| 10:05 | $183.49 | $184.48 | $183.25 | $184.45 | 15742 |
| 10:10 | $184.45 | $184.75 | $184.11 | $184.59 | 5132 |
| 10:15 | $184.59 | $185.07 | $184.14 | $184.97 | 4990 |
| 10:20 | $184.97 | $186.09 | $184.97 | $185.88 | 14219 |
| 10:25 | $185.88 | $186.57 | $185.25 | $185.67 | 14323 |
| 10:30 | $185.67 | $186.43 | $185.12 | $185.81 | 7525 |
| 10:35 | $185.81 | $186.77 | $185.27 | $186.77 | 2094 |
| 10:40 | $186.77 | $187.09 | $186.65 | $186.69 | 2500 |
| 10:45 | $186.69 | $187.44 | $186.43 | $187.23 | 7312 |
| 10:50 | $187.23 | $188.15 | $187.19 | $187.61 | 13494 |
| 10:55 | $187.61 | $187.64 | $186.56 | $186.88 | 12124 |
| 11:00 | $186.88 | $187.34 | $186.23 | $186.94 | 4591 |
| 11:05 | $186.94 | $187.40 | $185.99 | $186.39 | 7305 |
| 11:10 | $186.39 | $186.99 | $185.94 | $186.28 | 15390 |
| 11:15 | $186.28 | $186.53 | $185.27 | $185.82 | 11013 |
| 11:20 | $185.82 | $187.28 | $185.41 | $186.64 | 6860 |
| 11:25 | $186.64 | $187.60 | $186.22 | $187.45 | 9983 |
Order book
| Price (USD) | Shares | Depth |
|---|---|---|
| 188.15 | 240 | 240 |
| 188.20 | 410 | 650 |
| 188.25 | 650 | 1.3K |
Spread $0.05
| Price (USD) | Shares | Depth |
|---|---|---|
| 188.10 | 320 | 320 |
| 188.05 | 520 | 840 |
| 188.00 | 790 | 1.6K |
Illustrative market data. Focus a candle and use the arrow keys to explore.
Installation
npx nook-ui@latest add candlestick-chartPrompt
Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.
Short. For assistants that can run commands in your project.
Add the Nook "Candlestick chart" component to this project, exactly as Nook ships it.
Price candles, volume, a market ticker and a depth order book drawn without chart dependencies.
Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add candlestick-chart`. It writes `components/ui/candlestick-chart.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/candlestick-chart.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:
```tsx
import {
CandlestickChart,
Ticker,
OrderBook,
type Candle,
} from "@/components/ui/candlestick-chart";
// Fixed seed: the same illustrative session is rendered on the server and browser.
function session(): Candle[] {
let seed = 2048,
last = 184.2;
const next = () => {
seed = (seed * 16807) % 2147483647;
return seed / 2147483647;
};
return Array.from({ length: 24 }, (_, i) => {
const open = last,
close = open + (next() - 0.43) * 1.8;
last = close;
return {
time: `${String(9 + Math.floor((30 + i * 5) / 60)).padStart(2, "0")}:${String((30 + i * 5) % 60).padStart(2, "0")}`,
open,
close,
high: Math.max(open, close) + next() * 0.8,
low: Math.min(open, close) - next() * 0.7,
volume: Math.round(2000 + next() * 14000),
};
});
}
const candles = session();
export default function TradingDefault() {
return (
<div className="grid w-full gap-6">
<Ticker
symbol="NOVA"
name="Nova Technologies · illustrative data"
price={candles.at(-1)!.close}
change={candles.at(-1)!.close - candles[0]!.open}
changePercent={(candles.at(-1)!.close / candles[0]!.open - 1) * 100}
history={candles.map((d) => d.close)}
/>
<CandlestickChart title="NOVA · 5 minute candles" data={candles} />
<OrderBook
quantityLabel="Shares"
asks={[
{ price: 188.15, quantity: 240 },
{ price: 188.2, quantity: 410 },
{ price: 188.25, quantity: 650 },
]}
bids={[
{ price: 188.1, quantity: 320 },
{ price: 188.05, quantity: 520 },
{ price: 188, quantity: 790 },
]}
/>
<p className="text-xs text-muted-foreground">
Illustrative market data. Focus a candle and use the arrow keys to
explore.
</p>
</div>
);
}
```
API
- `CandlestickChart`: An SVG OHLC chart with the existing niceScale axis and a volume strip.
- `title / data` (`string / Candle[]`): Accessible chart name and time, open, high, low, close, volume for each candle in display order.
- `currency / locale` (`string`, default "USD" / "en-US"): Formatting for tooltip, announcements and table.
- `Ticker`: Symbol, name, last price, signed change and percent, and the existing Sparkline.
- `symbol / name / price / change / changePercent / history` (`string / string / number / number / number / number[]`): Market snapshot and chronological prices. Percent is in percentage points.
- `OrderBook`: Sorted bids and asks with cumulative depth and a spread line.
- `bids / asks` (`OrderLevel[]`): Price and quantity pairs; highest bid and lowest ask come first.
- `currency / quantityLabel` (`string`, default "USD" / "Shares"): Table units.
Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Up candles are filled; down candles are outlined. Focused candles announce direction and every value. Arrow keys, Home and End navigate. ChartTable supplies the full data alternative and tooltip direction includes an arrow and a word.
Done when the component renders like the example in light and dark mode and the project type-checks.Usage
import {
CandlestickChart,
Ticker,
OrderBook,
type Candle,
} from "@/components/ui/candlestick-chart";
// Fixed seed: the same illustrative session is rendered on the server and browser.
function session(): Candle[] {
let seed = 2048,
last = 184.2;
const next = () => {
seed = (seed * 16807) % 2147483647;
return seed / 2147483647;
};
return Array.from({ length: 24 }, (_, i) => {
const open = last,
close = open + (next() - 0.43) * 1.8;
last = close;
return {
time: `${String(9 + Math.floor((30 + i * 5) / 60)).padStart(2, "0")}:${String((30 + i * 5) % 60).padStart(2, "0")}`,
open,
close,
high: Math.max(open, close) + next() * 0.8,
low: Math.min(open, close) - next() * 0.7,
volume: Math.round(2000 + next() * 14000),
};
});
}
const candles = session();
export default function TradingDefault() {
return (
<div className="grid w-full gap-6">
<Ticker
symbol="NOVA"
name="Nova Technologies · illustrative data"
price={candles.at(-1)!.close}
change={candles.at(-1)!.close - candles[0]!.open}
changePercent={(candles.at(-1)!.close / candles[0]!.open - 1) * 100}
history={candles.map((d) => d.close)}
/>
<CandlestickChart title="NOVA · 5 minute candles" data={candles} />
<OrderBook
quantityLabel="Shares"
asks={[
{ price: 188.15, quantity: 240 },
{ price: 188.2, quantity: 410 },
{ price: 188.25, quantity: 650 },
]}
bids={[
{ price: 188.1, quantity: 320 },
{ price: 188.05, quantity: 520 },
{ price: 188, quantity: 790 },
]}
/>
<p className="text-xs text-muted-foreground">
Illustrative market data. Focus a candle and use the arrow keys to
explore.
</p>
</div>
);
}Props
CandlestickChart
An SVG OHLC chart with the existing niceScale axis and a volume strip.
| Prop | Type | Default | Description |
|---|---|---|---|
| title / data | string / Candle[] | – | Accessible chart name and time, open, high, low, close, volume for each candle in display order. |
| currency / locale | string | "USD" / "en-US" | Formatting for tooltip, announcements and table. |
Ticker
Symbol, name, last price, signed change and percent, and the existing Sparkline.
| Prop | Type | Default | Description |
|---|---|---|---|
| symbol / name / price / change / changePercent / history | string / string / number / number / number / number[] | – | Market snapshot and chronological prices. Percent is in percentage points. |
OrderBook
Sorted bids and asks with cumulative depth and a spread line.
| Prop | Type | Default | Description |
|---|---|---|---|
| bids / asks | OrderLevel[] | – | Price and quantity pairs; highest bid and lowest ask come first. |
| currency / quantityLabel | string | "USD" / "Shares" | Table units. |
Accessibility
Up candles are filled; down candles are outlined. Focused candles announce direction and every value. Arrow keys, Home and End navigate. ChartTable supplies the full data alternative and tooltip direction includes an arrow and a word.
Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.