Components
- Accordion
- Add to Cart
- Animated List
- Carousel
- Collapsible Sidebarnew
- Dynamic Island
- Expandable Cardnew
- Expanding Searchnew
- Filter Grid
- Kanban Board
- Layout Switcher
- Morphing Popover
- Number Flip
- Page Transition
- Product Gallery
- Segmented Control
- Sortable Table
- Stack Navigator
- Status Button
- Step Wizard
- Tabs
- Text Morphnew
- Theme Mode Switch
- Theme Morph Button
- Theme Toggle Button
- Theme Toggle Switch
- Theme Transition
- Toast Stacknew
Messages
Installation
$ pnpm dlx shadcn@latest add @transition-kit/stack-navigatorUsage
import {
StackNavigator,
StackScreen,
useStack,
} from "@/components/transitions/stack-navigator";const Inbox = () => {
const { push } = useStack();
return (
<button type="button" onClick={() => push("chat", { id: "ava" })}>
Ava Chen
</button>
);
};
<StackNavigator initialScreen="inbox" className="h-96 max-w-sm">
<StackScreen name="inbox" title="Messages" render={() => <Inbox />} />
<StackScreen<{ id: string }>
name="chat"
title={({ id }) => getChat(id).name}
actions={({ id }) => <ContactButton id={id} />}
render={({ id }) => <Conversation id={id} />}
/>
</StackNavigator>;API Reference
StackNavigator
| Prop | Type | Default | Description |
|---|---|---|---|
initialScreen | string | first StackScreen | Uncontrolled root screen. |
initialParams | Record<string, unknown> | {} | Params for the uncontrolled root entry. |
stack | StackEntry[] | - | Controlled stack, root first. |
onStackChange | (stack: StackEntry[]) => void | - | Called with the next stack after each navigation. |
StackScreen
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | - | Unique screen name referenced by initialScreen and push. |
render | (params) => ReactNode | - | Screen content rendered for the entry's params. |
title | ReactNode | (params) => ReactNode | - | Header title; morphs into the back button when a screen is pushed on top. |
actions | ReactNode | (params) => ReactNode | - | Trailing header content, e.g. an icon button. |
useStack
| Return | Type | Description |
|---|---|---|
push | (screen: string, params?: Record<string, unknown>) => void | Pushes a new entry onto the stack. |
pop | () => void | Goes back one screen; no-op at the root. |
popToRoot | () => void | Pops back to the root entry. |
stack | StackEntry[] | Current stack, root first. |