Tag.TagEntity

Tag

Tags use text to label card and sticky note items.
Tags help classify and categorize information to make it easier to retrieve.

After creating a tag on a board, you can attach it to the following items:

â„šī¸ Note:

  • title is required.
  • If no color is specified, it defaults to red.
  • Card and sticky note items can have up to 8 tags.
  • Boards can have up to 100 tags in total.

Example:

// Create a tag
const todo = await miro.board.createTag({
  title: 'todo or not todo, that is the question',
  color: 'yellow',
});

// Create a sticky note and attach the tag to it
const stickyNote = await miro.board.createStickyNote({
  content: "sticky note with tag: 'todo'",
  tagIds: [todo.id],
});

// Get the ID of the tag attached to the item
console.log(stickyNote.tagIds); // => ['3074457345627244742']

// Output the created item to the developer console
console.log(todo);

Tag attached to a sticky note:

A tag attached to a sticky note.
Figure 1. A tag attached to a sticky note.

Table of contents

Properties

Methods

Properties

type

â€ĸ Readonly type: "tag"


id

â€ĸ Readonly id: string


title

â€ĸ title: string = ''

The text to label card and sticky note items with.

The title property has the following characteristics:

  • Alphanumeric, space, special characters (non-alphanumeric characters; for example: ! @ # $ % ˆ & *), emojis
  • Case-sensitive
  • Must be unique
  • Maximum length: 120 characters, spaces included.

color

â€ĸ color: TagColor

A literal value that assigns a color to the background of the tag. Possible values:

Default: red

Methods

sync

▸ sync(): Promise<void>

sync propagates to the board any changes to item and tag properties.
After updating the properties of an item or a tag, sync it with the board to:

  • Propagate to the board the changes applied to the item or to the tag.
  • Make the changes visible on the board.

All board items and tags require sync to make any changes to their properties visible on the board.

For more information and examples, see Update and sync item properties.

Example:
(The code example updates a tag using sync.
The same mechanism applies to and works in the same way for all supported board items.)

// Create a tag.
const todo = await miro.board.createTag({
  title: 'todo',
  color: 'yellow',
});

// Create a sticky note and attach the tag to it.
const stickyNote = await miro.board.createStickyNote({
  content: 'sticky note with tag: "todo"',
  tagIds: [todo.id],
});
console.log(stickyNote.tagIds); // => ['3074457345627244742']

// Update the tag properties: title and color.
todo.title = "won't fix";
todo.color = 'green';

// Call 'sync' to make the changed tag properties visible on the board.
await todo.sync();

// Output the updated tag to the developer console.
console.log(todo);

Returns

Promise<void>


What's next

Go to board to explore the methods to perform CRUD operations on board items, to set and get metadata, and to retrieve user information.