nook
Browse the docs

Components

Candlestick chart

Native

Price candles, volume, a market ticker and a depth order book drawn without chart dependencies.

See the prompt

NOVA

Nova Technologies · illustrative data

$187.45

↑ +$3.25 (+1.77%)

NOVA · 5 minute candles

Filled: up · Outline: down

Use left and right arrows to explore candles. Home and End jump to the first and last candle.

NOVA · 5 minute candles
TimeOpenHighLowCloseVolume
09:30$184.20$184.51$183.12$183.456417
09:35$183.45$183.80$182.63$182.876409
09:40$182.87$183.07$182.17$182.4612706
09:45$182.46$183.80$182.12$183.1513564
09:50$183.15$183.92$182.99$183.3114501
09:55$183.31$183.71$182.40$182.559475
10:00$182.55$183.61$182.31$183.495164
10:05$183.49$184.48$183.25$184.4515742
10:10$184.45$184.75$184.11$184.595132
10:15$184.59$185.07$184.14$184.974990
10:20$184.97$186.09$184.97$185.8814219
10:25$185.88$186.57$185.25$185.6714323
10:30$185.67$186.43$185.12$185.817525
10:35$185.81$186.77$185.27$186.772094
10:40$186.77$187.09$186.65$186.692500
10:45$186.69$187.44$186.43$187.237312
10:50$187.23$188.15$187.19$187.6113494
10:55$187.61$187.64$186.56$186.8812124
11:00$186.88$187.34$186.23$186.944591
11:05$186.94$187.40$185.99$186.397305
11:10$186.39$186.99$185.94$186.2815390
11:15$186.28$186.53$185.27$185.8211013
11:20$185.82$187.28$185.41$186.646860
11:25$186.64$187.60$186.22$187.459983

Order book

Asks
Price (USD)SharesDepth
188.15240240
188.20410650
188.256501.3K

Spread $0.05

Bids
Price (USD)SharesDepth
188.10320320
188.05520840
188.007901.6K

Illustrative market data. Focus a candle and use the arrow keys to explore.

Installation

npx nook-ui@latest add candlestick-chart

Prompt

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.

Plain text
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.

PropTypeDefaultDescription
title / datastring / Candle[]–Accessible chart name and time, open, high, low, close, volume for each candle in display order.
currency / localestring"USD" / "en-US"Formatting for tooltip, announcements and table.

Ticker

Symbol, name, last price, signed change and percent, and the existing Sparkline.

PropTypeDefaultDescription
symbol / name / price / change / changePercent / historystring / 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.

PropTypeDefaultDescription
bids / asksOrderLevel[]–Price and quantity pairs; highest bid and lowest ask come first.
currency / quantityLabelstring"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.