Skip to content

Trend Badge

Beta
Get Ritla UI

The change next to a figure: up in green, down in red, flat in gray, with an arrow that never mirrors.

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 trend-badge

    Also works with shadcn: npx shadcn@latest add @ritla/trend-badge

  2. Dependencies it brings

    @phosphor-icons/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

trend-badge.tsx
import { TrendBadge } from "@/components/ui/trend-badge";<TrendBadge value={12.4} />

API reference

TrendBadge

PropTypeDefaultDescription
valuenumberNoneThe change in percent: 12.4 reads “+12.4%”. Its sign picks the direction.
childrenReactNodeNoneOther text in place of the percent (“+JOD 214.670”).
direction"up" | "down" | "flat"NoneFigma's Direction. Default: from the sign of value.
size"sm" | "md""sm"Figma's Size: sm in rows and tiles, md next to a display figure.
variant"soft" | "plain""soft"Figma's Style: Soft is a tinted pill, Plain is text only for dense rows.
fractionDigitsnumber1Digits after the point.

Accessibility

ARIA

  • Colour is never the only signal: the arrow and the sign say the same, and the badge sits next to words like “vs last month”.
  • The arrow is decorative; the text “+12.4%” is what is read.

Arabic and RTL notes

Mirrors

  • The arrow sits at the start, so it moves to the right in Arabic.

Does not mirror

  • Up and down arrows point up and down in both directions; the change “+12.4%” stays one left-to-right run, sign first.
Numerals
The percent follows numerals on RitlaProvider: +12.4% or +١٢٫٤٪.
Arabic typography
numeric-12 Regular (sm) or numeric-14 Medium (md), with tabular figures.