Removing objects from the SharePoint ribbon

If we need to remove a button from the SharePoint ribbon we can easily achieve this by creating a feature that defines a custom action. The feature should just refer to the element manifest, as follows.

<Feature xmlns=""
         Title="3 Guys On SharePoint Ribbon Customisations"
         Description="Makes changes to the ribbon to match the 3 Guys On SharePoint requirements"
    <ElementManifest Location="RibbonCustomisations\Elements.xml" />

The element manifest file then needs to define a custom action, referring to the location of the ribbon tab, group or control that you wish to remove.

	<CustomAction Id="3GuysCustomAction.RemoveUsageNewItem"
        		<CommandUIDefinition Location="Ribbon.ListItem.New"/>
        		<CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.VersionHistory"/>
        		<CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.ManagePermissions"/>
        		<CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.DeleteItem"/>
        		<CommandUIDefinition Location="Ribbon.ListForm.Edit.Actions.DeleteItem"/>

In this example we are removing several controls from various locations. The ‘New’ button is removed from the list; the ‘Version History’, ‘Manage Permissions’ and ‘Delete Item’ buttons are removed from the list item display form; and the ‘Delete Item’ is removed from the list item edit form. This is achieved by setting the Location attribute of the CommandUIDefinition element to the location(s) that we wish to remove. The default locations for the tabs, groups and controls can be found listed on MSDN.

Note that we can also remove groups (such as ‘Connect & Export’) or even whole tabs (for example the list tab) by specifying the locations of these rather than individual controls.

<CommandUIDefinition Location="Ribbon.List.Actions"/>
<CommandUIDefinition Location="Ribbon.List"/>

To prevent this customisation being deployed everywhere we restrict the removal to a single list type by setting the RegistrationId and RegistrationType attributes of the CustomAction element. In this instance we have a custom list definition with type 10004 so we set the RegistrationId =”10004″ and the RegistrationType=”List”. We also need to set the Location attribute of the CustomAction element to ‘CommandUI.Ribbon’, which tells SharePoint to apply the customisation everywhere for the specified RegistrationId. There are other options here:

CommandUI.Ribbon.ListView – Customization appears when the list view Web Part is present.
CommandUI.Ribbon.EditForm – Customization appears on the edit form.
CommandUI.Ribbon.NewForm – Customization appears on the new form.
CommandUI.Ribbon.DisplayForm – Customization appears on the display form.

Of course if required you can also manipulate the ribbon programmatically. Simply get a reference to the current SPRibbon object by passing in a reference to the current Page object.

            // Gets the current instance of the ribbon on the page.
            SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);

            // Make sure the ribbon exists
            if (ribbon != null)

Note the call to the TrimById method, which takes the location of the tab, group or control as a parameter – this is actually declared as a method on the Ribbon object in the Microsoft.Web.CommandUI assembly, which SPRibbon inherits from. To use this method successfully and build your project you will need to add a reference to the Microsoft.Web.CommandUI assembly, found in the SharePoint Root\ISAPI folder.

There are some ribbon locations that do not appear to be documented – or if they are  I can’t find them! I will add them to a list here and try and maintain it.

Upload Multiple Documents – Ribbon.Documents.New.AddDocument.Menu.Upload.UploadMultiple
New Folder - Ribbon.Documents.New.NewFolder


MSDN – Server Ribbon XML

MSDN – Default Server Ribbon Customization Locations

MSDN – SPRibbon class

MSDN – Ribbon.TrimById Method (String)

This entry was posted in SharePoint, SharePoint 2010 and tagged . Bookmark the permalink.

5 Responses to Removing objects from the SharePoint ribbon

  1. Goran says:

    How to undo this code? For exmaple how to undo


  2. Goran says:

    How to undo hiding groups?

    • ceej says:

      @Goran – if I understand the question correctly and assume you have removed a group from the ribbon using a feature then to undo it is simply a case of deactivating the appropriate feature. Your group should now appear on the ribbon again. HTH.

  3. Pingback: Remove New Folder button from the SharePoint ribbon | 3 Guys On SharePoint Blog

  4. Ven says:

    Can we remove the specific ribbon items based on some user role conditions? Say, for example, I have a scenario, wherein, I need to disable / remove Delete Item ribbon action (from ECB, View and Edit Form and other views also), even for a user with Contributor permission, but not disable / remove Delete Item permission for a user with Full Control permission. I would like to achieve this with a feature (and not through JS), since I want to have the flexibility to turn it on/off, as required. Also, I would like to know, how can we do it for all lists / libraries and specific lists / libraries.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>