メインコンテンツへスキップ
menumenu tanreiexpand_morecontrasttranslate
tanreiexpand_more
はじめにWebReactSwiftUIJetpack ComposeFlutterReact Nativeプリセット自分のデザインシステムを作るAI エージェントと Tanrei を使うブランドデザイントークンデザインシステムとカスタマイズTheme Studioカラータイポグラフィアイコン形状エレベーションモーションインタラクション状態振る舞いレイアウトアクセシビリティ言葉カラートークンタイプスケールトークン形状トークンエレベーショントークンモーショントークン状態トークンスペースと寸法のトークンコンポーネントボタンメインアクションボタンセグメントボタンボタングループメニュー付きボタンツールバーコピーボタンチェックボックスラジオボタンスイッチチップメニュースライダースライダーフィールドカレンダーDateTimePickerフィールドグループラジオグループチェックボックスグループセレクトセレクトフィールドメニューバーファイルアップロードファイルピッカー 上級者向けドロップゾーンテキスト入力欄 上級者向けテキストフィールドチップフィールドフィールドコンボボックス 上級者向けコンボボックスフィールド数値入力欄 上級者向け数値フィールドカラー入力欄 上級者向けカラーフィールドワンタイムコード入力欄 上級者向けワンタイムコードフィールド埋め込みテキスト入力欄 上級者向けチャットコンポーザーカード区切り線モーダルレイヤー 上級者向けダイアログリストリスト行ボトムシートサイドシートカルーセルコードブロックテーブルポップオーバーステップアコーディオン説明リスト図アプリシェルページヘッダーツリービュータイムライン画像プレビューハンドルサイズ変更できる枠スクロールエリアバッジプログレスインジケーターメーターナンバーティッカーローディングインジケータースナックバーツールチップキーボードショートカットタグインラインコードコールアウトアバター空の状態タググループスケルトンファイル項目色見本マーキーテキストタブタブビューアプリバーナビゲーションバーナビゲーションドロワー検索リンクページネーション前後のリンクステッパーパンくずリスト目次リンクカードFAB メニューステータスTanrei の作り方コントリビューションライセンスと帰属
ホームコンポーネントナンバーティッカー

ナンバーティッカー

件数、価格、スコア、ダッシュボードの数字のように変わる数を、変わった桁だけを新しい値まで動かして示します。見る人には変わったこと、その向き、おおよその量が伝わり、支援技術には落ち着いた最後の値だけが伝わります。

content_copyMarkdown で表示
カテゴリ
コミュニケーション
トークン
comp.number-ticker
レベル
基礎

概要

Web
tanrei-number-ticker
clock_loader_40
SwiftUI
TanreiNumberTicker
radio_button_unchecked
Jetpack Compose
TanreiNumberTicker
radio_button_unchecked
Flutter
TanreiNumberTicker
radio_button_unchecked
React Native
NumberTicker
radio_button_unchecked

生成元 docs/status/status.json, specs/number-ticker.spec.json

画面に入ったときに値まで上がっていく数字

使い方

Web と React の例は現在の仕様に沿っています。SwiftUI、Compose、Flutter、React Native は予定で、まだナンバーティッカーを提供していません。

<tanrei-number-ticker value="1234" label="注文数"></tanrei-number-ticker>
<tanrei-number-ticker value="98400" number-style="currency" currency="USD" label="売上"></tanrei-number-ticker>

<!-- ダッシュボードの数字は、初めて画面に入ったときに 0 から上がる。 -->
<tanrei-number-ticker start-value="0" value="0.426" number-style="percent" fraction-digits="1"></tanrei-number-ticker>

<!-- 人が変えている数:変化が落ち着くたびに 1 回だけ知らせる。 -->
<tanrei-number-ticker value="2" live="polite" label="カートの商品数"></tanrei-number-ticker>

<script type="module">
  import '@tanrei/web/components/number-ticker';
  const ticker = document.querySelector('tanrei-number-ticker');
  ticker.value = orders.length;
  ticker.addEventListener('settle', (event) => console.log('now showing', event.detail.value));
</script>
import { NumberTicker } from '@tanrei/react';

<NumberTicker value={orders.length} label="注文数" />
<NumberTicker value={revenue} numberStyle="currency" currency="USD" label="売上" />
<NumberTicker startValue={0} value={0.426} numberStyle="percent" fractionDigits={1} />
<NumberTicker value={count} live="polite" label="カートの商品数" onSettle={(event) => setShown(event.detail.value)} />

仕様

アニメーション:slide(既定のシステムの選択)、blur、blur-slide、flip

