Back to Insights

Creating site level ribbon tabs in SharePoint 2010 and hiding the ribbon on demand

In this article I will assume you have already read and understand how to provision the ribbon on a page. If not, refer to this article.

Here we'll focus on what you need to do to create a new ribbon tab at the site level, which seems to be a hot topic these days. You need to perform two things:

  1. In your SharePoint 2010 project, add a new empty element item and define the following XML:
     <[default] "":Elements xmlns=""""> <[default] "":CustomAction id=""MyProject.RibbonButton"" Location=""CommandUI.Ribbon""> <[default] "":CommandUIExtension> <[default] "":CommandUIDefinitions> <[default] "":CommandUIDefinition Location=""Ribbon.Tabs._children""> <[default] "":Tab id=""MyProject.Ribbon.HelloTab"" title=""Custom"> <[default] "":Scaling id=""Ribbon.Read.Scaling"">  <[default] "":Groups id=""Ribbon.Read.Groups"">        

    Feel free to add any controls to your group as needed.

  2. Enable this tab on each page of your site. This step is very specific to site-wide ribbon tabs. To achieve the goal you can either create a user control that will sit in your master page (header or footer) or delegate control and it will be called on each page. The code that you will run in this user control will look something like this:

    You can use this to verify that the tab was already enabled:


    Keep in mind that this needs to run each time the page is loaded and the tab will show up along with all of the contextual tabs.

    In some cases you may want to disable the whole ribbon on your page. How do you do that? You need to follow Step 2 and create a user control or a delegate control, but this time it will call the following code:

    CommandUIVisible = false;

Good luck!