Skip to content

Trade Action

Get Ritla UI

Buy and Sell side by side, for trading and brokerage screens. Both are primary actions: green Buy at the inline start, red Sell after it, and the colors never swap in Arabic.

Ritla scan of this preview: 41 of 41 checks3 breakpointsScanned

Open in Figma

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

PreviewCode
EnglishMirroredArabic
LTR →

Installation

  1. Add the component

    npx ritla add trade-action

    Also works with shadcn: npx shadcn@latest add @ritla/trade-action

  2. Dependencies it brings

    @base-ui/react

  3. Or copy by hand

    Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.

Usage

trade-action.tsx
import { TradeAction } from "@/components/ui/trade-action";<TradeAction buyLabel="Buy" sellLabel="Sell" onBuy={openBuy} onSell={openSell} />

Examples

Sizes

lg 56, md 48, sm 40 and xs 32px. Both halves are always the same width, and the tap target stays at least 48px.

EnglishMirroredArabic
LTR →

Disabled

disabled switches off both halves, for example when the market is closed. Say why next to them: a disabled control can't explain itself.

EnglishMirroredArabic
LTR →

API reference

TradeAction

PropTypeDefaultDescription
buyLabelReactNodeNoneBuy label: the Buy text, which can carry the price (“Buy 38.45”).
sellLabelReactNodeNoneSell label: the Sell text.
onBuy(event) => voidNoneCalled when Buy is pressed.
onSell(event) => voidNoneCalled when Sell is pressed.
size"lg" | "md" | "sm" | "xs""lg"Figma's Size.
disabledbooleanfalseState = Disabled on both halves.
classNamestringNoneClasses for the group, such as w-full to fill the width.

Accessibility

Keyboard

Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.

KeyAction
TabMoves from Buy to Sell; focus shows the ring without changing the color.
EnterSpaceRuns the focused action.

ARIA

  • Two native buttons in a role="group"; the name is the text, so meaning never depends on color alone.
  • Buy and Sell usually open a confirmation form; don't execute a financial order on a single press without a review.

Arabic and RTL notes

Mirrors

  • Buy sits at the inline start (the right in Arabic) and Sell after it, so the reading order stays Buy, then Sell.

Does not mirror

  • Colors never swap: Buy is green and Sell red in both languages.
Numerals
Prices in the labels are formatted with formatNumber and follow the numerals setting; try ١٢٣ in the preview.
Arabic typography
body-16 (body-14 at xs) in Semibold, at a fixed height that fits Arabic.
Mixed-direction text
A price after Arabic text (“شراء 38.45”) renders correctly; a Latin ticker inside it (“شراء AAPL”) goes in <bdi>.

Checks it passes

The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.

  • R050Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
  • R051letter-spacing applied to Arabic text (breaks the connected script)
  • R042Clipped text: content wider than its box with overflow hidden and no ellipsis
  • R043Fixed-pixel-width container whose Arabic text exceeds the space