メインコンテンツへスキップ
menu palettetanreidark_modetranslate

カラーモード

コントラスト

デザインシステム

ギャラリーのシステムは、Tanrei でどこまで表現できるかを示すために、ほかのデザインシステムを模して作ったものです。サポート対象のデザインではなく、あくまで例です。

リンクをコピーテーマを編集
palettetanrei

カラーモード

コントラスト

デザインシステム

ギャラリーのシステムは、Tanrei でどこまで表現できるかを示すために、ほかのデザインシステムを模して作ったものです。サポート対象のデザインではなく、あくまで例です。

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

サイズトランジション

伸びるメッセージ、1 行増えるセクション、1 行減るパネルのように、大きさが変わるコンテンツを包み、自分の大きさをコンテンツの新しい大きさへ 1 つの動きで運びます。後ろにあるものは跳ばずになめらかに動き、固定した辺は動きません。

content_copyMarkdown で表示
カテゴリ
コンテインメント
トークン
comp.size-transition
レベル
基礎

概要

Web
tanrei-size-transition
clock_loader_40
SwiftUI
TanreiSizeTransition
radio_button_unchecked
Jetpack Compose
TanreiSizeTransition
radio_button_unchecked
Flutter
TanreiSizeTransition
radio_button_unchecked
React Native
SizeTransition
radio_button_unchecked

生成元 docs/status/status.json, specs/size-transition.spec.json

段落に合わせるブロックと、単語に合わせるインラインのボックス

四半期レポートができました。前の版から、費用、人員、次の四半期の計画の 3 つのセクションが加わっています。

保存しました

中のコンテンツの大きさが変わると、ボックスはいま見えている大きさから新しい大きさへ、1 つの動きで移ります。レイアウトで後ろにあるものも一緒に動き、1 フレームで跳ぶことはありません。自分では何も描きません。背景、枠線、角丸、余白はありません。

使い方

Web と React の例は現在の仕様に沿っています。SwiftUI、Compose、Flutter、React Native は予定で、まだサイズトランジションを提供していません。

<tanrei-size-transition>
  <div id="details"></div>
</tanrei-size-transition>
<p>詳細が変わると、この下のものはすべてなめらかに動きます。</p>

<!-- 下端に付いた欄。上へ伸び、最後の行は動きません。 -->
<tanrei-size-transition anchor="end">
  <div id="draft"></div>
</tanrei-size-transition>

<script type="module">
  import '@tanrei/web/components/size-transition';
  const box = document.querySelector('tanrei-size-transition');
  box.addEventListener('settle', (event) => console.log(event.detail.height));
  document.querySelector('#details').textContent = longerText; // 跳ばずに動く
</script>
import { SizeTransition } from '@tanrei/react';

<SizeTransition onSettle={(event) => setHeight(event.detail.height)}>
  {expanded ? <FullDetails /> : <Summary />}
</SizeTransition>

<SizeTransition axis="inline">
  <span>{saving ? '保存中…' : '保存しました'}</span>
</SizeTransition>

仕様

固定する辺:start(既定)、end、center

start:1 行目は動かず、新しい行はその下に現れます。

end:最後の行はボックスの下端に付いたままで、新しい行はその上に現れます。

center:両方の辺が変化の半分ずつ動きます。

構成要素

構成要素

Web パッケージが描くフィクスチャ block の上に描いています。
パーツ 説明
1 box The size transition itself: a box with no look of its own, laid out where it stands, whose size along its axis is the one that moves. It clips what lies beyond it while it moves.
2 content Whatever the product puts in it, laid out at its own natural size and fixed to the box's anchor edge. It is measured, never scaled or stretched.

プロパティ

プロパティ 型 既定値 説明
axis block | inline | both "block" Which of its sizes follows the content. block: its height in a horizontal writing mode (the size across lines); its width is the layout's. inline: its width (the size along a line); its height is the layout's. both: both sizes.
anchor start | end | center "start" Which edge stays still while the box grows or shrinks. start: the block-start edge (the top) for block, the inline-start edge for inline, so that a growing box uncovers what is new below or after and never moves the first line. end: the opposite edges, for a box docked at its container's end that grows upward (a composer above the keyboard). center: both edges move by half.
duration number null How long one change takes, in milliseconds, used as given for every distance. Null, the default, takes the system's answer, which grows with the distance moved (SZT-3). Set it only where one place needs another tempo than every other size transition of the product.
disabled boolean false Makes the box follow its content's size at once, without a motion: for a change the person should not watch (a list replaced by a search's results) or a stretch of time in which the content changes at every frame.

