How to: Hide the Ribbon in SharePoint 2010 (Rajeswari Mohandas)

In this post, you learn how to hide the ribbon in SharePoint 2010 by using JavaScript.

About the Ribbon in SharePoint 2010

The SharePoint 2010 ribbon provides a similar user experience as the Microsoft Office client products. The ribbon is a toolbar which appears on top of the page to provide the most commonly used tools, controls, and commands.

The ribbon hierarchy is organized as follows (see Figure 1 and Figure 2):

Contextual Tag Group - A contextual tab enables you to provide a set of user interface (UI) controls within a certain context. For example, when you select a table in a document, a set of tabs is displayed to work with the table. When the table is deselected, the contextual tabs are hidden. Contextual tabs with a similar context are organized in a contextual tab group so you can have more than one tab in a group.

Tabs – Tabs are used to organize groups of related controls. For example, an Insert tab displays controls that enable you to insert various objects into a document such as files, tables, images, and so forth.

Groups – Groups are used to organize related controls such as the font group, styles group, document views group, and so forth.

Controls – Buttons, dropdown controls, radio buttons, and other controls that enable you to perform a singular task from the ribbon.

The ribbon can have multiple tabs, tabs can have multiple groups, and group can have multiple controls.

Figure 1. Ribbon tabs and groups

Figure 2. Ribbon contextual tab group and controls

Hiding the Ribbon in SharePoint 2010

There are multiple ways to hide the ribbon in SharePoint 2010. For example:

When publishing a website template (which you should use for public websites), there is a Show/Hide ribbon option under the Site Actions drop-down menu.

By using the Security Trimmer control. The Security Trimmer control can be place around the ribbon in Master page to conditionally hide it based on user permissions. The following example shows that a user without manage permissions will not be able to see the ribbon. The PermissionString attribute value can be changed based on the requirement.

By using custom code. JavaScript can be used to show or hide the ribbon in SharePoint 2010.

Creating JavaScript to Hide the Ribbon

In this section, you create a file that contains JavaScript code to show or hide the ribbon while loading a website and webpage. You then create an empty SharePoint 2010 project in Microsoft Visual Studio 2010 and then add the JavaScript file to it. Next, you reference the JavaScript file in the Master page. Finally, you deploy and test the solution.

To create the JavaScript file

Open Notepad.

Add the following JavaScript code to the file and then save it as custom.js.