组件 · 导航
MobileNav
The phone tab bar — up to 5 destinations at the bottom of a top-level page, the selected one's icon in a yellow sticker.
import { MobileNav } from "@botiverse/raft-ui";MobileNav is the phone web's tab bar: a row of a product's destinations at the bottom of every top-level page. The selected destination's icon sits in a yellow sticker. Pushed pages cover it. The iOS and Android apps draw the same destinations with their own system tab bar instead (Navigation).
When to use
| Situation | Use |
|---|---|
| A product's destinations on a phone | MobileNav |
| The same destinations on desktop | AppRail |
| Sections of one page | Tabs |
| Another view of the same content | SegmentedControl |
How the tab bar works with Back and pushed pages, and how many destinations it holds, is in Navigation. Nothing is attached above the tab bar; where working agents appear instead is in Working agents. Which destinations a product has is on its own page (Raft Chat).
Anatomy
MobileNavRoot: the edge bar, onlayer-card(in dark mode onlayer-frame, the same dark layer as the tab header), with aline-seamalong its top edge and padding for the bottom safe area. It runs the full width at the bottom edge; it is never a floating pill.MobileNavItem: one destination: a 22px icon, then its label.MobileNavLabel: the label, intext-label. It truncates.
Search and More
A product can give one of the tab bar's slots to Search and make its last tab More. Raft Chat does both, in its mobile app and on the phone web.
- Make Search a tab like the others: its page is a top-level page, with no Back, and the bar stays with Search
selected. Search never shows an attention dot. How its page and its results behave is in Navigation. - Make the last tab More when a product has more destinations than fit. More's top-level page is a page of its own that lists the remaining destinations at its top; each row opens a pushed page under More, with Back. A link to one of those pages opens it under More, with More selected.
raft-ui draws both with MobileNavItem. Separate parts for a floating pill and a Search button (MobileNavPill, MobileNavSearch) are no longer planned.
Behavior
- Hide the bar while the on-screen keyboard is open. Pinned above the keyboard, it would cover the field being typed in and the composer. When the keyboard closes, bring the bar back with the platform's default transition, not an instant jump, so people can see the navigation return rather than wonder where it went.
- Show the bar only on top-level pages: a page with Back never shows it (Navigation). Pushed pages cover it; menus, dialogs and bottom sheets leave it as it is.
- Keep the bar in place while a page scrolls. Don't hide it on scroll: it is how people know where they are.
- Tapping the selected item scrolls its page to the top, and on Search focuses the field. Each tab keeps its page's scroll position and filters while another tab is open (Navigation).
States
| State | Look |
|---|---|
| Not selected | Icon and label in foreground-hint |
Selected (selected) | The icon in a 56×30px yellow sticker; the label in foreground, bold |
| Attention | One pink pixel at the top right of the icon (States), never a number. Never on the selected item, with no exception |
The sticker wraps only the icon, not the whole item: a yellow item adds another strip of frame at the bottom of the screen, and wrapping only the icon halves the color while the selection still reads at a glance (Navigation).
Content
- Label every item, in Title Case (Typography). Keep a label to at most 8 Latin letters or 4 Chinese characters, so 5 items fit at 320px; a longer one truncates.
- Which items can show an attention dot is the product's choice. Say other news inside the page instead.
- Show a dot, never a count, on the tab bar: the count belongs inside the page, next to what it counts.
- Dot More only for something inside More that shows nowhere else, and show the same dot on the row that caused it, so people can find what is new.
Accessibility
MobileNavRootrenders anav. Name it witharia-label="Primary".MobileNavItemrenders the Base UI Button;selectedsetsaria-pressed. For an item that navigates, render a link (render={<a href="…" />}withnativeButton={false}) and setaria-current="page"on the selected one: raft-ui sets neither on a link.- The visible label names the item. When an item shows an attention dot, give it an
aria-labelthat says both: "More, new reply to your feedback". The dot itself isaria-hidden.
API
MobileNavItem
| Prop | 类型 | 默认值 |
|---|---|---|
| boolean | true | |
| boolean | ||
| Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ReactElement | ((props, state) => ReactElement) |
Also takes the attributes of its element.
MobileNavLabel, MobileNavRoot
| Prop | 类型 | 默认值 |
|---|---|---|
| Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ReactElement | ((props, state) => ReactElement) |
Also takes the attributes of its element.