Skip to content

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)

PropertyTypeRequiredDescription
idstringNoTab id; auto-generated if omitted. Same id = activate existing tab
titlestringYesTab title
pathstringYesRoute path or iframe URL
queryLocationQueryRawNoQuery params
closablebooleanNoCan close; default true
refreshablebooleanNoCan refresh; default true
iframebooleanNoOpen as iframe
iframeRefreshMode'postMessage' / 'reload'Noiframe refresh mode; defaults to postMessage for same-origin URLs and reload for cross-origin ones

Close ​

MethodDescription
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 ​

MethodDescription
refreshTab(id)Refresh current page of tab; ignored when the tab is not refreshable
refreshAllTabs()Refresh all refreshable tabs

Other ​

MethodDescription
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
tabsTab 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)

Released under the Apache License.