useTabActions
Hook for tab operations: open, close, refresh, etc.
typescript
import { useTabActions } from 'vue-stack-tabs'
const {
openTab,
closeTab,
closeAllTabs,
refreshTab,
refreshAllTabs,
activeTab,
moveTab,
updateTabTitle,
reset,
tabs,
setIFramePath,
getWrapper,
openInNewWindow
} = useTabActions()openTab
Opens a new tab. If a tab with the same id exists, it is activated and the last page is shown. With renew=true, the stack is cleared and the tab is reopened.
Call: openTab(tab: ITabData, renew?: boolean)
| Property | Type | Required | Description |
|---|---|---|---|
| id | string | No | Tab id; auto-generated if omitted. Same id = activate existing tab |
| title | string | Yes | Tab title |
| path | string | Yes | Route path or iframe URL |
| query | LocationQueryRaw | No | Query params |
| closable | boolean | No | Can close; default true |
| refreshable | boolean | No | Can refresh; default true |
| iframe | boolean | No | Open as iframe |
| iframeRefreshMode | 'postMessage' / 'reload' | No | iframe refresh mode; defaults to postMessage for same-origin URLs and reload for cross-origin ones |
Close
| Method | Description |
|---|---|
closeTab(id) | Close specific tab; returns the newly activated tab id (empty string if the id is unknown, the same id if the tab is not closable) |
closeAllTabs() | Close all tabs |
Close left/right/others are available via the right-click context menu.
Refresh
| Method | Description |
|---|---|
refreshTab(id) | Refresh current page of tab; ignored when the tab is not refreshable |
refreshAllTabs() | Refresh all refreshable tabs |
Other
| Method | Description |
|---|---|
activeTab(id, isRoute?) | Activate tab; pass isRoute=false to switch without navigating |
moveTab(id, targetIndex) | Move a tab to an index; the tab header also supports mouse drag-and-drop reordering |
updateTabTitle(id, title) | Update a tab title at runtime (also refreshes session and the active tab's __tab); returns false when the tab is missing |
reset() | Reset all |
tabs | Tab list (read-only) |
setIFramePath(path) | Set iframe path (internal) |
getWrapper({ tabId?, pageId? }) | Get a content DOM node. Omit parameters for legacy first-node behavior; use tabId or pageId when multiple tabs exist. |
openInNewWindow(id) | Open iframe tab in new window (fallback) |