How to disable Share in SharePoint Document Library?

disable Share and shared with in SharePoint Document Library

In the previous post, Disable “Shared With” from Ribbon in SharePoint List, we have learned how to hide or disable the Shared With button from SharePoint Ribbon. Also, we will show how to remove or disable the Share menu item for SharePoint List.

In this post, we will also try to provide a simple CSS solution to hide or disable Share in SharePoint Document Library in SharePoint Online and SharePoint 2019 / 2016 / 2013.


Disable Share in SharePoint Document Library

In SharePoint Document library, there are main seven places for Share functionality as the following:

  1. “Shared With” button in Library Settings Ribbon,
  2. “Shared With” button in Files Tab Ribbon,
  3. “Share” button in Files Tab Ribbon,
  4. “Share” button in Document Library Toolbar,
  5. “Share” Callout link in Document Preview,
  6. “Share” Menu Item in Document Menu Item, and
  7. “Shared With” Child Menu Item in Advanced Menu item.

So, in the post, we will show how to hide and disable Share in SharePoint Document Library for all users as shown below:

disable share in SharePoint Document Library
Disable Share in SharePoint Document Library

How to disable “Shared With” button in Document Library Settings Ribbon?

In SharePoint Online Classic Experience as well as SharePoint Server 2019 / 2016, there is a “Shared With” button in the above ribbon of SharePoint Document Library to can see who has access to this list as shown below:

Shared With button in SharePoint Library Settings Ribbon
Shared With button in SharePoint Library Settings Ribbon

The simple solution to disable the Shared With button in SharePoint Library Settings Ribbon is using a simple CSS code in a Script Editor web part at the AllItems page of the SharePoint Document Library by following the below steps:

Steps

  1. Open your SharePoint Site.
  2. Navigate to your Document Library that you would like to disable the “Shared With” button.
  3. Click on the Settings Gear icon > Edit the Page.
edit page in SharePoint Online
  1. Click “Add Web Part” > “Media and Content” > Add “Script Editor Web Part” > “Edit Snippet”.
Add Script Editor Web Part
  1. Copy the below CSS, and paste it to your script editor web part.
//disable Shared With button from the SharePoint Document Library Ribbon
<style>
#Ribbon\.Library\.Settings\.LibraryPermissions-Large,
#Ribbon\.Library\.Settings\.LibraryPermissions-Medium,
#Ribbon\.Library\.Settings\.LibraryPermissions-Small {
	pointer-events: none;
	opacity: 0.6;
}
</style>
  1. From the above ribbon, click “Stop Editing Page”.
  2. Great, the “Shared With” button in the SharePoint Document Library Ribbon has been disabled successfully as shown below.
disable Shared With button in SharePoint Library Settings Ribbon

How to disable “Shared With” button in Files Tab Ribbon?

The second place, that you can find the “Shared With” button is the Files Tab ribbon as shown below:

How to disable Share in SharePoint Document Library?

To disable “Shared With” button in Files Tab Ribbon for a SharePoint Document Library, you should do the following:

Steps

  1. Open your SharePoint Site.
  2. Navigate to your document library that you would like to disable the “Shared With” button in the ribbon Files tab.
  3. Click on the Right Setting Gear icon > Edit the Page.
  4. Click “Add Web Part” > “Media and Content” > Add “Script Editor Web Part” > “Edit Snippet”.
  5. Copy the below CSS, and paste it to your script editor.
//disable Shared With button from SharePoint Document Library Files Ribbon
<style>
#Ribbon\.Documents\.Manage\.ManagePermissions-Medium {
	pointer-events: none;
	opacity: 0.6;
}
</style>
  1. From the above ribbon, click “Stop Editing Page”.
  2. Great, the “Shared With” button in the SharePoint Document Library Files Ribbon has been disabled successfully as shown below.
disable Shared with button in files document library ribbon

How to disable “Share” button in Files Tab Ribbon?

In the same Files Tab Ribbon, you will note that there is also a “Share” button as shown below:

Share button in files document library ribbon

In order to disable “Share” button in Files Tab Ribbon in SharePoint Document Library, you should do the following:

Steps

  1. Open your SharePoint Site.
  2. Navigate to your document library that you would like to disable the “Share” button in the ribbon Files tab.
  3. Click on the Right Setting Gear icon > Edit the Page.
  4. Click “Add Web Part” > “Media and Content” > Add “Script Editor Web Part” > “Edit Snippet”.
  5. Copy the below CSS, and paste it to your script editor.
//disable Share button from SharePoint Document Library Files Ribbon
<style>
#Ribbon\.Documents\.Share\.ShareItem-Large {
	pointer-events: none;
	opacity: 0.6;
}
</style>
  1. From the above ribbon, click “Stop Editing Page”.
  2. Great, the “Share” button in the SharePoint Document Library Files Ribbon has been disabled successfully as shown below.
