Composables
useTray
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
| Property | Type | Description |
|---|---|---|
view | Ref<string> | Id of the currently-visible view. |
visible | Ref<boolean> | Whether the tray is open. |
canGoBack | ComputedRef<boolean> | true when the history stack has a frame to pop. |
open | (view?: string) => void | Open the tray, optionally jumping to view (defaults to defaultView). |
close | () => void | Close the tray. |
setView | (id: string) => void | Navigate to id, pushing the current view onto the back stack. |
goBack | () => void | Pop the back stack and return to the previous view. No-op if empty. |