trend:auto(19 から 20 で両方の桁が上へ)と digit(1 の位が 9 から 0 へ下がる)

構成要素

パーツ 説明
1 number The formatted number, laid out as text in the style of where it stands: every digit in a column of its own, every other character (a sign, a separator, a currency, a unit, a compact suffix) as plain text between them.
2 digit One digit's place: a window one digit high showing one digit of a column of the digits 0 to 9 stacked from top to bottom, which moves through the window to show another.
3 text The label and the formatted value as one text for assistive technology, not drawn.

プロパティ

プロパティ 型 既定値 説明
value number 0 The number shown.
style decimal | percent | currency | unit "decimal" How the number is written, by the platform's number formatter. percent multiplies by 100 and adds the locale's percent sign; currency writes it as an amount of currency; unit with the unit unit names.
currency string "" The currency while style is currency, as its three-letter code ("JPY", "EUR"). Not words: the formatter writes the locale's symbol.
unit string "" The unit while style is unit, as the formatter's identifier of a unit ("kilometer-per-hour", "megabyte"). Not words: the formatter writes the locale's form.
notation standard | compact "standard" standard writes every digit; compact writes the number short with the locale's suffix (1.2K, 1.2万).
fractionDigits number null How many digits after the decimal separator are always written. Null leaves it to the formatter for the style (none for a whole decimal, the currency's own for currency).
signDisplay auto | always | except-zero "auto" When a sign is written: auto for a negative number only; always for every number; except-zero for every number but zero (a change: +12, −3, 0).
locale string "" The language the number is written in, as a language tag ("ja-JP", "ar-EG"). Empty takes the language of where the ticker stands, and the platform's where none is set.
trend auto | up | down | digit "auto" Which way the digits move. auto: every changed digit moves the way the whole number moved — up when it grew, down when it shrank — so that 19 to 20 moves both digits up. up and down force one way. digit: each digit moves the way its own value moved, so that 19 to 20 moves the ones down from 9 to 0.
animation auto | slide | blur | blur-slide | flip | none "auto" How a digit changes. slide: its column moves through the window. blur: the old digit blurs out as the new one sharpens in. blur-slide: both, the new one coming from the side the digit moves from. flip: the upper half of the old digit turns down over the lower half, as a split-flap board. none: at once. auto takes comp.number-ticker.animation, the design system's answer (slide in the default system).
startValue number null A value to move from the first time the ticker comes into view (a dashboard's figures rising to their values). Null draws the first value at once.
duration number null How long a change takes, in milliseconds. Null takes comp.number-ticker.motion.duration.
live off | polite "off" Whether assistive technology is told each new value as it settles. off for a number that is not the point of the moment (most figures); polite for one a person waits for (a counter they are changing, a result arriving).
label string "" Words read before the value ("Revenue"), where nothing visible beside the number already says what it is. Never drawn.

イベント

イベント 説明
settle The digits came to rest at value: once at the end of each change's motion (at once where there is none). Carries value.

状態

振る舞い

EARS 記法による要件です。各プラットフォームの実装は、この ID に対応するテストで検証されます。要件の原文は仕様ファイルのものをそのまま掲載しています。

ID 要件
NTK-1 THE number ticker SHALL write value with the platform's number formatter in locale (the language of where it stands while locale is empty), with style, currency, unit, notation, fractionDigits and signDisplay, SHALL draw every digit of the result — in the locale's own digits — in a digit place of its own, in tabular figures of the font of where it stands so that every digit is as wide as every other, and every other character the formatter writes as plain text in that font; it SHALL lay the number out inline, in the text style, color and direction of where it stands, as one run isolated from the text around it, and SHALL draw no fill, edge or color of its own.
NTK-2 THE number ticker SHALL draw each digit place as a window one line high that shows one digit of a column of the locale's digits 0 to 9 stacked from top to bottom, clipped to the window, so that a greater digit lies lower in the column; to show a digit the column SHALL stand with that digit in the window.
NTK-3 WHEN value changes while animation is slide THE number ticker SHALL move the column of every digit place whose digit changes from the old digit to the new one: WHILE trend is digit, down the column toward a greater digit (the column moving up through the window, the new digit rising from below) and up it toward a lesser one; WHILE trend is auto, every changed digit in the direction the whole number moved — toward the greater digits when value grew and toward the lesser when it shrank — going on past 9 to 0 (or back past 0 to 9) where the new digit lies the other way, so that 19 to 20 moves the ones one step on from 9 to 0 and the tens one step on from 1 to 2; WHILE trend is up or down, every changed digit in that direction as auto does for a number that grew or shrank. Each column SHALL move over the change's duration (duration, or comp.number-ticker.motion.duration while it is null) with comp.number-ticker.motion.easing, each digit place, from the most significant to the least, starting comp.number-ticker.motion.stagger after the one before it.
NTK-4 WHEN value changes while animation is blur THE number ticker SHALL cross-fade each changed digit over the change's duration, the old digit blurring from none to comp.number-ticker.blur.radius as it fades out and the new one sharpening from that radius to none as it fades in; WHILE animation is blur-slide it SHALL do the same while moving the old digit out and the new one in by comp.number-ticker.blur-slide.distance in the direction slide would (NTK-3); WHILE animation is flip it SHALL turn the upper half of the old digit down about the digit's middle over the lower half, showing the upper half of the new digit behind it and then its lower half, as a split-flap board, over the change's duration with comp.number-ticker.motion.easing.
NTK-5 WHEN the formatted number gains or loses characters (99 to 100, 999 to 1,000, a sign that appears) THE number ticker SHALL move its width to the new one with the digits' motion, keeping its end edge still WHILE it is aligned to the end of where it stands and its start edge still otherwise; a digit place that appears SHALL slide in with its column from the side the change moves from and fade in, one that goes SHALL slide out the other way and fade out, and a character that is not a digit SHALL fade in or out in its place.
NTK-6 WHEN value changes again before a change's motion has ended THE number ticker SHALL move every digit place from where it is drawn at that moment to the new digit, by the rule of NTK-3 for the new change, and SHALL never jump to a digit first; the change's duration SHALL start again from that moment.
NTK-7 WHERE motion is reduced, or WHILE animation is none, THE number ticker SHALL show the new number at once, its width included — cross-fading the old number to the new one over comp.number-ticker.motion.reduced-duration where motion is reduced and the platform can fade — and SHALL emit settle at once.
NTK-8 WHEN the ticker first comes into view WHILE startValue is not null THE number ticker SHALL draw startValue and move to value as a change of NTK-3 and NTK-4, once; WHILE startValue is null, and on every later first drawing, it SHALL draw value at once without a motion.
NTK-9 THE number ticker SHALL expose to assistive technology one text — label where it is not empty, then the number written as NTK-1 says — and SHALL hide every drawn digit, column and character from it, so that the number is read once, as written, and never digit by digit or as the digits passing through the windows; the text SHALL be the current value, in place, read where the ticker stands — WHILE live is polite, the value of the last change that settled (NTK-10).
NTK-10 WHILE live is polite THE number ticker SHALL tell assistive technology the text of NTK-9, politely and without moving focus, once WHEN a change's motion ends — the text itself changing only then, so that what a region holds is what it says — and SHALL tell it no value in between, nor any value of a change that a later change replaced before it ended; WHILE live is off it SHALL tell it nothing by itself.
NTK-11 WHEN the digits come to rest at value THE number ticker SHALL emit settle once with value; a change that a later change replaces before its end SHALL emit none.
NTK-12 IF value is not a finite number THE number ticker SHALL draw what the formatter writes for it (the locale's sign for infinity, or its word for a value that is not a number) as plain text at once, without a motion, and in debug builds report it; IF style is currency and currency is not a code the formatter knows, or style is unit and unit is not a unit it knows, THE number ticker SHALL write the number as decimal and in debug builds report the value.
NTK-13 WHERE the layout direction is right-to-left THE number ticker SHALL lay out the number as the formatter writes it for its locale — digits in the order the locale writes them, which is left to right in every locale, isolated from the text around it — and SHALL move its columns up and down as in a left-to-right layout; only the side it stands at and the edge NTK-5 keeps still follow the direction.
NTK-14 THE number ticker SHALL take its layout direction and its language from where it is used — the nearest ancestor that sets one, and the platform's own where none does — and SHALL have no direction setting of its own; WHEN either changes while the ticker is shown THE number ticker SHALL write and draw the number for the new one at once, without a motion.
NTK-15 WHILE the text size is enlarged THE number ticker SHALL grow with the text it stands in, its windows a line of the larger text high and its motion's distances with them.
NTK-16 WHEN animation names a value the active design system does not have, or trend, style, notation, signDisplay or live a value the component does not define, THE number ticker SHALL use the default value (auto, decimal, standard, auto, off) and in debug builds report the unknown value; WHEN duration is not a positive number, or fractionDigits not a whole number from 0 to 100, THE number ticker SHALL treat it as null and in debug builds report it.
NTK-17 THE number ticker SHALL have no words of its own and SHALL read none of the product's words: label is about this one number, and every sign, separator, symbol and suffix is the platform's formatter's, in the locale.

プラットフォーム別の名前対応

パリティは API が同一であることを意味しません。同じ契約を、各プラットフォームの流儀で表現します。

仕様 Web SwiftUI Jetpack Compose Flutter React Native
コンポーネント tanrei-number-ticker TanreiNumberTicker TanreiNumberTicker TanreiNumberTicker NumberTicker
value · プロパティ value value value value value
style · プロパティ numberStyle format format format format
currency · プロパティ currency format format format format
unit · プロパティ unit format format format format
notation · プロパティ notation format format format format
fractionDigits · プロパティ fractionDigits format format format format
signDisplay · プロパティ signDisplay format format format format
locale · プロパティ locale locale locale locale locale
trend · プロパティ trend trend trend trend trend
animation · プロパティ animation animation animation animation animation
startValue · プロパティ startValue startValue startValue startValue startValue
duration · プロパティ duration duration duration duration duration
live · プロパティ live live live live live
label · プロパティ label label label label label
settle · イベント settle onSettle onSettle onSettle onSettle
備考 <tanrei-number-ticker value number-style currency unit notation fraction-digits sign-display locale trend animation start-value duration live label>; style is spelled numberStyle (attribute number-style) because style is every element's own. Intl.NumberFormat(…).formatToParts gives the characters; each digit place is an inline-block column moved by transform: translateY() through the Web Animations API, and a retarget reads the drawn position from getComputedStyle first (NTK-6). The width moves with the shared size transition primitive. The text of NTK-9 is a visually hidden span; the drawn number is aria-hidden. The first view of NTK-8 is an IntersectionObserver. The characters are laid out as flex items in the locale's direction, the digits and their separators in one left-to-right run (NTK-13). A change of an ancestor's lang is seen by one MutationObserver shared by every ticker (NTK-14). The six format props are one FloatingPointFormatStyle value (.number, .percent, .currency(code:), .measurement, with .notation(.compactName), .precision, .sign(strategy:)); locale is the environment's unless given. contentTransition(.numericText(countsDown:)) is not used: it cannot follow the trend rule of NTK-3 or the retarget of NTK-6. The six format props are one TanreiNumberFormat value built on ICU's NumberFormatter (android.icu.number). Each digit column is an Animatable offset; liveRegion = LiveRegionMode.Polite is set on a node whose text changes only at settle. The six format props are one NumberFormat of the intl package. Semantics(liveRegion:) on a node whose label changes only at settle. The six format props are one format: Intl.NumberFormatOptions (Hermes ships Intl.NumberFormat). accessibilityLiveRegion="polite" on Android and AccessibilityInfo.announceForAccessibility on iOS, at settle only.

トークン

トークン 参照先 解決値(ライト)
--tanrei-comp-number-ticker-animation — 0
--tanrei-comp-number-ticker-blur-slide-distance sys.space.space100 8px
--tanrei-comp-number-ticker-blur-radius sys.space.space100 8px
--tanrei-comp-number-ticker-motion-duration sys.motion.role.resize.large 400ms
--tanrei-comp-number-ticker-motion-easing sys.motion.easing.spatial cubic-bezier(0.2, 0, 0, 1)
--tanrei-comp-number-ticker-motion-reduced-duration sys.motion.role.reduced 100ms
--tanrei-comp-number-ticker-motion-stagger sys.motion.duration.short1 50ms

フィクスチャ

基準となる描画パターンです。全プラットフォームが同じ ID でスナップショットを撮り、結果を比較できるようにしています。

生成元 specs/number-ticker.spec.json, tokens/comp/number-ticker.tokens.json, design/tokens/

ガイドライン

使う場面

人が見ている間に変わり、その変化そのものに見る価値がある数に使います。注文が届くたびに増える件数、動く価格、スコア、ページを開いたときに値まで上がっていくダッシュボードの数字などです。動きによって、数が変わったこと、その向き、おおよその量が伝わります。

めったに変わらない数や、変わる瞬間を誰も見ていない数は、ふつうのテキストにします。割り当てに対するストレージ使用量のように、決まった範囲の中の水準はメーターです。時刻や日付は数ではありません。プラットフォームの日付と時刻の書式で書きます。

数の書き方

ナンバーティッカーは、自分の言葉も数の規則も持ちません。数はプラットフォームの数の書式が読み手の言語で書きます。桁区切りと小数点、通貨記号、パーセント記号、大きな数の短い形(1.2K、1.2万)、そして数字そのもの(エジプトのアラビア語では ١٢٣٤)です。スタイル(decimal、percent、currency、unit)、通貨コードか単位、短縮表記、小数部の桁数、符号を書く場合を選びます。言語を指定しなければ、置かれた場所の言語を使います。

書体、大きさ、色も持ちません。置いた場所の文字のスタイルで、等幅の数字で描くので、桁が変わっても数の位置がずれません。ダッシュボードのカードの大きな数字にも、文中の件数にもなります。

アニメーションの選び方

アニメーション 用途
Slide ほとんどの数。変わった桁の列が新しい数字まで回ります。既定のシステムの選択です。
Blur 控えめな変化。古い数字がぼやけて消え、新しい数字がはっきり現れます。
Blur slide 同じ変化に、変化の向きへの短い移動が加わります。
Flip 反転フラップ式の表示板。発車案内、カウントダウン、機械的な見た目のプロダクトに。
None すぐに変わらなければならない数。

プロダクトの中ではアニメーションを 1 つにそろえます。ティッカーごとではなく、デザインシステムで 1 回(comp.number-ticker.animation)設定します。

trend の選び方

既定では、変わった桁はすべて数全体の動いた向きに動きます。増えたら上へ、減ったら下へ動くので、19 から 20 では両方の桁が上へ動きます。1 つの数の 1 回の変化として読めます。それぞれの位がそれ自体で意味を持つ場合は digit を選びます。各桁が自分の変化の向きに動くので、1 の位は 9 から 0 へ下がります。up と down は向きを固定するもので、一方向にしか数えない数に使います。

推奨

  • テキストの中に置くか、入れ物に望む文字のスタイルを与えます。ティッカーはすべてをそこから受け取ります。
  • 数の横に何の数かを示すものが見えていないときは、ラベルを付けます(「売上」「注文数」)。
  • ひとりでに変わる数字では live をオフのままにします。人が待っている数や、人が変えている数だけオンにします。
  • ダッシュボードでは開始値を使い、数字が初めて見えたときに 1 回だけ上がるようにします。

非推奨

  • ティッカーで増加を緑に、減少を赤に塗らないでください。そのような色は持っていません。変化に意味があるなら、数の横で伝えます(タグ、言葉、ラベル付きの矢印)。
  • 1 秒に何度も数を更新しないでください。1 回の変化には動きの時間がかかり、変化が続けて届くと雑音に見えます。人が追える速さで更新します。
  • 時間には使わないでください。時計の桁は 9 ではなく 59 で繰り上がります。

アクセシビリティ

ロール
none (text)
ラベル付け
Read as one text: label, then the number as the formatter writes it. The drawn digits are hidden. With live polite, the settled value is told once per change.
最小ターゲット
見た目のサイズが小さくても、ヒット領域は最小ターゲットサイズを満たします。 minimum 32px · pointer 44px · spacing 8px · touch 48px

キーボード操作

キー 動作

備考

  • Not interactive: no focus, no input, no target; minimumTarget holds trivially.
  • Live regions: a number that is not the point of the moment is told nothing (off); one a person waits for is told politely once it settles, never each value it passes through.
  • Pause, Stop, Hide (WCAG 2.2.2): one change's motion ends well within five seconds. A number the product updates by itself, again and again, alongside other content is auto-updating content: the product gives the means to pause the updates, or to set how often they come.
  • Animation from interactions (WCAG 2.3.3): where motion is reduced, the number changes at once (NTK-7).

生成元 specs/number-ticker.spec.json, tokens/sys/measure.tokens.json

コンポーネントが担うこと

  • 支援技術が読むのは 1 つのテキストです。ラベルと、書式どおりの数です。描いた数字は隠すので、数が 1 桁ずつ読まれたり、窓を通り過ぎる数字が読まれたりすることはありません。
  • 既定では何も知らせません。ほとんどの数字はその場の主題ではないからです。live を polite にすると、変化が落ち着くたびに 1 回だけ控えめに知らせます。途中の値や、後の変化に置き換えられた値は知らせません。
  • 動きを減らす設定のときは、新しい数がすぐに表示され、古い数が短くフェードアウトします。
  • 置かれた場所の言語と方向を使い、どちらかが変わるとすぐに数を書き直します。
  • 未知の animation、trend、style、notation、sign display、live の値、正でない duration、書式が知らない通貨や単位、数でない値は、デバッグビルドで報告します。

利用者がすること

  • プロダクトが数をひとりでに何度も更新し、それがほかの内容と並んでいるなら、更新を止める手段か、更新の頻度を選ぶ手段を用意します(WCAG 2.2.2 一時停止、停止、非表示)。
  • 大事な変化では、その意味を言葉で伝えます。動きは変わったことを示しますが、それが良いことか悪いことかは伝えません。