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
NavigationStackwith a bounded height. URL destinations render a normalaelement 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
dismissto go back, or calluseNaviContext().dismiss()from a page. For conditional navigation, render a link only when the destination is available, or call the navigation context after validating. pageOptions.typeispage(default) oractionsheet. The latter is a legacy navigation presentation; useSheetfor modal focus isolation andConfirmationDialogfor 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.
| Option | Values / default | Use |
|---|---|---|
type | slide, fade, scale, view-transition, none | Slide for pages; fade/scale for overlays; none for immediate navigation |
direction | forwards, backwards, auto (default) | Slide push/pop direction |
duration | Milliseconds; 300 by default | Override animation duration |
easing | CSS easing; slide defaults to cubic-bezier(0.075, 0.82, 0.165, 1) | Control animation timing; fade defaults to ease-out |
viewTransitionName | A unique string | Match 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
| Prop | Type | Required | Description |
|---|---|---|---|
destination | string | ComponentType | No | The 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
} | No | Options for configuring the page presentation. |
dismiss | boolean | No | A 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.