content logo

React Sidebars:

Top Right Menu using React JS with Toggle Button

In this post, we are going to introduce a beautiful code with a different design for all kinds of websites. The Top Right Menu using React JS with Toggle Button is one of the best codes that you can use for your own website. This Top Menu Effect has a simple design, and it can easily fit with all kinds of websites with different themes. With the help of this beautiful React Menu Code, you are able to classify different kinds of content on your website into various categories. So, if you want to save the physical space of your website and gain more followers, this HTML Menu Fade Effect is a great idea.

We have provided the preview of this Javascript Menu Example down below to represent its performance. You can see that the mentioned code has an orange background with white writing. There is a hamburger icon on the right side of this page in white color. When you put the mouse’s cursor on this icon, its background changes to orange. By clicking on this Menu Toggle Button, a menu will be displayed with a white background and black texts representing four categories.

#

Top Sidebar Effect

#

React Sidebar Code

#

HTML Sidebar Fade Effect

#

Javascript Sidebar Example

#

Menu Toggle Button

<!-- This script got from frontendfreecode.com -->
<div id="app"></div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
html, body {
	height: 100%;
	background: #282830;
	font-family: Helvetica Neue;
}
.text {
	display: flex;
	justify-content: center;
	align-items: center;
	margin-top: 150px;
	color: #eee;
	font-size: 1.5em;
}
.hamburger {
	cursor: pointer;
	position: absolute;
	right: 20px;
	top: 20px;
}
.hamburger.inactive {
	height: 30px;
	width: 30px;
	transition: all 0.5s ease-in-out;
	transition-delay: 0.4s;
}
.hamburger.inactive ul {
	opacity: 0;
	transition: opacity 0.5s ease-in-out;
	transition-delay: 0s;
}
.hamburger.active {
	background: #eee;
	width: 150px;
	height: 200px;
	transition: all 0.5s ease-in-out;
}
.hamburger.active ul {
	opacity: 1;
	transition: opacity 0.5s ease-in-out;
	transition-delay: 0.5s;
}
.hamburger.active .lines {
	background: #fab800;
}
.menu {
	cursor: pointer;
	text-align: center;
	margin: 30px 0 30px 0;
	width: 100%;
}
.menu li {
	line-height: 40px;
	width: 100%;
}
.menu li:hover {
	background: #fab800;
}
.lines {
	position: absolute;
	width: 30px;
	height: 30px;
	right: 0;
}
.lines:hover {
	background: #fab800;
}
.lines span {
	background: #fff;
	display: block;
	width: 20px;
	height: 2px;
	position: absolute;
	right: 5px;
}
.lines span:first-of-type {
	top: 10px;
}
.lines span:nth-of-type(2) {
	top: 15px;
}
.lines span:nth-of-type(3) {
	top: 20px;
}
class Hamburger extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("div", { className: "lines" }, /*#__PURE__*/
    React.createElement("span", null), /*#__PURE__*/
    React.createElement("span", null), /*#__PURE__*/
    React.createElement("span", null));
  }}
class Menu extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("div", { className: "menu" }, /*#__PURE__*/
    React.createElement("ul", null, /*#__PURE__*/
    React.createElement("li", null, "Home"), /*#__PURE__*/
    React.createElement("li", null, "About"), /*#__PURE__*/
    React.createElement("li", null, "Work"), /*#__PURE__*/
    React.createElement("li", null, "Contact")));
  }}
class Text extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("div", { className: "text" }, /*#__PURE__*/
    React.createElement("h1", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore"));
  }}
class App extends React.Component {
  constructor() {
    super();
    this.onButtonClick = this.onButtonClick.bind(this);
    this.state = { condition: true };
  }
  onButtonClick() {
    this.setState({ condition: !this.state.condition });
  }
  render() {
    return /*#__PURE__*/(
      React.createElement("div", null, /*#__PURE__*/
      React.createElement("div", { className: this.state.condition ? "hamburger inactive" : "hamburger active" }, /*#__PURE__*/
      React.createElement("div", { onClick: this.onButtonClick }, /*#__PURE__*/
      React.createElement(Hamburger, null)), /*#__PURE__*/
      React.createElement(Menu, null)), /*#__PURE__*/
      React.createElement(Text, null)));
  }}