スロット

スロット 説明
default The content whose size the box follows. Any content: text, a list, another component.

イベント

イベント 説明
settle The box's size has come to rest after a change, by a motion or at once: emitted once per change, after the last frame, with the box's new width and height in the platform's layout units. A motion that is turned round or retargeted (SZT-2) emits once, at its final rest.

状態

振る舞い

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

ID 要件
SZT-1 WHEN the size transition is first drawn THE size transition SHALL take its content's size along its axis in its first frame, without a motion, as every component draws its first frame at rest (MOT-3); content that arrives or changes before that frame is drawn is part of the first frame.
SZT-2 WHEN its content's size along its axis changes after the first frame THE size transition SHALL move its own size in the layout, at every frame, from the size it shows to the new one, over the duration SZT-3 gives with comp.size-transition.motion.easing, so that what stands after it moves with it; WHEN the content changes again during the motion THE size transition SHALL go on from the size then shown towards the newest size as one motion, never jumping to the old target or restarting from the old size (MOT-2).
SZT-3 WHILE duration is null THE size transition SHALL take the duration of a change from the distance its size moves: comp.size-transition.motion.duration for a distance of up to comp.size-transition.motion.distance-step, plus comp.size-transition.motion.duration-step for each further distance-step begun, and never more than comp.size-transition.motion.duration-max; WHILE duration is a number THE size transition SHALL take that many milliseconds for every distance, 0 meaning at once. The duration of a retargeted motion SHALL be computed from the distance between the size shown and the newest size.
SZT-4 WHILE its size differs from its content's THE size transition SHALL clip what lies beyond its box and keep the content fixed to the edge anchor names, mirrored for inline in a right-to-left layout: WHILE anchor is start a growing box SHALL uncover what is new at its block-end (or inline-end) edge and never move its first line, WHILE anchor is end it SHALL uncover what is new at its start edge, the content moving with its end edge, and WHILE anchor is center both edges SHALL move by half the change.
SZT-5 WHILE it moves THE size transition SHALL scroll nothing — neither itself nor its content nor an ancestor — to bring a part of the content into view, also WHILE an element inside it has focus, and SHALL leave focus, the caret and a selection where they are (MOT-5).
SZT-6 WHEN its content's size changes because the room the layout gives it changed — the window or a pane was resized or turned, the text size changed, the layout direction changed — THE size transition SHALL take the new size at once, so that it never lags behind a person resizing the window; and WHILE a size transition inside its content is moving THE size transition SHALL follow its content at every frame, so that two nested motions move as one and do not compound.
SZT-7 WHERE motion is reduced THE size transition SHALL take every new size at once, as size changes are made where motion is reduced (MOT-6), and SHALL still emit settle once per change.
SZT-8 WHILE disabled is true THE size transition SHALL follow its content's size at once; WHEN disabled becomes true during a motion THE size transition SHALL take the newest size at once and emit settle.
SZT-9 WHILE the size transition is not drawn — hidden, outside a view that is shown, or in an app in the background — THE size transition SHALL take every new size at once, and WHEN it is drawn again it SHALL show its content's size without a motion.
SZT-10 THE size transition SHALL expose nothing of its own to assistive technology — no role, no name, no state — and SHALL NOT be a focus stop: its content is read and reached as if the box were not there, including content that the box clips during a motion.
SZT-11 WHEN its size has come to rest after a change, by a motion or at once, THE size transition SHALL emit settle exactly once, after the last frame, with its new width and height; it SHALL emit nothing WHEN its content changes without changing its size along its axis.
SZT-12 THE size transition SHALL draw nothing of its own — no color, edge, shadow, corner or padding — and SHALL take, on the axes it does not follow, the size its layout gives it; WHILE axis is both it SHALL follow the content's width and height together in one motion of one duration, computed from the larger of the two distances (SZT-3).
SZT-13 THE size transition SHALL take its layout direction from where it is used and SHALL have no direction setting of its own; WHEN axis or anchor names a value it does not define THE size transition SHALL use the default value and in debug builds report the unknown value; WHILE duration is a negative number or not a finite number THE size transition SHALL treat it as null and in debug builds report it.

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

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

