I'm just getting in to customizing the modern interface in SharePoint Online for a new project. If this has been answered repeatedly before, my Google-fu may be off.

We've disabled sharing on a site, but the Share button still shows up when a file is selected - granted, the only option available is "People with existing access" but this is confusing people. So we'd like to hide this button all together.

enter image description here

It sounds like it was possible to do this in the classic interface, but I haven't found anything about doing it in the modern interface.

I've tried using CSS, which the modern interface doesn't support. I've also started looking into PnP Custom Actions, but I haven't found anything specific about hiding a built-in button with that.

Any pointers, thoughts, links to articles that I've clearly missed ... all welcome.

1 Answer 1


You could create SPFx Application Customizer to inject custom CSS to hide element.

Check below threads for demos.



  • A ready-made solution in github github.com/pnp/sp-dev-fx-extensions/tree/main/samples/…. The hide/unhide is configurable through a custom list without deploying a new code.
    – san
    Commented Jun 25, 2021 at 12:39
  • 1
    The only issue with this approach is that, there is fluctuation while loading the page. i.e these options are first shown for a sec and then hidden. Is there any approach to overcome this? Commented Jun 28, 2021 at 15:20
  • No. There is no easy way to overcome it. Hope Microsoft would release a proper API to play around with these buttons.
    – san
    Commented Jun 29, 2021 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.