For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
Shadcn Labs/

Stack Navigator

Push and pop screens like an iOS navigation stack. Screens slide in the direction you travel and the title glides into the back button.

Messages

Installation

$ pnpm dlx shadcn@latest add @transition-kit/stack-navigator

Usage

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

PropTypeDefaultDescription
initialScreenstringfirst StackScreenUncontrolled root screen.
initialParamsRecord<string, unknown>{}Params for the uncontrolled root entry.
stackStackEntry[]-Controlled stack, root first.
onStackChange(stack: StackEntry[]) => void-Called with the next stack after each navigation.

StackScreen

PropTypeDefaultDescription
namestring-Unique screen name referenced by initialScreen and push.
render(params) => ReactNode-Screen content rendered for the entry's params.
titleReactNode | (params) => ReactNode-Header title; morphs into the back button when a screen is pushed on top.
actionsReactNode | (params) => ReactNode-Trailing header content, e.g. an icon button.

useStack

ReturnTypeDescription
push(screen: string, params?: Record<string, unknown>) => voidPushes a new entry onto the stack.
pop() => voidGoes back one screen; no-op at the root.
popToRoot() => voidPops back to the root entry.
stackStackEntry[]Current stack, root first.