SharePoint / SharePoint/sp-dev-docs

ThemeProvider does not return V2 theme in SingleWebPartAppPage

Open
#10,362 4 comments 0 reactions 1 assignee View on GitHub

@Amey-MSFT is already working on this.

Since Aug 7, 2025.

area:spfx type:bug-confirmed
Dominant language
PowerShell
Stars
1.4k
Forks
1.1k
Avg merge
4d 12h
Merged PRs (30d)
12

Description

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Developer environment

Windows

What browser(s) / client(s) have you tested
  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)
Additional environment details
  • browser version v139
  • SPFx version v1.21.1
  • Node.js version v22.15.0
Describe the bug / error

Based on the documentation provided here:
https://learn.microsoft.com/en-us/javascript/api/sp-component-base/themeprovider?view=sp-typescript-latest#@microsoft-sp-component-base-themeprovider-trygetthemev2-member(1)

When this method is called on a sample article page, it returns proper theme, however when you try and call this method in SingleWebPartAppPage page layout, it returns undefined

Steps to reproduce
  1. Create Hello World webpart
  2. update supported hosts
  "supportedHosts": [
    "SharePointWebPart",
    "TeamsPersonalApp",
    "TeamsTab",
    "SharePointFullPage"
  ]
  1. consume theme provider
//onInit
   this.themeProvider = this.context.serviceScope.consume(ThemeProvider.serviceKey);
//onRender
console.log(this.themeProvider.tryGetThemeV2())
  1. Create article page, add webpart, observe that console.log returns data
  2. Create app page, observe that console.log returns undefined
Expected behavior

There should be no difference, and it should return data, however I might be wrong and missed this part in the docs.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.