React.render( /*#__PURE__*/React.createElement(App, null), document.getElementById('app'));
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.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://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/0.13.0/react.min.js'></script>
<style>
html, body {
	height: 100%;
	background: #282830;
	font-family: Helvetica Neue;
}
.text {
	display: flex;
	justify-content: center;
	align-items: center;
	margin-top: 150px;
	color: #eee;
	font-size: 1.5em;
}
.hamburger {
	cursor: pointer;
	position: absolute;
	right: 20px;
	top: 20px;
}
.hamburger.inactive {
	height: 30px;
	width: 30px;
	transition: all 0.5s ease-in-out;
	transition-delay: 0.4s;
}
.hamburger.inactive ul {
	opacity: 0;
	transition: opacity 0.5s ease-in-out;
	transition-delay: 0s;
}
.hamburger.active {
	background: #eee;
	width: 150px;
	height: 200px;
	transition: all 0.5s ease-in-out;
}
.hamburger.active ul {
	opacity: 1;
	transition: opacity 0.5s ease-in-out;
	transition-delay: 0.5s;
}
.hamburger.active .lines {
	background: #fab800;
}
.menu {
	cursor: pointer;
	text-align: center;
	margin: 30px 0 30px 0;
	width: 100%;
}
.menu li {
	line-height: 40px;
	width: 100%;
}
.menu li:hover {
	background: #fab800;
}
.lines {
	position: absolute;
	width: 30px;
	height: 30px;
	right: 0;
}
.lines:hover {
	background: #fab800;
}
.lines span {
	background: #fff;
	display: block;
	width: 20px;
	height: 2px;
	position: absolute;
	right: 5px;
}
.lines span:first-of-type {
	top: 10px;
}
.lines span:nth-of-type(2) {
	top: 15px;
}
.lines span:nth-of-type(3) {
	top: 20px;
}
</style>

</head>
<body>
<div id="app"></div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
class Hamburger extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("div", { className: "lines" }, /*#__PURE__*/
    React.createElement("span", null), /*#__PURE__*/
    React.createElement("span", null), /*#__PURE__*/
    React.createElement("span", null));
  }}
class Menu extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("div", { className: "menu" }, /*#__PURE__*/
    React.createElement("ul", null, /*#__PURE__*/
    React.createElement("li", null, "Home"), /*#__PURE__*/
    React.createElement("li", null, "About"), /*#__PURE__*/
    React.createElement("li", null, "Work"), /*#__PURE__*/
    React.createElement("li", null, "Contact")));
  }}
class Text extends React.Component {
  render() {
    return /*#__PURE__*/React.createElement("div", { className: "text" }, /*#__PURE__*/
    React.createElement("h1", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore"));
  }}
class App extends React.Component {
  constructor() {
    super();
    this.onButtonClick = this.onButtonClick.bind(this);
    this.state = { condition: true };
  }
  onButtonClick() {
    this.setState({ condition: !this.state.condition });
  }
  render() {
    return /*#__PURE__*/(
      React.createElement("div", null, /*#__PURE__*/
      React.createElement("div", { className: this.state.condition ? "hamburger inactive" : "hamburger active" }, /*#__PURE__*/
      React.createElement("div", { onClick: this.onButtonClick }, /*#__PURE__*/
      React.createElement(Hamburger, null)), /*#__PURE__*/
      React.createElement(Menu, null)), /*#__PURE__*/
      React.createElement(Text, null)));
  }}
React.render( /*#__PURE__*/React.createElement(App, null), document.getElementById('app'));
</script>

</body>
</html>
Preview