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.
-
1
Disable Share in SharePoint Document Library
- 1.1 How to disable “Shared With” button in Document Library Settings Ribbon?
- 1.2 How to disable “Shared With” button in Files Tab Ribbon?
- 1.3 How to disable “Share” button in Files Tab Ribbon?
- 1.4 How to disable “Share” button in SharePoint Document Library Toolbar?
- 1.5 How to disable “Share” Callout Link in SharePoint Document Library?
- 1.6 How to disable “Share” Menu Item in SharePoint Document Library?
- 1.7 How to disable “Shared With” menu item in SharePoint Document Library?
In SharePoint Document library, there are main seven places for Share functionality as the following:
- “Shared With” button in Library Settings Ribbon,
- “Shared With” button in Files Tab Ribbon,
- “Share” button in Files Tab Ribbon,
- “Share” button in Document Library Toolbar,
- “Share” Callout link in Document Preview,
- “Share” Menu Item in Document Menu Item, and
- “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:
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:
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
- Open your SharePoint Site.
- Navigate to your Document Library that you would like to disable the “Shared With” button.
- Click on the Settings Gear icon > Edit the Page.
- Click “Add Web Part” > “Media and Content” > Add “Script Editor Web Part” > “Edit Snippet”.
- 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>
- From the above ribbon, click “Stop Editing Page”.
- Great, the “Shared With” button in the SharePoint Document Library Ribbon has been disabled successfully as shown below.
The second place, that you can find the “Shared With” button is the Files Tab ribbon as shown below:
To disable “Shared With” button in Files Tab Ribbon for a SharePoint Document Library, you should do the following:
Steps
- Open your SharePoint Site.
- Navigate to your document library that you would like to disable the “Shared With” button in the ribbon Files tab.
- Click on the Right Setting Gear icon > Edit the Page.
- Click “Add Web Part” > “Media and Content” > Add “Script Editor Web Part” > “Edit Snippet”.
- 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>
- From the above ribbon, click “Stop Editing Page”.
- Great, the “Shared With” button in the SharePoint Document Library Files Ribbon has been disabled successfully as shown below.
In the same Files Tab Ribbon, you will note that there is also a “Share” button as shown below:
In order to disable “Share” button in Files Tab Ribbon in SharePoint Document Library, you should do the following:
Steps
- Open your SharePoint Site.
- Navigate to your document library that you would like to disable the “Share” button in the ribbon Files tab.
- Click on the Right Setting Gear icon > Edit the Page.
- Click “Add Web Part” > “Media and Content” > Add “Script Editor Web Part” > “Edit Snippet”.
- 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>
- From the above ribbon, click “Stop Editing Page”.
- Great, the “Share” button in the SharePoint Document Library Files Ribbon has been disabled successfully as shown below.
Again, in the SharePoint Document Library Tool bar, you will note that there is a “Share” button as shown below:
To disable “Share” button in SharePoint Document Library Toolbar, you should do the following:
Steps
- Open your SharePoint Site.
- Navigate to your document library that you would like to disable the “Share” button in the toolbar.
- Click on the Right Setting Gear icon > Edit the Page.
- Click “Add Web Part” > “Media and Content” > Add “Script Editor Web Part” > “Edit Snippet”.
- 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>
- From the above ribbon, click “Stop Editing Page”.
- Great, the “Share” button in the SharePoint Document Library Toolbar has been disabled successfully as shown below.
Besides of all the above options, you can also find a “Share” Callout Link in document library as shown below:
To disable “Share” link in Document Callout in SharePoint Document Library, you should do the following:
Steps
- Open your SharePoint Site.
- Navigate to your document library that you would like to disable the “Share” link.
- Click on the Right Setting Gear icon > Edit the Page.
- Click “Add Web Part” > “Media and Content” > Add “Script Editor Web Part” > “Edit Snippet”.
- 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>
- From the above ribbon, click “Stop Editing Page”.
- Great, the “Share” Callout link in the SharePoint Document Library has been disabled successfully as shown below.
In the Document Callout, you can also find a Share menu item as shown below:
To disable “Share” Menu Item in SharePoint Document Library, you should do the following:
Steps
- Open your SharePoint Site.
- Navigate to your document library that you would like to disable the “Share” menu item.
- Click on the Right Setting Gear icon > Edit the Page.
- Click “Add Web Part” > “Media and Content” > Add “Script Editor Web Part” > “Edit Snippet”.
- 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>
- From the above ribbon, click “Stop Editing Page”.
- Great, the “Share” menu item in the SharePoint Document Library has been disabled successfully as shown below.
The Last “Share” option that I can find is the “Shared With” Child Menu Item below Advanced Menu item as shown below:
To disable “Shared With” child menu item in SharePoint Document Library, you should do the following:
Steps
- Open your SharePoint Site.
- Navigate to your document library that you would like to disable the “Share” menu item.
- Click on the Right Setting Gear icon > Edit the Page.
- Click “Add Web Part” > “Media and Content” > Add “Script Editor Web Part” > “Edit Snippet”.
- 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>
- From the above ribbon, click “Stop Editing Page”.
- Great, the “Shared With” menu item in the SharePoint Document Library has been disabled successfully as shown below.
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
- How to Disable Shared With button in SharePoint 2019 and SharePoint Online?
- Disable SharePoint Field Using JQuery
- Hide Save button from SharePoint Ribbon
- Have a question or need clarification, please post it at our QnA deBUG.to Community.