Composables

useTray

Source
Imperative navigation for an ancestor VyTray from anywhere inside it.

Overview

useTray (from @vyui/kit) reads the enclosing VyTray's navigation controller — handy for custom triggers or deep view bodies that shouldn't thread callbacks through props.

import { useTray } from '@vyui/kit'

const tray = useTray()
tray.setView('confirm') // navigate + push history
tray.goBack() // pop back

Throws if called outside a VyTray.

Returns

PropertyTypeDescription
viewRef<string>Id of the currently-visible view.
visibleRef<boolean>Whether the tray is open.
canGoBackComputedRef<boolean>true when the history stack has a frame to pop.
open(view?: string) => voidOpen the tray, optionally jumping to view (defaults to defaultView).
close() => voidClose the tray.
setView(id: string) => voidNavigate to id, pushing the current view onto the back stack.
goBack() => voidPop the back stack and return to the previous view. No-op if empty.