Components
NavigationBar
Display a title, optional back button and page actions.
Example
Requires React 18.2+ or 19 and shared styles. See setup.
Default
Loading preview…
Code
'use client';
import { NavigationBar } from '@swiftuijs/ui';
export default function Example() {
return ((<NavigationBar title="Home"/>));
}Usage and limitations
StandardPagecreates a bar whennavigationTitleis provided and automatically wires back navigation for pushed pages.- A standalone bar requires explicit
showBackButtonandonBack; it does not infer navigation state. - For a custom back guard, render a standalone
NavigationBar, validate inonBack, then calluseNaviContext().dismiss(). Do not also enable the automatic StandardPage bar. toolbarItemsaccepts React content; compose multiple actions withHStack. Keep actions short and label icon-only buttons for screen readers.- Appearance uses theme tokens such as
--sw-accent-color,--sw-color-background-primary, and--sw-color-separator. A localglassoverride controls the bar material.
See StandardPage for an automatic bar and theming for scoped customization.
More examples
With Back Button
With Toolbar Items
In Navigation Stack
API reference
| Prop | Type | Required | Description |
|---|---|---|---|
title | string | No | Navigation bar title |
showBackButton | boolean | No | Whether to show back button Default: false |
onBack | () => void | No | Callback when back button is clicked |
toolbarItems | ReactNode | No | Toolbar items to display on the right side |
glass | boolean | { enabled?: boolean; intensity?: number; variant?: 'regular' | 'clear' } | No | Local material override. Intensity is clamped to 0–1; zero uses an opaque surface. Default: Inherited from UIProvider; off without a provider |
Inherits additional props from GlassSurfaceProps.