BottomNavigation
狭い幅での主要な移動手段。アイコンと短い文字を 3〜5 個並べる。
tsx
import { BottomNavigation } from "knowidea-ui";カテゴリ: Navigation。同じカテゴリ: Link、Tabs、Menu、Breadcrumbs、Pagination、AppBar、Drawer
Demos
Basic
件数のバッジは、項目の右上に表示される。
Show code
tsx
import { BottomNavigation, type NavItem } from "knowidea-ui";const items: NavItem[] = [ { id: "home", label: "ホーム", icon: "home", href: "#home" }, { id: "list", label: "一覧", icon: "list", href: "#list", count: 3 }, { id: "calendar", label: "予定", icon: "calendar", href: "#calendar" }, { id: "settings", label: "設定", icon: "settings", href: "#settings" },];function Basic() { return ( <div style={{ width: "min(100%, 390px)", border: "1px solid var(--color-line)", borderRadius: "var(--radius-3)", overflow: "hidden" }}> <BottomNavigation items={items} current="home" /> </div> );}Plain HTML
React を使わないページでは、knowidea-css の CSS を読み込み、クラスを指定する。
Show code
html
<nav class="ki-bottomnav" aria-label="画面の切り替え"> <ul class="ki-bottomnav__list"> <li><a class="ki-bottomnav__item" href="#" aria-current="page"><svg class="ki-icon" aria-hidden="true"><use href="#home"/></svg>ホーム</a></li> <li><a class="ki-bottomnav__item" href="#"><svg class="ki-icon" aria-hidden="true"><use href="#list"/></svg>一覧</a></li> </ul></nav>States
すべてのコンポーネントが、Empty、Loading、Error、Disabled、Focus の 5 つの状態を備える。Hover と Active は、確認用に固定して表示している。そのコンポーネントにあてはまらない状態は「対象外」とし、理由を添える。
| State | Appearance |
|---|---|
| Empty | 対象外。項目のないナビゲーションは作らない |
| Loading | 対象外。項目は先に決まっているため、ローディング状態を持たない |
| Error | 対象外。エラー状態を持たない |
| Disabled | |
| Focus | 項目に Tab で移ると、2px のリングが表示される |
API
| Name | Type | Default | Description |
|---|---|---|---|
items | NavItem[] | - | 3〜5 個。{ id, label, icon?, href, count?, disabled? } |
current | string | - | 現在のページの id |
label | string | "画面の切り替え" | nav の名前 |
position | "static" | "sticky" | "static" | sticky を指定すると下部に固定される |
CSS
Classes and data attributes
| Name | Description |
|---|---|
.ki-bottomnav | nav。data-position |
.ki-bottomnav__list、__item | リストと項目(aria-current="page" が現在のページ) |
CSS variables
コンポーネントが参照するのは、役割を表す名前の変数だけで、素の値は参照しない。オーバーライドの方法は Overriding を参照。
| Variable | Usage |
|---|---|
| --color-surface、--color-line | 背景と上の線 |
| --color-primary | 現在のページ |
| --size-hit | 項目の高さの基準(52px) |
Accessibility
- <nav> と <ul> を使う。現在のページには aria-current="page" を付ける
- 項目の高さは 52px(44px 以上)。件数のバッジは aria-label で件数を読み上げる