Navigation
View
A stack of Panels with forward/back slide transitions, per-panel scroll restore and touch swipe-back.
import { View } from "datui";Examples
History and swipe-back
Keep a history array; push to go forward, pop to go back. With onSwipeBack, touch users can drag from the start edge to return to history.at(-2).
Settings
Accessibility
- Only the active panel is rendered; during a transition the outgoing panel is
inertandaria-hidden. - After a transition, focus moves to the incoming panel's
PanelHeadertitle (or the panel container) when focus was inside the view, so keyboard and screen-reader users land on the new screen. - Swipe-back is touch-only — always render a visible
PanelHeaderBacktoo. - Transitions are skipped when
prefers-reduced-motionis set orConfigProvider transitionMotionEnabled={false}. useNavId(),useNavTransition()anduseNavDirection()tell descendants which view/panel they are in and whether a transition is running (defer autofocus untilanimatingis false).- Add
data-no-swipe-backto elements (e.g. a horizontal carousel) that should not start the gesture.
API
View
Stack of `Panel`s showing `activePanel`. Switching panels slides forward or back, restores the scroll position when going back and moves focus to the new panel's title. Touch users can swipe back from the start edge.
| Prop | Type | Default | Description |
|---|---|---|---|
| activePanel (required) | string | — | Id of the `Panel` to show. |
| children | ReactNode | — | `Panel`s with unique `id`s. |
| className | string | — | |
| history | string[] | — | Stack of visited panel ids, ending with `activePanel`. Shrinking it means "back"; with two or more entries, touch users can swipe from the start edge to go back to `history.at(-2)`. |
| id | string | — | Id used by `Root`/`Epic` to pick this view. |
| isBackCheck | ((p: { from: string; to: string; }) => boolean) | — | Override back detection, e.g. for histories where the same id repeats. |
| onSwipeBack | (() => void) | — | Swipe-back committed: pop your history here. Without it swipe-back is off. |
| onSwipeBackCancel | (() => void) | — | Swipe released below the threshold; the panel springs back. |
| onSwipeBackStart | ((activePanel: string | null) => "prevent") | — | Swipe-back gesture recognized; return `"prevent"` to cancel it. |
| onTransition | ((event: NavTransitionEvent) => void) | — | Fires once each transition (animated or not) has finished. |