datui
Color scheme

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 inert and aria-hidden.
  • After a transition, focus moves to the incoming panel's PanelHeader title (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 PanelHeaderBack too.
  • Transitions are skipped when prefers-reduced-motion is set or ConfigProvider transitionMotionEnabled={false}.
  • useNavId(), useNavTransition() and useNavDirection() tell descendants which view/panel they are in and whether a transition is running (defer autofocus until animating is false).
  • Add data-no-swipe-back to 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.

PropTypeDefaultDescription
activePanel (required)string—Id of the `Panel` to show.
childrenReactNode—`Panel`s with unique `id`s.
classNamestring—
historystring[]—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)`.
idstring—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.