To Do component in the Microsoft Graph Toolkit

The To Do component is used to enable the signed-in user to view, add, remove, complete, and/or edit tasks from Microsoft To Do using the To Do API in Microsoft Graph.


The following example displays the signed-in user's Microsoft To Do tasks using the mgt-todo component. You can use the code editor to see how properties change the behavior of the component.

Open this example in


You can use the following attributes and properties to customize the component.

Attribute Property Description
read-only readOnly A Boolean to set the task interface to be read only (no adding or removing tasks). Default is false.
hide-header hideHeader A Boolean to show or hide the header of the component. Default is false.
hide-options hideOptions A Boolean to show or hide the options in tasks. Default is false.
initial-id="folder_id" initialId A string ID to set the initially displayed folder to the provided ID.
target-id="folder_id" targetId A string ID to lock the tasks interface to the provided folder ID.
N/A isNewTaskVisible Determines whether new task view is visible at render.
N/A taskFilter An optional function to filter which tasks are shown to the user.

The following example shows only tasks from the folder with ID 12345 and does not allow the user to create new tasks.

<mgt-todo read-only initial-id="12345"></mgt-todo>

Custom CSS variables

The mgt-todo component defines the following CSS custom properties.

mgt-todo {






  --task-icon-alignment: flex-start (default) | center | flex-end

To learn more, see styling components.


The following events are fired from the component.

Event Detail Description
taskAdded The detail contains the respective task object Fires when a new task has been created.
taskChanged The detail contains the respective task object Fires when task metadata has been changed, such as marking completed.
taskClick The detail contains the respective task object Fires when the user clicks or taps on a task.
taskRemoved The detail contains the respective task object Fires when an existing task has been deleted.


The tasks component supports several templates that allow you to replace certain parts of the component. To specify a template, include a <template> element inside a component and set the data-type value to one of the following.

Data type Data context Description
task task: a to-do task object Replaces the whole default task.
task-details task: a to-do task object Template replaces the details section of the task.

The following example defines a template for the tasks component.

    <template data-type="task-details">
            Importance Level: {{task.importance}}

Microsoft Graph permissions

This control uses the following Microsoft Graph APIs and permissions.

Resource Permission
/me/todo/lists/ Tasks.ReadWrite
/me/todo/lists/{todoTaskListId}/tasks Tasks.ReadWrite
/me/todo/lists/{todoTaskListId}/tasks/{taskId} Tasks.ReadWrite


The tasks component uses the global authentication provider described in the authentication documentation.