chrome.tabGroups
Description
Use the chrome.tabGroups API to interact with the browser's tab grouping system. You can use this API to modify and rearrange tab groups in the browser. To group and ungroup tabs, or to query what tabs are in groups, use the chrome.tabs API.
Permissions
tabGroups
Availability
Types
Enum
"grey"
"blue"
"red"
"yellow"
"green"
"pink"
"purple"
"cyan"
"orange"
TabGroup
Properties
-
Whether the group is collapsed. A collapsed group is one whose tabs are hidden.
-
The group's color.
-
The ID of the group. Group IDs are unique within a browser session.
-
Whether the group is shared.
-
The title of the group.
-
The ID of the window that contains the group.
Properties
TAB_GROUP_ID_NONE
An ID that represents the absence of a group.
Methods
get()
chrome.tabGroups.get(
groupId: number,
): Promise<TabGroup>
Retrieves details about the specified group.
Parameters
Returns
move()
chrome.tabGroups.move(
groupId: number,
moveProperties: object,
): Promise<TabGroup | undefined>
Moves the group and all its tabs within its window, or to a new window.
Parameters
-
The ID of the group to move.
-
-
The position to move the group to. Use
-1to place the group at the end of the window. -
The window to move the group to. Defaults to the window the group is currently in. Note that groups can only be moved to and from windows with
windows.WindowTypetype"normal".
-
Returns
-
Promise<TabGroup | undefined>
query()
chrome.tabGroups.query(
queryInfo: object,
): Promise<TabGroup[]>
Gets all groups that have the specified properties, or all groups if no properties are specified.
Parameters
-
-
collapsed
boolean optional
Whether the groups are collapsed.
-
The color of the groups.
-
Whether the group is shared.
-
Match group titles against a pattern.
-
The ID of the parent window, or
windows.WINDOW_ID_CURRENTfor the current window.
-
Returns
update()
chrome.tabGroups.update(
groupId: number,
updateProperties: object,
): Promise<TabGroup | undefined>
Modifies the properties of a group. Properties that are not specified in updateProperties are not modified.
Parameters
-
The ID of the group to modify.
-
-
collapsed
boolean optional
Whether the group should be collapsed.
-
The color of the group.
-
The title of the group.
-
Returns
-
Promise<TabGroup | undefined>
Events
onCreated
chrome.tabGroups.onCreated.addListener(
callback: function,
)
Fired when a group is created.
Parameters
-
The
callbackparameter looks like:(group: TabGroup) => void
onMoved
chrome.tabGroups.onMoved.addListener(
callback: function,
)
Fired when a group is moved within a window. Move events are still fired for the individual tabs within the group, as well as for the group itself. This event is not fired when a group is moved between windows; instead, it will be removed from one window and created in another.
Parameters
-
The
callbackparameter looks like:(group: TabGroup) => void
onRemoved
chrome.tabGroups.onRemoved.addListener(
callback: function,
)
Fired when a group is closed, either directly by the user or automatically because it contained zero tabs.
Parameters
-
The
callbackparameter looks like:(group: TabGroup) => void
onUpdated
chrome.tabGroups.onUpdated.addListener(
callback: function,
)
Fired when a group is updated.
Parameters
-
The
callbackparameter looks like:(group: TabGroup) => void