Register a screen in a Router. Use it in an app with component routes, rather than file routes.

Register a parameterized detail screen

tsx
import { Link, Route, Router, Text, VStack, routes, type RouteTo, type ScreenProps } from 'kuito';

declare module 'kuito' {
  interface Routes {
    index: RouteTo;
    show: RouteTo<{ id: number }>;
    settings: RouteTo;
  }
}

function Home() {
  return (
    <VStack padding={16}>
      <Link to={routes.show({ id: 42 })}>
        <Text>Show 42</Text>
      </Link>
    </VStack>
  );
}

function Show({ id }: ScreenProps<{ id: number }>) {
  return <Text padding={16}>{`Show ${id}`}</Text>;
}

function Settings() {
  return <Text padding={16}>Settings</Text>;
}

export default function App() {
  return (
    <Router>
      <Route name="index" path="/" screen={Home} title="Home" />
      <Route
        name="show"
        path="/show/:id"
        params={{ id: Number }}
        screen={Show}
        title={({ id }) => `Show ${id}`}
      />
      <Route name="settings" path="/settings" screen={Settings} presentation="sheet" />
    </Router>
  );
}

Behavior

name identifies the destination, path matches links, and screen renders it. Declare parameter types with params. Route is navigation configuration rather than a visible layout container.

Continue

Read Navigation for a complete workflow. See the complete prop reference for types and documented defaults.

Referência

Assinaturas

ts
<P extends object, R>(_props: RouteProps<P, R>): KuitoNode

Parâmetros de tipo

NomeRestriçãoPredefinição
Pobject—
R——

Parâmetros

NomeTipoObrigatórioDescrição
_propsRouteProps<P, R>Sim—

Devolve

KuitoNode

Props: RouteProps<P, R>

Props (incluindo props herdadas) 10

NomeTipoObrigatórioDescrição
namestringSimIts key in routes.
pathstringSimSegments, :name params and a final *name: what a deep link's path matches.
params{ [K in keyof P]?: ParamType; }NãoHow a link's text parses into each param; a path param left out is a string.
screenComponent<ScreenProps<P, R>>Sim—
titlestring | ((params: P) => string)NãoThe native header's title.
presentationPresentationNão—
backgroundColorstringNãoThe screen's color, under the bars too; the platform's background without.
snapPointsreadonly SnapPoint[]NãoA sheet route's heights, as <Sheet snapPoints> takes them; the platform's default without.
headerfalse | ScreenHeader | ((params: P) => false | ScreenHeader)NãoThe native header: false hides it; its items, large title and search otherwise (docs/navigation.md#headers).
systemBarsSystemBarsPropsNãoThe system bars while this screen is focused, as a <SystemBars>'s props (docs/system-ui.md).
screen — assinaturas de método

Assinaturas

ts
(props: ScreenProps<P, R>): KuitoNode

Parâmetros

NomeTipoObrigatórioDescrição
propsScreenProps<P, R>Sim—

Devolve

KuitoNode

systemBars — campos aninhados

systemBars campos

NomeTipoObrigatórioDescrição
statusBarStatusBarOptionsNãoThe status bar's content color, visibility and, on Android, color.
backgroundColorstringNãoThe root view's color, seen behind the app's views.
navigationBarColorstringNãoAndroid: drawn behind the navigation bar.
navigationBarButtonStyleNavigationBarButtonStyleNãoAndroid: light buttons for a dark navigation bar, dark buttons for a light one.
navigationBarHiddenbooleanNãoAndroid: hides the navigation bar; a swipe from the edge shows it for a moment.
immersivebooleanNãoFull screen: hides the status bar, the navigation bar and the home indicator, and on iOS edge swipes reach the app first. The entry's own props, and later entries, win over what it hides.
homeIndicatorAutoHiddenbooleanNãoiOS: lets the home indicator fade out while the user doesn't touch the screen.
statusBar — campos aninhados

statusBar campos

NomeTipoObrigatórioDescrição
contentStatusBarContentNãoThe color of the status bar's text and icons.
hiddenbooleanNão—
animatedbooleanNãoWhether changes to content, hidden and backgroundColor animate.
transitionStatusBarTransitionNãoiOS: how showing and hiding animates, when animated.
backgroundColorstringNãoAndroid: drawn behind the status bar; a hex color.
translucentbooleanNãoAndroid: false lays the app out below the status bar instead of under it.
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.