content logo

React Headers:

Simple Navbar Menu using React

Using a menu on all websites is one of the most important things you have to do if you are an administrator of a page. So, we have presented a Simple Navbar Menu using React on this post to help you on this way. To make your websites more attractive, this React Header Menu can be a great idea. You are able to change the appearance of your website with the help of this React Navbar Menu Code. Additionally, this code allows you to mention much information in a small physical space. So, you can reduce the occupied space of your website.

At the bottom of the page, you can see the preview of this Selection Menu Hover Effect. In this preview, the main page is white, and the header is light blue. All the texts are black with a normal font style. This header includes four sections, and if you put the mouse's cursor on or select one of these items, its background changes to dark blue. Since this Full Width Menu Code has a hover effect, users will not be bored while using your website. Because of all the positive features, this post can be an excellent idea for all kinds of websites.

#

React Header Menu

#

React Navbar Menu Code

#

Full Width Menu Code

#

Selection Menu Hover Effect

<!-- This script got from frontendfreecode.com -->
<div id="nav"></div>
<div id="text" class="window">
    <h1>React Navbar Example</h1>
    <p>This example was made with react (es6).</p>
</div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
ul {
  list-style: none;
  margin: 0;
  width: 100%;
  background-color: #beecea;
}
ul li {
  display: inline-block;
  padding: 1.25rem 3rem;
  cursor: pointer;
}
ul li:hover, ul li.active {
  background-color: #83dbd7;
}
.window {
  max-width: 1024px;
  padding: 20px;
  margin: auto;
}
function _defineProperty(obj, key, value) {if (key in obj) {Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });} else {obj[key] = value;}return obj;}class MenuExample extends React.Component {constructor(...args) {super(...args);_defineProperty(this, "state",
    { focused: 0 });}
  clicked(index) {
    this.setState({ focused: index });
  }
  render() {
    var self = this;
    return /*#__PURE__*/(
      React.createElement("div", null, /*#__PURE__*/
      React.createElement("ul", null, " ", this.props.items.map(function (m, index) {
        var style = '';
        if (self.state.focused == index) {
          style = 'active';
        }
        return /*#__PURE__*/React.createElement("li", { className: style, onClick: self.clicked.bind(self, index) }, m);
      }))));
  }}
;
React.render( /*#__PURE__*/
React.createElement(MenuExample, { items: ['Home', 'Services', 'About', 'Contact us'] }),
document.getElementById('nav'));
<link rel='stylesheet' href='https://cdn.jsdelivr.net/foundation/5.5.0/css/foundation.css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/0.13.0/react.min.js'></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<link rel='stylesheet' href='https://cdn.jsdelivr.net/foundation/5.5.0/css/foundation.css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/0.13.0/react.min.js'></script>
<style>
ul {
  list-style: none;
  margin: 0;
  width: 100%;
  background-color: #beecea;
}
ul li {
  display: inline-block;
  padding: 1.25rem 3rem;
  cursor: pointer;
}
ul li:hover, ul li.active {
  background-color: #83dbd7;
}
.window {
  max-width: 1024px;
  padding: 20px;
  margin: auto;
}
</style>

</head>
<body>
<div id="nav"></div>
<div id="text" class="window">
    <h1>React Navbar Example</h1>
    <p>This example was made with react (es6).</p>
</div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
function _defineProperty(obj, key, value) {if (key in obj) {Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });} else {obj[key] = value;}return obj;}class MenuExample extends React.Component {constructor(...args) {super(...args);_defineProperty(this, "state",
    { focused: 0 });}
  clicked(index) {
    this.setState({ focused: index });
  }
  render() {
    var self = this;
    return /*#__PURE__*/(
      React.createElement("div", null, /*#__PURE__*/
      React.createElement("ul", null, " ", this.props.items.map(function (m, index) {
        var style = '';
        if (self.state.focused == index) {
          style = 'active';
        }
        return /*#__PURE__*/React.createElement("li", { className: style, onClick: self.clicked.bind(self, index) }, m);
      }))));
  }}
;
React.render( /*#__PURE__*/
React.createElement(MenuExample, { items: ['Home', 'Services', 'About', 'Contact us'] }),
document.getElementById('nav'));
</script>

</body>
<script>'undefined'=== typeof _trfq || (window._trfq = []);'undefined'=== typeof _trfd && (window._trfd=[]),_trfd.push({'tccl.baseHost':'secureserver.net'},{'ap':'cpbh-mt'},{'server':'p3plmcpnl484880'},{'dcenter':'p3'},{'cp_id':'765442'},{'cp_cl':'8'}) // Monitoring performance to make your website faster. If you want to opt-out, please contact web hosting support.</script><script src='https://img1.wsimg.com/traffic-assets/js/tccl.min.js'></script></html>
Preview