Skip to main content

SidebarTabs

Import :

const SidebarTabs = brackets.getModule("view/SidebarTabs")

view/SidebarTabs

SidebarTabs manages multiple tab panes within the sidebar. It inserts a #navTabBar element after #mainNavBar and provides an API for registering tabs, associating DOM content with tabs, and switching between them.

Existing sidebar children that are not explicitly associated with a tab via addToTab are treated as belonging to the default "Files" tab. This means extensions that add DOM nodes to the sidebar will continue to work without any code changes.

Tab switching works purely by toggling the .sidebar-tab-hidden CSS class (display: none !important). No DOM reparenting or detaching occurs, so cached jQuery/DOM references held by extensions remain valid.

view/SidebarTabs.SIDEBAR_TAB_FILES : string

The built-in Files tab id.

Kind: inner constant of view/SidebarTabs

view/SidebarTabs.AI_TAB_GOOD_WIDTH : number

Preferred sidebar width (px) when a non-files tab (e.g. AI) is first activated. Applied once if the current width is narrower.

Kind: inner constant of view/SidebarTabs

view/SidebarTabs.PREF_AI_WIDTH_SET_INITIAL

Preference key used to track whether the initial width bump has been applied.

Kind: inner constant of view/SidebarTabs

view/SidebarTabs.EVENT_TAB_ADDED : string

Fired when a new tab is registered via addTab.

Kind: inner constant of view/SidebarTabs

view/SidebarTabs.EVENT_TAB_REMOVED : string

Fired when a tab is removed via removeTab.

Kind: inner constant of view/SidebarTabs

view/SidebarTabs.EVENT_TAB_CHANGED : string

Fired when the active tab changes via setActiveTab.

Kind: inner constant of view/SidebarTabs

view/SidebarTabs.addTab(id, label, iconClass, [options])

Register a new sidebar tab.

Kind: inner method of view/SidebarTabs

ParamTypeDefaultDescription
idstringUnique tab identifier
labelstringDisplay text shown in the tab bar
iconClassstringFontAwesome (or other) icon class string
[options]Object
[options.priority]number100Lower values appear further left

view/SidebarTabs.addToTab(tabId, $content)

Associate a DOM node (or jQuery element) with a tab. If the node is not already a child of #sidebar, it is appended. If the tab is not the currently active tab, the node is immediately hidden.

Kind: inner method of view/SidebarTabs

ParamTypeDescription
tabIdstringThe tab to associate with
$contentjQuery | ElementDOM node or jQuery wrapper

view/SidebarTabs.removeFromTab(tabId, $content)

Remove a DOM node's association with a tab. If the node was appended by addToTab (was not originally in the sidebar) and is no longer associated with any tab, it is also removed from the DOM.

Kind: inner method of view/SidebarTabs

ParamTypeDescription
tabIdstringThe tab to disassociate from
$contentjQuery | ElementDOM node or jQuery wrapper

view/SidebarTabs.removeTab(id) ⇒ boolean

Remove a tab entirely. Only succeeds if all content has been removed via removeFromTab first. Returns false if content still exists.

Kind: inner method of view/SidebarTabs
Returns: boolean - true if removed, false if content still associated

ParamTypeDescription
idstringThe tab id to remove

view/SidebarTabs.setActiveTab(id)

Switch the active sidebar tab. Shows nodes associated with the target tab, hides all others.

Kind: inner method of view/SidebarTabs

ParamTypeDescription
idstringThe tab id to activate

view/SidebarTabs.getActiveTab() ⇒ string

Get the currently active tab id.

Kind: inner method of view/SidebarTabs

view/SidebarTabs.TabDescriptor ⇒ Array.<TabDescriptor>

Get an array of all registered tab descriptors.

Kind: inner typedef of view/SidebarTabs
Properties

NameTypeDescription
idstringUnique tab identifier
labelstringDisplay text shown in the tab bar
iconClassstringIcon class string
prioritynumberSort priority (lower = further left)