disable Share button in files document library ribbon

How to disable “Share” button in SharePoint Document Library Toolbar?

Again, in the SharePoint Document Library Tool bar, you will note that there is a “Share” button as shown below:

Share button in document library toolbar

To disable “Share” button in SharePoint Document Library Toolbar, you should do the following:

Steps

  1. Open your SharePoint Site.
  2. Navigate to your document library that you would like to disable the “Share” button in the toolbar.
  3. Click on the Right Setting Gear icon > Edit the Page.
  4. Click “Add Web Part” > “Media and Content” > Add “Script Editor Web Part” > “Edit Snippet”.
  5. Copy the below CSS, and paste it to your script editor.
//disable Share button in SharePoint Document Library Toolbar
<style>
.js-listview-qcbShareButton {
	pointer-events: none;
	opacity: 0.6;
}
</style>
  1. From the above ribbon, click “Stop Editing Page”.
  2. Great, the “Share” button in the SharePoint Document Library Toolbar has been disabled successfully as shown below.
disable Share button in document library toolbar

How to disable “Share” Callout Link in SharePoint Document Library?

Besides of all the above options, you can also find a “Share” Callout Link in document library as shown below:

Share callout link in document library

To disable “Share” link in Document Callout in SharePoint Document Library, you should do the following:

Steps

  1. Open your SharePoint Site.
  2. Navigate to your document library that you would like to disable the “Share” link.
  3. Click on the Right Setting Gear icon > Edit the Page.
  4. Click “Add Web Part” > “Media and Content” > Add “Script Editor Web Part” > “Edit Snippet”.
  5. Copy the below CSS, and paste it to your script editor.
//disable Share link in Document Preview callout
<style>
.ms-calloutLink[title="Share file or folder with other person or group"] {
	pointer-events: none;
	opacity: 0.6;
}
</style>
  1. From the above ribbon, click “Stop Editing Page”.
  2. Great, the “Share” Callout link in the SharePoint Document Library has been disabled successfully as shown below.
disable Share callout link in document library

How to disable “Share” Menu Item in SharePoint Document Library?

In the Document Callout, you can also find a Share menu item as shown below:

share menu item in sharepoint document library

To disable “Share” Menu Item in SharePoint Document Library, you should do the following:

Steps

  1. Open your SharePoint Site.
  2. Navigate to your document library that you would like to disable the “Share” menu item.
  3. Click on the Right Setting Gear icon > Edit the Page.
  4. Click “Add Web Part” > “Media and Content” > Add “Script Editor Web Part” > “Edit Snippet”.
  5. Copy the below CSS, and paste it to your script editor.
//disable Share menu item in SharePoint Document Library
<style>
.ms-contextmenu-link[title="Shared With"] {
	pointer-events: none;
	opacity: 0.6;
}
</style>
  1. From the above ribbon, click “Stop Editing Page”.
  2. Great, the “Share” menu item in the SharePoint Document Library has been disabled successfully as shown below.
disable share menu item in sharepoint document library

How to disable “Shared With” menu item in SharePoint Document Library?

The Last “Share” option that I can find is the “Shared With” Child Menu Item below Advanced Menu item as shown below:

shared with menu item in sharepoint document library

To disable “Shared With” child menu item in SharePoint Document Library, you should do the following:

Steps

  1. Open your SharePoint Site.
  2. Navigate to your document library that you would like to disable the “Share” menu item.
  3. Click on the Right Setting Gear icon > Edit the Page.
  4. Click “Add Web Part” > “Media and Content” > Add “Script Editor Web Part” > “Edit Snippet”.
  5. Copy the below CSS, and paste it to your script editor.
//disable Share menu item in SharePoint Document Library
<style>
.ms-contextmenu-link[title="Shared With"] {
	pointer-events: none;
	opacity: 0.6;
}
</style>
  1. From the above ribbon, click “Stop Editing Page”.
  2. Great, the “Shared With” menu item in the SharePoint Document Library has been disabled successfully as shown below.
disable shared with menu item in sharepoint document library

Download

Download the full CSS code from GitHub at “Hide/Disable Share in SharePoint Document Library“, Please don’t forget to follow me to get the latest update.

Conclusion

In conclusion, we have provided a simple CSS solution to disable Share, and Shared with options in SharePoint Document Library Ribbon, Toolbar, and Menu Item.

Applies To
  • SharePoint Online Classic Experience.
  • SharePoint 2019.
  • SharePoint 2016.
  • SharePoint 2013.

This demo has been tested in SharePoint Online Classic Experience, if it is not worked for specific SharePoint version, just use F12 developer tool to get the corresponding ID of the item and replace it with the same provided CSS in this article

See Also

Leave a Reply