🚦 Rate limit: Level 1
πŸ”’ Requires scope: boards:write

Groups the given items in the board, including unsupported items.

ℹ️ Note:

  • Previously grouped items cannot be grouped again, this will cause an error. You can use the groupId property in the item to check whether it's already assigned to a group.
  • Groups can only be created with at least two items.
  • Locked elements cannot be grouped.
  • Mindmaps and tags are not supported in groups.
  • Groups do not support metadata as other board items.
  • If a group is added to a frame, all the grouped items will also be attached to that frame. The group must fit within the frame dimensions to be added.

Example of adding grouped items to a frame:

const shape = await miro.board.createShape()
const card = await miro.board.createCard()
const text = await miro.board.createText()

const boardItems = [shape, card, text]

const group = await miro.board.group({ items: boardItems })
const frame = await miro.board.createFrame();

// shape, card and text will also be added to the frame
// you can check their parentId property after this operation
await frame.add(group)

Example:

const shape = await miro.board.createShape()
const card = await miro.board.createCard()
const text = await miro.board.createText()

const boardItems = [shape, card, text]

const group = await miro.board.group({items: boardItems})

// get all groups
const allGroups = await miro.board.get({ type: 'group' });

// get a specific group by ID
const groupById = await miro.board.getById(group.id);

// get all selected groups
const selectedItems = await miro.board.getSelection();
const selectedGroups = selectedItems.filter(item => item.type === 'group');

Methods


getItems(...)

() => Promise<Array<GroupableItem>>
🚦 Rate limit: Level 1
πŸ”’ Requires scope: boards:read

Returns all the items assigned to the group.

const shape = await miro.board.createShape()
const card = await miro.board.createCard()
const text = await miro.board.createText()

const boardItems = [shape, card, text]

const group = await miro.board.group({ items: boardItems })

const groupedItems = await group.getItems();
// Grouped items should be the same as items

ungroup(...)

() => Promise<Array<GroupableItem>>
🚦 Rate limit: Level 1
πŸ”’ Requires scope: boards:write

Ungroups and returns all currently grouped items.
Once ungrouped, the group object is invalidated. Each item will have its own groupId property equal to undefined.
To group items again, use the method miro.board.group.

const shape = await miro.board.createShape()
const card = await miro.board.createCard()
const text = await miro.board.createText()

const boardItems = [shape, card, text]

const group = await miro.board.group({ items: boardItems })
const releasedItems = await group.ungroup();

All properties

PropertyType
id
readonly string
itemsIds
readonly Array<string>
type
readonly 'group'
getItems(...)
() => Promise<Array<GroupableItem>>
sync(...)
() => Promise<void>
ungroup(...)
() => Promise<Array<GroupableItem>>