SharePoint / SharePoint/sp-dev-docs
ThemeProvider does not return V2 theme in SingleWebPartAppPage
@Amey-MSFT is already working on this.
Since Aug 7, 2025.
- 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
- Create Hello World webpart
- update supported hosts
"supportedHosts": [
"SharePointWebPart",
"TeamsPersonalApp",
"TeamsTab",
"SharePointFullPage"
]
- consume theme provider
//onInit
this.themeProvider = this.context.serviceScope.consume(ThemeProvider.serviceKey);
//onRender
console.log(this.themeProvider.tryGetThemeV2())
- Create article page, add webpart, observe that
console.logreturns data - Create app page, observe that
console.logreturnsundefined
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.