Krizaka UI
Krizaka UI
ComponentsData display

Credit usage

What is left of an allowance: the remaining amount in large, a meter that turns to warning then danger, the use per day and the day it runs out.

Web · ✓Mobile · ✓Desktop · ✓BetaCharts
Support level
Beta
Size
Not measured
Who uses it
No live product imports it yet
import { CreditUsage } from "@krizaka/charts/credits";

Web and mobile — the same component for React and React Native. Beta: its API may still change in a minor version.

Why it is here. Sovkora's credits left (PS-C ready-made charts).

When to use

  • Sovkora's billing: the credits left this month and when they run out at the current pace.
  • A storage plan (a platform's console): gigabytes used of the plan, with a unit format.
  • Any quota that renews: API calls, minutes of video.

When not to use

  • Money raised towards a goal.Use instead: Goal progress
  • A value in a range with no notion of running out (a load, a score).Use instead: Gauge

Installation

Install

npm install @krizaka/charts

Import

import { CreditUsage } from "@krizaka/charts/credits";

Examples

Monthly credits

An Sovkora plan: credits left, the daily use, the run-out date.

Storage plan

A platform's console: gigabytes of the plan, past the warning level.

Props

What is left of an allowance: the remaining amount, a meter in tones, the use per day and the run-out date.

PropTypeDefaultDescription
limitrequirednumber—The allowance.
titlerequiredstring—What the allowance is (“Credits this month”): the heading and the meter's name.
usedrequirednumber—How much is used.
brandBrandId—The brand whose palette the charts use. Without it, a chart follows a .brand-<id> ancestor, else Krizaka. Set it when the app loads a brand stylesheet on :root (@krizaka/tokens/brands/sovkora.css).
classNamestring—A class on the figure (layout).
dailyreadonly (number | null)[]—The use of each recent day, oldest first: the sparkline and the projection.
daysreadonly unknown[]—The days of daily (ISO dates), for the sparkline's summary.
descriptionReactNode—A line under the title: the plan, the period.
formatValueFormatintegerHow the amounts are written. Default "integer"; a { style: "unit", unit: "gigabyte" } for storage.
hideTitleboolean—Visually hide the title (it stays the accessible name).
labelsPartial<CreditLabels>—The words, passed translated; English by default.
levelsreadonly [number, number][0.8, 0.95]The share where the meter turns to warning, then danger. Default [0.8, 0.95].
loadingboolean—The data is on its way.
localeLocale—The locale of every figure and date ("fr-FR"). Default "en-US".
nowDate—Today, for the run-out projection: the host gives the time (from the server, the same date on both sides); without it no run-out date is shown.
renewsAtstring | Date—When the allowance renews (an ISO date or a Date).
styleCSSProperties—Inline style on the figure (layout only).

Accessibility

  • The meter is a meter named by the title, its value said in words (“3,120 used (62 %)”).
  • The warning and danger tones come with words: the projection says when it runs out.

Best practices

  • Pass the use of the recent days: the projection and the sparkline need it.
  • Pass now from the server when the page is server-rendered: both sides write the same date.
  • Lead with what is left, not what is used: it is what people decide on.

Generated from the code of @krizaka/ui 5.3.4: its meta.ts, its examples and its types.Edit this documentation on GitHub

On this page