仕様 Web SwiftUI Jetpack Compose Flutter React Native
コンポーネント tanrei-size-transition TanreiSizeTransition TanreiSizeTransition TanreiSizeTransition SizeTransition
axis · プロパティ axis axis axis axis axis
anchor · プロパティ anchor anchor anchor anchor anchor
duration · プロパティ duration duration durationMillis duration duration
disabled · プロパティ disabled isDisabled enabled disabled disabled
settle · イベント settle onSettle onSettle onSettle onSettle
備考 <tanrei-size-transition axis="block" anchor="start">…</tanrei-size-transition>, built on the package's size-motion primitive (AnimatedSize). The shadow root holds a box and, in it, a wrapper around the slot at its natural size. A resize observer of the wrapper sees a change of the content's size after layout and before the frame is painted; the box then moves from the size the last frame drew to the new one in pixels, with a CSS transition, clipped with overflow: clip (never hidden, which lets a focused descendant scroll the box). The box is a flex container that justifies the wrapper to the anchor's edge (flex-start, flex-end, center), so that the content is laid out at its own size and overflows the edge that moves; justification follows the direction, so the inline axis mirrors in right-to-left. interpolate-size: allow-keywords is not used: it is experimental and not Baseline. SZT-6: a change of the window's size, of the box's own inline size (the room it is given, for axis block), of its font size or of its direction is applied at once, as is any change while a size transition in its content carries data-resizing (the host carries it while it moves). settle is a CustomEvent that does not bubble, whose detail is { width, height } in CSS pixels; a run that is retargeted ends with the run that replaced it. duration is a number property, the duration attribute parsed as the tooltip's delays are (an empty attribute is not a number). The host is display: block (axis inline or both: display: inline-block), as large as the box. A container view that measures its content with a geometry reader and animates its frame with withAnimation on the measured size, .clipped(), aligned by anchor; reduced motion from accessibilityReduceMotion. A Box with Modifier.animateContentSize(animationSpec, alignment) and clipToBounds(); enabled is the inverse of disabled. The spec of SZT-3 is computed from the measured distance before each animation. Built on AnimatedSize with alignment from anchor and clipBehavior: Clip.hardEdge; the duration of SZT-3 is set from the size the child reports before the animation starts. A View that measures its child with onLayout and animates its own height or width with Reanimated, overflow: 'hidden' (React Native has no clip distinction).

トークン

トークン 参照先 解決値(ライト)
--tanrei-comp-size-transition-motion-distance-step sys.space.space800 64px
--tanrei-comp-size-transition-motion-duration sys.motion.role.resize.default 300ms
--tanrei-comp-size-transition-motion-duration-max sys.motion.role.resize.large 400ms
--tanrei-comp-size-transition-motion-duration-step sys.motion.duration.short1 50ms
--tanrei-comp-size-transition-motion-easing sys.motion.easing.spatial cubic-bezier(0.2, 0, 0, 1)

フィクスチャ

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

生成元 specs/size-transition.spec.json, tokens/comp/size-transition.tokens.json, design/tokens/

ガイドライン

使う場面

利用者が見ている間に大きさが変わる、プロダクト自身のコンテンツを包みます。2 行目に折り返す返信の下書き、全文に差し替える要約、自前の入力欄の下に現れるエラーの行、長い言葉に変わるステータスのラベルなどです。包まないと、その下のものがすべて 1 フレームで跳び、利用者はどこを読んでいたかを見失います。

Tanrei のコンポーネントは、自分の大きさの変化をすでに動かしています。伸びるテキスト入力、広がるスナックバー、開くアコーディオンなどです。そのためにサイズトランジションで包む必要はありません。

求めに応じてセクションをまるごと開いたり閉じたりするなら、アコーディオンを使います。開閉はアコーディオンの仕事です。サイズトランジションは何も開閉しません。中にあるものに合わせるだけです。

変化にかかる時間

時間は距離に応じて伸びます。既定のシステムでは、64 ピクセルまでの変化は 300 ms です。さらに 64 ピクセル(に満たない分も含む)ごとに 50 ms を足し、長くても 400 ms です。大きな変化が小さな変化の横でせわしなく見えることも、遠い変化で待たされることもありません。duration は、プロダクトのほかのサイズトランジションと違うテンポが必要な 1 か所にだけ設定します。0 にすると、変化はすぐに反映されます。

