I build components for trading and finance screens. I asked six AI tools with web search for a good React order book component. Most of the answers pointed at the same few repos. The one they cited most was last updated in July 2023.

Those repos did the job back then. But if you're building an exchange or a perps front end now, you probably want something that drops into a shadcn and Tailwind project and that you can change.

So I put the order book from my library on its own repo. Here's what I think an order book has to do, and how this one does it.

What an order book has to do

It has to stay readable when the market is busy. So prices group by the market's tick, and you can switch the grouping.

It has to show where the size sits. Each level gets a depth bar, so you see the walls without reading every number.

It has to answer the question a trader actually has. Point at a level and it tells you the total size and value up to that price. That's the number you want before you place a big order.

And the numbers can't jump. Every figure is set in tabular numerals, so the columns stay still while prices tick. It sounds small, but it's the first thing that makes a book feel cheap when it's wrong.

Install

It's a shadcn registry item, so in a React project with Tailwind:

npx shadcn@latest add @ssych/order-book 

The source lands in your project. It's yours to change.

Use

<OrderBook symbol="BTC-USD" unit="BTC" bids={bids} asks={asks} tick={0.5} feed={false} /> 

bids and asks are arrays of { price, size }. feed runs a demo feed for the docs, so turn it off when you pass live levels from your exchange or websocket.

What it doesn't do

It doesn't virtualise thousands of rows. It's sized for the levels one screen shows. If you need a deep ladder you scroll through, a data grid fits better.

The parts around it

An order book rarely sits alone. Next to it you usually want a depth chart, a time and sales tape, an order ticket and a positions table. For perps I think the ticket should show the liquidation price before you confirm. Finding it out after the click is one of the worst things a trading UI can do to someone.

They're all free and MIT here: https://ssych.com/library/s/perps-dex

The repo: https://github.com/savvasicevs/react-order-book

If you've built an exchange UI, I'd really like to hear what you'd add.