You built this beautiful new web part and it looks great in SharePoint. You click the Sync to Teams button to try it out there only to find that your icons are missing. You think it’s your issue because maybe your styles are wrong. It’s not. I tried all sorts of things, but it turns out it was a reported issue. It turns out Microsoft Teams doesn’t initialize the icons for you when you are in a Microsoft Teams context.
Luckily it’s easy to fix. In your web part’s class, you’ll need to add the following import.
import { initializeIcons } from 'office-ui-fabric-react';
If you’ve already made the transition to Fluent UI, you’ll replace office-ui-fabric-react with @fluentui/react.
Now make a call to initializeIcons in your onInit method. I added a check to see if the context for the web part was in Microsoft Teams first so that it won’t call it unnecessarily when hosted in SharePoint.
if (this.context.sdks.microsoftTeams)
initializeIcons();
That’s it. Once you do that, your icons will return and look great inside your SPFx web part in Microsoft Teams.