ナビゲーション · 準拠済み
NavigationSuite
NavigationSuiteNavigationSuiteProps
import {
FloatingActionButton,
Icon,
NavigationSuite,
Surface,
Text,
} from '@language-lit/material3-expressive'
export function NavigationSuiteExample() {
return (
<Surface
as="section"
aria-labelledby="navigation-suite-example-title"
color="surface-container-low"
shape="extra-large"
className="navigation-suite-example"
>
<Text as="h2" id="navigation-suite-example-title" variant="titleLarge" emphasis="emphasized">
Navigation suite
</Text>
<Text as="p" variant="bodyMedium">
Adaptive: renders Navigation bar below 600px, Navigation rail from
600–839px, and a permanent Navigation drawer at 840px and up. Resize
the window to see it switch live.
</Text>
<div className="navigation-suite-example__frame">
<NavigationSuite
aria-label="Example sections"
header={<FloatingActionButton aria-label="Compose" icon={<Icon source="add" />} size="medium" />}
items={[
{
value: 'home',
label: 'Home',
icon: <Icon source="home" />,
selectedIcon: <Icon source="home" fill={1} />,
},
{ value: 'favorites', label: 'Favorites', icon: <Icon source="favorite" /> },
{ value: 'settings', label: 'Settings', icon: <Icon source="settings" /> },
{ value: 'archive', label: 'Archive', icon: <Icon source="archive" />, disabled: true },
{ value: 'docs', label: 'Docs', icon: <Icon source="description" />, href: '#' },
]}
/>
</div>
</Surface>
)
}NavigationSuiteはビューポート幅に応じて最適なナビゲーションレイアウトを自動選択します。固定されたMaterialのブレークポイントに従い、600px未満ではNavigationBar、600〜839pxではNavigationRail、840px以上では常設のNavigationDrawerを表示します。
import { Icon, NavigationSuite } from '@language-lit/material3-expressive'
import '@language-lit/material3-expressive/styles.css'
<NavigationSuite
aria-label="Primary sections"
items={[
{ value: 'home', label: 'Home', icon: <Icon source="home" /> },
{ value: 'favorites', label: 'Favorites', icon: <Icon source="favorite" /> },
]}
/>仕様
itemsとvalue/defaultValue/onValueChangeにはNavigationBarと同じNavigationItem形式を使います。headerはNavigationRailにだけ渡され、ほかの2つの表示幅では無視されます。- 独自のコンポーネントトークンは登録しません。表示中の
NavigationBar/NavigationRail/NavigationDrawerが色、形状、モーションの値をすべて提供します。 - 実際のビューポート幅を測定できないため、サーバーレンダリング時とハイドレーション前のマークアップは常にコンパクト表示(
NavigationBar)になります。マウント直後のクライアントエフェクトで実際の幅を測り、表示を調整します。
構造、バリアント、状態、アクセシビリティ
一度にレンダーされる公開ナビゲーションコンポーネントは1つだけです。コンパクト幅ではバー、中程度の幅ではレール、広い幅では常設ドロワーになります。選択、無効項目、任意のリンク、アイコンの形状、値の制御/非制御状態は、そのコンポーネントの公開仕様に委ねられます。
aria-labelなどでアクセシブルネームを指定し、ナビゲーション領域を識別できるようにします。表示されるバー、レール、ドロワーはネイティブのナビゲーションリンク/ボタンとaria-currentを使い、タブリストの矢印キー動作は採用しません。ビューポートに応じた調整が行われる前でも、サーバーのマークアップはコンパクトなバーとして完全に操作できます。
トークンと境界
テーマの上書きはMaterial3Providerのスコープ内で適用されます。NavigationSuiteは実行時スタイルを注入せず、Next.js、Vite、ルーター、アニメーションライブラリ、非公開のアプリケーションコードをインポートしません。