Components

NavigationLink

Navigate to a React page inside NavigationStack, open a URL, or dismiss the current page.

Example

Requires React 18.2+ or 19 and shared styles. See setup.

Default

Loading preview…

Code
'use client';
import { VStack, Text, NavigationStack } from '@swiftuijs/ui';
import { NavigationLink } from '@swiftuijs/ui';
function DetailPage() {
    return (<VStack spacing={20}>
      <Text style={{ fontSize: '24px', fontWeight: 'bold' }}>Detail Page</Text>
      <Text>This is a detail page navigated from NavigationLink</Text>
      <NavigationLink dismiss>Go Back</NavigationLink>
    </VStack>);
}
export default function Example() {
    return ((<NavigationStack style={{ height: 420 }}>
      <VStack spacing={20}>
        <NavigationLink destination={DetailPage}>
          <Text>Go to Detail</Text>
        </NavigationLink>
      </VStack>
    </NavigationStack>));
}

Usage and limitations

  • Component destinations require a NavigationStack with a bounded height. URL destinations render a normal a element and follow browser navigation.
  • Component/dismiss links render buttons. Put text or non-interactive content inside; do not nest a Button, link or other control.
  • Use dismiss to go back, or call useNaviContext().dismiss() from a page. For conditional navigation, render a link only when the destination is available, or call the navigation context after validating.
  • pageOptions.type is page (default) or actionsheet. The latter is a legacy navigation presentation; use Sheet for modal focus isolation and ConfirmationDialog for a list of actions.
  • This is in-memory navigation. Browser history, routes and deep links need application integration.

Transitions

Pass pageOptions={ transition: { type: 'fade', duration: 200 } }. The same configuration is accepted by StandardPage.transition.

OptionValues / defaultUse
typeslide, fade, scale, view-transition, noneSlide for pages; fade/scale for overlays; none for immediate navigation
directionforwards, backwards, auto (default)Slide push/pop direction
durationMilliseconds; 300 by defaultOverride animation duration
easingCSS easing; slide defaults to cubic-bezier(0.075, 0.82, 0.165, 1)Control animation timing; fade defaults to ease-out
viewTransitionNameA unique stringMatch style.viewTransitionName on source and destination elements

View Transitions need browser support; unsupported browsers use CSS animation fallbacks. Shared elements such as images/cards must use matching names on both pages. Avoid duplicate names within one rendered page.

See StandardPage for titles and toolbars and NavigationStack for path control.

More examples

External URL
Action Sheet

API reference

PropTypeRequiredDescription
destinationstring | ComponentTypeNoThe destination component or URL to navigate to. If a string is provided, it will navigate to that URL. If a ComponentType is provided, it will navigate to that component within the NavigationStack. Default: undefined
pageOptions{ /** * The type of page presentation. */ type?: IPageType /** * Transition configuration for page animation. * * @example * ```tsx * transition: { * type: 'view-transition', * viewTransitionName: 'shared-element' * } * ``` */ transition?: ITransitionConfig }NoOptions for configuring the page presentation.
dismissbooleanNoA Boolean value that indicates whether to dismiss the current page. When true, clicking the link will navigate back instead of forward. Default: false

Inherits additional props from IBaseComponent.