軸と固定する辺の選び方

軸 用途
Block(既定) 高さが変わるコンテンツ。段落、リスト、行が増えるセクションなど。幅はレイアウトに従います。
Inline 幅が変わるラベル。ステータスの言葉、件数、ボタンのテキストなど。幅はコンテンツと同じです。
Both 幅と高さが一緒に変わる小さなボックス。2 行目に折り返すバッジなど。両方が 1 つの動きで動きます。
固定する辺 用途
Start(既定) ほとんどのコンテンツ。1 行目は動かず、新しいものはその後ろに現れます。
End キーボードの上のメッセージ入力欄のように、コンテナーの終わりに付いたコンテンツ。最後の行はそのままで、ボックスは先頭の側へ伸びます。
Center 空のパネルの中央に置いたお知らせのように、場所の中央にあるもの。

推奨

  • 変わるコンテンツだけを包みます。ページ全体を包むと、すべてが一度に動きます。
  • 中で何かをドラッグしている間のように、コンテンツが毎フレーム変わる間は disabled にします。検索結果に置き換わるリストのように、利用者に見せる必要のない変化にも使います。
  • 変化のあとで測ったりスクロールしたりするときは、settle を待ちます。最後のフレームのあとに 1 回だけ届きます。

非推奨

  • フェードで現したり消したりするために使わない。動かすのは大きさだけです。フェードはコンテンツの側で付けます。
  • 自分の大きさをすでに動かす Tanrei のコンポーネントを包まない。
  • 指標の上でレイアウトシフトを消すために頼らない。ブラウザーは、レイアウトの変化で動いた要素をそのまま数えます。消えるのは、利用者に見える跳びです。

アクセシビリティ

ロール
none (a generic container that exposes nothing of its own)
ラベル付け
The size transition names nothing and is not named; its content keeps its own names, roles and order.
最小ターゲット
見た目のサイズが小さくても、ヒット領域は最小ターゲットサイズを満たします。 minimum 36px · pointer 36px · spacing 8px · touch 36px

キーボード操作

キー 動作

備考

  • It takes no input, so it has no target of its own; its content keeps its own hit areas.
  • A size change is a motion in the sense of WCAG 2.3.3 (animation from interactions): where motion is reduced it happens at once (SZT-7). The opacity of the content is never changed by this component.
  • Content that the box clips while it moves stays in the reading and focus order: a person who tabs into it during the motion reaches it, and nothing scrolls to show it (SZT-5) — the motion ends within comp.size-transition.motion.duration-max.
  • Browsers count an element moved by a layout change as a layout shift unless a person's input preceded it within a short window. Moving what follows over a motion does not remove it from that count; it removes the jump a person sees. Measure layout shift in a product's own pages.

生成元 specs/size-transition.spec.json, tokens/sys/measure.tokens.json

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

  • 支援技術には自分のものを何も公開しません。ロールも名前も状態もありません。フォーカスも止まりません。中のコンテンツは、ボックスがないかのように読まれ、たどり着けます。
  • 動いている間にボックスが切り取っているコンテンツも、読み上げとフォーカスの順序に残ります。動いている間に Tab で入ればたどり着けます。動きは、既定のシステムでは 400 ms 以内に終わります。
  • 動いている間は何もスクロールしません。ボックスも、中のコンテンツも、ページもです。フォーカス、キャレット、選択範囲もそのままです。
  • 動きを減らす設定のときは、大きさの変化はすべてすぐに反映されます。settle は変化ごとに 1 回届きます。
  • ウィンドウの大きさ、文字の大きさ、方向が変わるなど、レイアウトが与える場所が変わったときは、すぐに反映されます。ウィンドウの大きさを変えている利用者に、ボックスが遅れてついてくることはありません。
  • 未知の axis や anchor、負の値や数でない duration は、デバッグビルドで報告されます。

利用者がすること

  • 重要な変化は自分で知らせます。ライブリージョンか、利用者が目にする通知です。サイズトランジションは大きさを動かすだけで、何も伝えません。
  • コンテンツ自身の名前、ロール、順序を正しく保ちます。サイズトランジションは何も足しません。