MobileTopBar
The bar above the page below 640 px, with the store's mark or a back link, the page's name, and icon buttons for search and notifications.
Import
import { MobileTopBar } from '@nizivo/react/mobile-top-bar';
// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/mobile-top-bar.css';Static or interactive
Server. It is a layout with slots and ships no client JavaScript of its own; the example's IconButtons bring their tooltip's. How to choose.
In a client app (a Vite or React Router single-page app, or a 'use client' file) it is an ordinary React component: event handlers, refs and state work as usual. In a client app.
Slots
mark: Figma's 32 px Store mark, an initial or a logo image.leading: in place ofmark, for example a back link on a detail page.title: the page's name in Heading/H4's look, with an ellipsis when long. As in the TopBar, it is text, not a heading.actions:IconButtons, usually search and notifications. Figma draws bare 20 px icons there; a button gives each a name and a 44 px target under a touch pointer.
Hooks: --nz-mobile-top-bar-padding-inline, --nz-mobile-top-bar-bg, --nz-mobile-top-bar-border,
--nz-mobile-top-bar-mark-bg.
Examples
Basic
Figma's Mobile Top Bar: the store's mark, the page's name, then search and notifications as IconButtons (Figma draws bare icons). Below 640 px it takes the TopBar's place.
import type { JSX, ReactNode } from 'react';
import { IconButton } from '@nizivo/react/icon-button';
import { MobileTopBar } from '@nizivo/react/mobile-top-bar';
/** Stands in for an `@nizivo/icons` glyph (20 px Lucide strokes). */
function Glyph({ children }: { children: ReactNode }): JSX.Element {
return (
<svg
viewBox="0 0 24 24"
width="1em"
height="1em"
fill="none"
stroke="currentColor"
strokeWidth={1.92}
strokeLinecap="round"
strokeLinejoin="round"
>
{children}
</svg>
);
}
const ICONS = {
search: (
<Glyph>
<circle cx="11" cy="11" r="8" />
<path d="m21 21-4.3-4.3" />
</Glyph>
),
bell: (
<Glyph>
<path d="M10.3 21a1.94 1.94 0 0 0 3.4 0M3.26 15.33A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.67C19.41 13.96 18 12.5 18 8A6 6 0 0 0 6 8c0 4.5-1.41 5.96-2.74 7.33" />
</Glyph>
),
};
export function MobileTopBarExample(): JSX.Element {
return (
<MobileTopBar
mark="M"
title="Overview"
actions={
<>
<IconButton icon={ICONS.search} label="Search" variant="tertiary" />
<IconButton icon={ICONS.bell} label="Notifications, 3 unread" variant="tertiary" />
</>
}
/>
);
}
Props
The bar above the page below 640 px (AppShell's mobileTopBar).
Server component Renders data-slot="mobile-top-bar" with the class nz-mobile-top-bar. Props: MobileTopBarProps. Source: src/mobile-top-bar/mobile-top-bar.tsx.
| Name | Type | Default | Description |
|---|---|---|---|
actions | ReactNode | – | At the end, usually a search IconButton and a notifications IconButton. |
leading | ReactNode | – | In place of |
mark | ReactNode | – | The store's mark, drawn as Figma's 32 px Store mark: an initial, or a logo image that fills it. |
render | RenderProp<Record<string, never>> | – | |
title | ReactNode | – | The page's name, in Heading/H4's look (Figma's Title). Not a heading element. |
- Also takes every attribute of
<header>exceptchildren,title. (Omit<ComponentPropsWithRef<"header">, "title" | "children">)
render takes an element, or, in client code, a function of the props and no state.
Other exports
MobileTopBarPropstypeimport type { MobileTopBarProps } from '@nizivo/react/mobile-top-bar'The props of
MobileTopBar, listed above.
Data attributes and slots
Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.
| Slot | Rendered by | Data attributes |
|---|---|---|
mobile-top-bar.nz-mobile-top-bar | MobileTopBarroot (takes render) | none |
mobile-top-bar-actions.nz-mobile-top-bar-actions | MobileTopBarinner element (CSS only) | none |
mobile-top-bar-mark.nz-mobile-top-bar-mark | MobileTopBarinner element (CSS only) | none |
mobile-top-bar-title.nz-mobile-top-bar-title | MobileTopBarinner element (CSS only) | none |
CSS hooks
Set a hook on the component's class or any ancestor to restyle it without specificity games; leave it unset for the default shown.
| Hook | Default | Read as |
|---|---|---|
--nz-mobile-top-bar-bg | --nz-bg-canvas |
|
--nz-mobile-top-bar-border | --nz-border-subtle |
|
--nz-mobile-top-bar-mark-bg | --nz-bg-brand |
|
--nz-mobile-top-bar-padding-inline | --nz-space-4 |
|
Layers: nz.components. Classes: .nz-mobile-top-bar, .nz-mobile-top-bar-actions, .nz-mobile-top-bar-mark, .nz-mobile-top-bar-title.
Tokens this stylesheet reads (15)
--nz-bg-brand, --nz-bg-canvas, --nz-border-subtle, --nz-border-width-default, --nz-font-heading-h4, --nz-font-label-m-strong, --nz-radius-sm, --nz-space-1, --nz-space-3, --nz-space-4, --nz-space-8, --nz-text-on-brand, --nz-text-primary, --nz-tracking-heading-h4, --nz-tracking-label-m-strong
Accessibility
Nothing in this component takes focus or keyboard input.
Keyboard
None.
Figma
Node ids from design/component-map.json, which nz gen writes from component.json. The links open the Nizivo Figma library, which may ask you to sign in.
- Canonical: none
- Ghost masters: Figma node
764:3397
MobileTabBar
Five destinations at the bottom of the screen below 640 px, in place of the Sidebar. They are links in a navigation landmark, and More opens the rest in a bottom sheet.
Motion
CountUp: a number that counts up to its value on the client, while the server renders the final value in NumberValue's element. Tabular digits that keep their width, 0 ms under reduced motion, and nothing announced while it counts. Also useCountUp, for an element of your own.