Welcome to my blog. I assume that you are working in Office UI Fabric React components and you want to create a horizontal menu component in your React solution. Unfortunately, the normal Nav component in the Office UI Fabric doesn’t give you this option. And somehow you reached this post by searching for a solution to implement the horizontal menu. You are in the right place then. Let’s skip the talking and jump into the code. I hope you will like this article. Let’s start coding.
BackgroundAs I mentioned in the introduction, there is no option to make a horizontal menu if you are using UI Fabric Nav component. And I also ended up in spending some time playing with the Nav component to make it horizontal, but it wasn’t working as expected. And I found a different way to achieve the same, hereby I am sharing it as I couldn’t find such a solution on the internet.

Nav menu vertical
I believe that you have already created your solution and you are just trying to create a new Menu web part in the existing solution. If you haven’t created a solution, you can create one using the below command.
MenuWebPart.ts
Once you have created a new web part, you can see that there is a file called MenuWebPart.ts. This is the file we are going to edit first. You can see the content of that file below.
- import * as React from 'react';
- import * as ReactDom from 'react-dom';
- import {
- Version
- } from '@microsoft/sp-core-library';
- import {
- BaseClientSideWebPart,
- IPropertyPaneConfiguration,
- PropertyPaneTextField
- } from '@microsoft/sp-webpart-base';
- import * as strings from 'MenuWebPartStrings';
- import Menu from './components/Menu';
- import {
- IMenuProps
- } from './components/IMenuProps';
- export interface IMenuWebPartProps {
- description: string;
- }
- export default class MenuWebPart extends BaseClientSideWebPart < IMenuWebPartProps > {
- public render(): void {
- const element: React.ReactElement < IMenuProps > = React.createElement(Menu, {
- items: [{
- name: 'Home',
- url: '',
- key: 'key3'
- }, {
- name: 'Admin',
- key: 'key4'
- }]
- });
- ReactDom.render(element, this.domElement);
- }
- protected onDispose(): void {
- ReactDom.unmountComponentAtNode(this.domElement);
- }
- protected get dataVersion(): Version {
- return Version.parse('1.0');
- }
- protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
- return {
- pages: [{
- header: {
- description: strings.PropertyPaneDescription
- },
- groups: [{
- groupName: strings.BasicGroupName,
- groupFields: [
- PropertyPaneTextField('description', {
- label: strings.DescriptionFieldLabel
- })
- ]
- }]
- }]
- };
- }
- }


Join the conversation! Your thoughts help the community grow.