Unable to remove active class in React NavLink - reactjs

I have taken advantage of the NavLink styling to add the active class to the current page menu item link. I am also using "exact in the Navs. However, I am unable to remove the active class from the Home page. Can anyone please take a look at my code and see if I am missing something? Thank you. The code is as follows:
app.js -
import React, { Component } from 'react';
import './App.css';
import { HashRouter as Router, Route } from 'react-router-dom';
import Inicio from './pages/Inicio';
import Gamification from './pages/Gamification';
import TotalMultimedia from './pages/TotalMultimedia';
import ELearning from './pages/ELearning';
import AbsoluteEngagement from './pages/AbsoluteEngagement';
import Nosotros from './pages/Nosotros';
import Contacto from './pages/Contacto';
class App extends Component {
render() {
return (
<Router basename="/">
<div>
<Route exact path='/' component={Inicio} />
<Route exact path='/Gamification' component={Gamification} />
<Route exact path='/TotalMultimedia' component={TotalMultimedia} />
<Route exact path='/ELearning' component={ELearning} />
<Route exact path='/AbsoluteEngagement' component=
{AbsoluteEngagement} />
<Route exact path='/Nosotros' component={Nosotros} />
<Route exact path='/Contacto' component={Contacto} />
</div>
</Router>
);
}
}
export default App;
Navbar.js -
import React, { Component } from 'react';
import './Navbar.css';
import { NavLink } from 'react-router-dom';
const isActivefunc = (match, location) => {
console.log(match, location)
return match
}
class Navbar extends Component {
render() {
return (
<div className="nav-wrapper">
<nav className="navbar nav-container pb-3 navbar-expand-md navbar-dark overlay">
<NavLink exact to="/"className="navbar-brand"></NavLink>
<button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span className="navbar-toggler-icon"></span>
</button>
<div className="collapse navbar-collapse" id="navbarsExampleDefault">
<ul className="navbar-nav ml-auto">
<li className="nav-item active">
<NavLink
isActive={isActivefunc}
exact activeClassName="active"
className="nav-link text-uppercase"
to="/">Inicio</NavLink>
</li>
<li className="nav-item dropdown">
<NavLink exact to="/Servicios" activeClassName="active" className="nav-link text-uppercase dropdown-toggle" href="#" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Servicios</NavLink>
<div className="dropdown-menu" aria-labelledby="dropdown01">
<NavLink exact to="/Gamification" activeClassName="main-nav-active-dropdown" className="dropdown-item text-uppercase font-weight-bold">Gamification Projects</NavLink>
<NavLink exact to="/TotalMultimedia" activeClassName="main-nav-active-dropdown" className="dropdown-item text-uppercase font-weight-bold">Total Multimedia</NavLink>
<NavLink exact to="/ELearning" activeClassName="main-nav-active-dropdown" className="dropdown-item text-uppercase font-weight-bold">Full E-Learning Platform</NavLink>
<NavLink exact to="/AbsoluteEngagement" activeClassName="main-nav-active-dropdown" className="dropdown-item text-uppercase font-weight-bold">Absolute Engagement Program</NavLink>
</div>
</li>
<li className="nav-item">
<NavLink exact to="/Nosotros" activeClassName="active" className="nav-link text-uppercase">Nosotros</NavLink>
</li>
<li className="nav-item">
<NavLink exact to="/Contacto" activeClassName="active" className="nav-link text-uppercase">Contacto</NavLink>
</li>
</ul>
</div>
</nav>
</div>
);
}
}
export default Navbar
Homepage -
import React, { Component } from 'react';
import './Inicio.css';
import { Link } from 'react-router-dom';
import Navbar from '../components/Navbar';
import Jumbotron1 from '../components/Jumbotron1';
import Footer from '../components/Footer';
class Inicio extends Component {
render() {
return (
<div>
<Navbar />
<Jumbotron1 />
<div className="content-container mt-3 mb-1 pt-5 pb-5">
<div className="content-img-1">
<div className="image-inner">
<div className="caption-background">
<div className="caption caption text-center pt-1 text-uppercase">1. Total Multimedia</div>
<div className="sub-caption text-center pb-1">
<h3>Realizamos sus tutoriales, videos, descargables y más, la mejor experiencia en capacitación</h3>
</div>
<div className="button-holder">
<Link to='/TotalMultimedia' className="btn btn-primary text-uppercase" role="button">Ver Detalles</Link>
</div>
</div>
</div>
</div>
</div>
<div className="content-container mb-2 pt-5 pb-5">
<div className="content-img-2">
<div className="image-inner">
<div className="caption-background">
<div className="caption caption text-center pt-1 text-uppercase">2. Gamification Projects</div>
<div className="sub-caption text-center pb-1">
<h3>Desarrollamos el potencial de cada persona con juegos, aplicaciones y más, las herramientas más innovadoras en capacitación</h3>
</div>
<div className="button-holder">
<Link to='/Gamification' className="btn btn-primary text-uppercase" role="button">Ver Detalles</Link>
</div>
</div>
</div>
</div>
</div>
<div className="content-container mb-2 pt-5 pb-5">
<div className="content-img-3">
<div className="image-inner">
<div className="caption-background">
<div className="caption caption text-center pt-1 text-uppercase">3. Full E-Learning Platform</div>
<div className="sub-caption text-center pb-1">
<h3>Creamos una plataforma para todos sus materiales de formación, totalmente interactivos y atractivos</h3>
</div>
<div className="button-holder">
<Link to='/ELearning' className="btn btn-primary text-uppercase" role="button">Ver Detalles</Link>
</div>
</div>
</div>
</div>
</div>
<div className="content-container mb-2 pt-5">
<div className="content-img-4">
<div className="image-inner">
<div className="caption-background">
<div className="caption caption text-center pt-1 text-uppercase">4. ABSOLUTE ENGAGEMENT PROGRAM</div>
<div className="sub-caption text-center pb-1">
<h3>El poder de todas nuestras soluciones en un solo programa incomparable</h3>
</div>
<div className="button-holder">
<Link to='/AbsoluteEngagement' className="btn btn-primary text-uppercase" role="button">Ver Detalles</Link>
</div>
</div>
</div>
</div>
</div>
<div className="content-container text-center mb-2 pt-5 pb-5">
<div className="row">
<div className="col-lg-3 col-md-6 spacing">
<Link to='/TotalMultimedia' className="blue-links">Multimedia</Link>
</div>
<div className="col-lg-3 col-md-6 spacing">
<Link to='/Gamification' className="blue-links">Gamification</Link>
</div>
<div className="col-lg-3 col-md-6 spacing">
<Link to='/ELearning' className="blue-links">Platform</Link>
</div>
<div className="col-lg-3 col-md-6 spacing">
<Link to='/AbsoluteEngagement' className="blue-links">Absolute Program</Link>
</div>
</div>
</div>
<div class="images-section pt-3 pb-3">
<div class="container pt-5 pb-5">
<div class="owl-carousel owl-theme">
<div class="item"><img class="grey" src="/assets/img/Renault-e1437433948637.jpg" alt="" /></div>
<div class="item"><img class="grey" src="/assets/img/hsbc.jpg" alt="" /></div>
<div class="item"><img class="grey" src="/assets/img/hiab.jpg" alt="" /></div>
<div class="item"><img class="grey" src="/assets/img/ge.jpg" alt="" /></div>
<div class="item"><img class="grey" src="/assets/img/holiday-inn.jpg" alt="" /></div>
<div class="item"><img class="grey" src="/assets/img/toyota.jpg" alt="" /></div>
</div>
</div>
</div>
<Footer />
</div>
);
}
}
export default Inicio
Demo site can be found at https://rrspark.com/lionsfieldcom

I found my problem. I simply forgot to remove the active class that shipped with the bootstrap example that I copied (dangers of cut and paste). The problem can be seen right after the nav-item class in the Navbar.js file.

Related

How to create a new page with React js

I have a code where this would essentially show links that you can press and would redirect you. I am have a problem where I am trying to click the link to "eco-news" and essentially open up a page with news articles in it. I have coded the news section, but I just dont know how to implement it.
Home > News > (directed to a new page where news would would populate)
import React from "react";
import './sidebar.css';
//import News from "../news section/News";
import { Link } from 'react-router-dom'
// Imported Images ==============>
import logo from '../../Assets/logo.png';
// Imported icons ===============>
import {IoMdSpeedometer} from 'react-icons/io';
import {TfiWorld} from 'react-icons/tfi';
import {BsQuestionCircle} from 'react-icons/bs'
// placeholder logo image
const Sidebar = () => {
return (
<div className="sideBar grid">
<div className="logoDiv flex">
<img src={logo} alt="World Space Logo" />
<h2>World Space.</h2>
</div>
<div className="menuDiv">
<h3 className="divTitle">
CONSUMPTION OVERVIEW
</h3>
<ul className="menuLists grid">
<li className="listItem">
<a href="/#" className="menuLink flex">
<IoMdSpeedometer className="icon" />
<span className="smallText">
Readout
</span>
</a>
</li>
<li className="listItem">
<a href="/#" className="menuLink flex">
<TfiWorld className="icon" />
<span className="smallText">
Driven Equivalent
</span>
</a>
</li>
<li className="listItem">
<a href="/#" className="menuLink flex">
<TfiWorld className="icon" />
<span className="smallText">
Efficiency Score
</span>
</a>
</li>
</ul>
</div>
{/* This is the tab for the Eco news, please update the necessary fonts and spacing */}
<div className="menuDiv">
<h3 className="divTitle">
NEWS
</h3>
<ul className="menuLists grid">
<li className="listItem">
{/* <a href=/News className="menuLink flex"> */}
<Link to ='\News' className="menuLink flex">
<TfiWorld className="icon" />
<span className="smallText">
Eco-News
</span>
</Link>
{/* </a> */}
</li>
</ul>
</div>
<div className="settingsDiv">
<h3 className="divTitle">
SETTINGS
</h3>
<ul className="menuLists grid">
<li className="listItem">
<a href="/#" className="menuLink flex">
<IoMdSpeedometer className="icon" />
<span className="smallText">
Dashboard
</span>
</a>
</li>
<li className="listItem">
<a href="/#" className="menuLink flex">
<TfiWorld className="icon" />
<span className="smallText">
Consumption Overview
</span>
</a>
</li>
<li className="listItem">
<a href="/#" className="menuLink flex">
<TfiWorld className="icon" />
<span className="smallText">
Goals
</span>
</a>
</li>
<li className="listItem">
<a href="/#" className="menuLink flex">
<TfiWorld className="icon" />
<span className="smallText">
Achievements
</span>
</a>
</li>
</ul>
</div>
<div className="sideBarCard">
<BsQuestionCircle className="icon" />
<div className="cardContent">
<h3>Help Center</h3>
{/*<p>Having trouble in World Space, please contact us.</p>
<button className="btn">Go to help center</button>*/}
</div>
</div>
</div>
);
}
export default Sidebar;
<div className="menuDiv">
<h3 className="divTitle">
NEWS
</h3>
<ul className="menuLists grid">
<li className="listItem">
{/* <a href=/News className="menuLink flex"> */}
<Link to ='\News' className="menuLink flex">
<TfiWorld className="icon" />
<span className="smallText">
Eco-News
</span>
</Link>
{/* </a> */}
</li>
</ul>
</div>
if you click the link it would lead to a broken page.
What it looks like so far
Ensure that you have followed the below steps as pre requisites
Create browser router
Add a route for your News component
Only then will your routing work

React Dom Outlet Route Confusion. Nest 3 Part Page Into one Route. React Router v6

I'm having a hard time understanding how the routes and outlets work in react. My problem is this.
If I have a route that should load 3 parts.
-Top Menu
-Side Menu
-Center Content
But the center content is contained in the div thats wrapped by the "Side Menu" how do I wrap another element that will be changing inside of a previous component. My goal is to use the first 2 in all of the routes and based on the route the center content will change.
This is what it should look like
<div id="layoutSideNav">
<div id="layoutsidenav_nav"></div>
<div id="layoutSidenav_content"></div>
</div>
But for some reason all I can get is this
<div id="layoutSideNav">
<div id="layoutsidenav_nav"></div>
</div>
<div id="layoutSidenav_content"></div>
My react looks like this.
3 Components
Contains the top nav
contains the side nav
contains body elements that will change.
App()
<Route
path='/admin-dashboard'
element={
<>
<AdminNavigation />
<AdminNavigationLeft />
<AdminDashBoardHome />
</>
}
>
If I add <Outlet/> before the closing div in "layoutSideNav" component. nothing happens. If I remove the outlets from all components the app() looks the same. The top nav and side nave display correclty, but the center content is wonky.
I feel like routes is so much more abstract than I'm used to so maybe I'm just not thinking about it logically. Thank you so much for your help!
I tried using <Outlet/> to adjust how where the third component content displayed.
I've added my full code below for review.
const AdminNavigation = () =>{
const toggleSideMenu = event => {
// 👇️ toggle class on click
document.getElementsByTagName('body')[0].classList.toggle('sb-sidenav-toggled');
};
return (
<Fragment>
<nav className="sb-topnav navbar navbar-expand navbar-dark bg-dark">
<a className="navbar-brand ps-3" href="index.html">Woodmoore Improvement</a>
<button className="btn btn-link btn-sm order-1 order-lg-0 me-4 me-lg-0" onClick={toggleSideMenu} id="sidebarToggle" href="#!"><i className="fas fa-bars"></i></button>
<form className="d-none d-md-inline-block form-inline ms-auto me-0 me-md-3 my-2 my-md-0">
<div className="input-group">
<input className="form-control" type="text" placeholder="Search for..." aria-label="Search for..." aria-describedby="btnNavbarSearch" />
<button className="btn btn-primary" id="btnNavbarSearch" type="button"><i className="fas fa-search"></i></button>
</div>
</form>
<ul className="navbar-nav ms-auto ms-md-0 me-3 me-lg-4">
<li className="nav-item dropdown">
<a className="nav-link dropdown-toggle" id="navbarDropdown" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"><i className="fas fa-user fa-fw"></i></a>
<ul className="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
<li><a className="dropdown-item" href="#!">Settings</a></li>
<li><hr className="dropdown-divider" /></li>
<li><a className="dropdown-item" href="#!">Logout</a></li>
</ul>
</li>
</ul>
</nav>
</Fragment>
)
}
export default AdminNavigation;
const AdminDashBoardHome = () => {
return(
<Fragment>
<div id='layoutSidenav_content'>
<main>
<div className='container-fluid px-4'>
<h1 className='mt-4'>HOA Member Manager</h1>
<ol className='breadcrumb mb-4'>
<li className='breadcrumb-item active'>Member Map</li>
</ol>
<div className='row'>
<div className='col-lg-12'>
<div className='embed-responsive embed-responsive-16by9'>
<div id='map_canvas' className='embed-responsive-item pb-4' >
</div>
</div>
</div>
</div>
<div className='row'>
</div>
<div className='card mb-4'>
<div className='card-header'>
<i className='fas fa-table me-1'></i>
Member Lookup
</div>
<MemberDataList/>
</div>
</div>
</main>
<footer className='py-4 bg-light mt-auto'>
<div className='container-fluid px-4'>
<div className='d-flex align-items-center justify-content-between small'>
<div className='text-muted'>Copyright © Your Website 2022</div>
<div>
<a href='#'>Privacy Policy</a>
·
<a href='#'>Terms & Conditions</a>
</div>
</div>
</div>
</footer>
</div>
</Fragment>
)
}
export default AdminDashBoardHome;
const AdminNavigationLeft = () => {
document.body.classList.add('sb-nav-fixed');
return(
<Fragment>
<div id="layoutSidenav">
<Outlet/>
<div id="layoutSidenav_nav">
<nav className="sb-sidenav accordion sb-sidenav-dark" id="sidenavAccordion">
<div className="sb-sidenav-menu">
<div className="nav">
<div className="sb-sidenav-menu-heading">Core</div>
<a className="nav-link" href="index.html">
<div className="sb-nav-link-icon"><i className="fas fa-tachometer-alt"></i></div>
Dashboard
</a>
<div className="sb-sidenav-menu-heading">Interface</div>
<a className="nav-link collapsed" href="#" data-bs-toggle="collapse" data-bs-target="#collapseLayouts" aria-expanded="false" aria-controls="collapseLayouts">
<div className="sb-nav-link-icon"><i className="fas fa-columns"></i></div>
Layouts
<div className="sb-sidenav-collapse-arrow"><i className="fas fa-angle-down"></i></div>
</a>
<div className="collapse" id="collapseLayouts" aria-labelledby="headingOne" data-bs-parent="#sidenavAccordion">
<nav className="sb-sidenav-menu-nested nav">
<a className="nav-link" href="layout-static.html">Static Navigation</a>
<a className="nav-link" href="layout-sidenav-light.html">Light Sidenav</a>
</nav>
</div>
<a className="nav-link collapsed" href="#" data-bs-toggle="collapse" data-bs-target="#collapsePages" aria-expanded="false" aria-controls="collapsePages">
<div className="sb-nav-link-icon"><i className="fas fa-book-open"></i></div>
Admin Management
<div className="sb-sidenav-collapse-arrow"><i className="fas fa-angle-down"></i></div>
</a>
<div className="collapse" id="collapsePages" aria-labelledby="headingTwo" data-bs-parent="#sidenavAccordion">
<nav className="sb-sidenav-menu-nested nav accordion" id="sidenavAccordionPages">
<a className="nav-link collapsed" href="#" data-bs-toggle="collapse" data-bs-target="#pagesCollapseAuth" aria-expanded="false" aria-controls="pagesCollapseAuth">
Manage Users
</a>
<a className="nav-link collapsed" href="#" data-bs-toggle="collapse" data-bs-target="#pagesCollapseAuth" aria-expanded="false" aria-controls="pagesCollapseAuth">
Create New
</a>
</nav>
</div>
</div>
</div>
<div className="sb-sidenav-footer">
<div className="small">Logged in as:</div>
Start Bootstrap
</div>
</nav>
</div>
</div>
</Fragment>
)
}
export default AdminNavigationLeft;
If the following is what you intend to be rendered:
<div id="layoutSideNav">
<div id="layoutsidenav_nav"></div>
<div id="layoutSidenav_content"></div>
</div>
Then I suspect you want the routed content to be rendered in the layoutSidenav_content div. Something like the following:
<div id="layoutSideNav">
<div id="layoutsidenav_nav">
... navbar content ...
</div>
<div id="layoutSidenav_content">
... routed content ...
</div>
</div>
In other words, the above snippet describes a layout component, the routed content is the logical place for an Outlet component wrapping nested routes to output their element content into. The route may look like:
const AdminLayout = () => (
<>
<AdminNavigation />
<div id="layoutsidenav">
<div id="layoutSidenav_nav">
<AdminNavigationLeft />
</div>
<div id="layoutsidenav_content">
<Outlet />
</div>
</div>
</>
);
<Route
path='/admin-dashboard'
element={<AdminLayout />}
>
<Route index element={<AdminDashBoardHome />} />
... other admin routes
</Route>
const AdminNavigationLeft = () => {
useEffect(() => {
document.body.classList.add('sb-nav-fixed');
}, []);
return (
<nav className="sb-sidenav accordion sb-sidenav-dark" id="sidenavAccordion">
<div className="sb-sidenav-menu">
...
</div>
</nav>
)
}
const AdminDashBoardHome = () => {
return (
<Fragment>
<main>
...
</main>
<footer className='py-4 bg-light mt-auto'>
...
</footer>
</Fragment>
)
}
I solved my own question.
You need to run the props through the component you're trying to display. The solution should be like this.
App()
<Route path='/admin-dashboard' element={<><AdminNavigation /><AdminNavigationLeft><AdminDashBoardHome/></AdminNavigationLeft></>}>
AdminDashLeft()
const AdminNavigationLeft = (props) => {
{props.children} // This is where the child component should display
}

Unable to use div components with bootstrap classes inside map function in react

I have passed the data via props, the console logs show me the data being passed. here is the code below
import React, { Component } from 'react';
import "../../../node_modules/bootstrap/dist/css/bootstrap.min.css";
import "./TestimonialCard.css";
const Cards = ({cardData}) =>{
console.log(cardData);
return(
<>
<div className="container">
<div className="row">
<div className="col-md-8 col-center m-auto">
<h2>Testimonials</h2>
<div id="myCarousel" className="carousel slide" data-ride="carousel" >
<div className="carousel-inner">
{cardData.map((slide , index )=>{
{console.log(slide)}
<div className="item carousel-item active" key={index} >
<div className="img-box">
<img src={slide.image} alt={slide.alt}/>
</div>
<p className="testimonial">
{slide.testimonial}
</p>
<p className="overview">
<b> {slide.name} </b> ,<span>{slide.designation}</span>
</p>
</div>
})}
</div>
<a className="carousel-control left carousel-control-prev" href="myCarousel" data-slide="prev">
<i className="fa fa-angle-left"></i>
</a>
<a className="carousel-control right carousel-control-next" href="myCarousel" data-slide="next">
<i className="fa fa-angle-right"></i>
</a>
</div>
</div>
</div>
</div>
</>
)
}
export default Cards
Here, I'm not getting an expected UI under my div with carousel-inner class.
You can use it like this:
import React, { Component } from 'react';
import "../../../node_modules/bootstrap/dist/css/bootstrap.min.css";
import "./TestimonialCard.css";
const Cards = ({cardData}) =>{
console.log(cardData);
const cardData = (cardData) => {
cardData.map((slide, index) => {
return (
<div className="item carousel-item active" key={index}>
<div className="img-box">
<img src={slide.image} alt={slide.alt}/>
</div>
<p className="testimonial">
{slide.testimonial}
</p>
<p className="overview">
<b> {slide.name} </b> ,<span>{slide.designation}</span>
</p>
</div>
)
})
}
return(
<>
<div className="container">
<div className="row">
<div className="col-md-8 col-center m-auto">
<h2>Testimonials</h2>
<div id="myCarousel" className="carousel slide" data-ride="carousel" >
<div className="carousel-inner">
{cardData()}
</div>
<a className="carousel-control left carousel-control-prev" href="myCarousel" data-slide="prev">
<i className="fa fa-angle-left"></i>
</a>
<a className="carousel-control right carousel-control-next" href="myCarousel" data-slide="next">
<i className="fa fa-angle-right"></i>
</a>
</div>
</div>
</div>
</div>
</>
)
}
export default Cards
The reason UI was not rendering is because you are using {} instead of () in map inside JSX.
If you want to use map inside render() or the JSX you need to use () instead of {} like this:
{cardData.map((slide , index )=> (
{console.log(slide)}
<div className="item carousel-item active" key={index} >
<div className="img-box">
<img src={slide.image} alt={slide.alt}/>
</div>
<p className="testimonial">
{slide.testimonial}
</p>
<p className="overview">
<b> {slide.name} </b> ,<span>{slide.designation}</span>
</p>
</div>
))}

How to render the page based on selected option on the middle part of App, Top and side bar should be static

Sorry if the title is kinda confusing.
I'm making an index page with a side and top navbar with the menu using react router, I have successfully loaded the content up but I want it to load in the main body, the middle of the page.
I've tried separating method like how I used JSP before but its not very effective so to speak
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import Login from './Login';
import * as serviceWorker from './serviceWorker';
import Dropdown from 'react-bootstrap/Dropdown';
import { Link } from 'react-router-dom';
import { BrowserRouter, Route } from "react-router-dom";
import './index.css';
import AssetView from './AssetView';
import DepartmentView from './DepartmentView';
import LocationView from './LocationView';
import EmployeeView from './EmployeeView';
import AddDepartment from './AddDepartment';
import AddLocation from './AddLocation';
const routing = (
<BrowserRouter>
<div>
<nav class="navbar navbar-dark fixed-top bg-dark flex-md-nowrap p-0">
<a class="navbar-brand col-sm-3 col-md-2 mr-0" href="#">Company name</a>
<ul class="navbar-nav px-3">
<li class="nav-item dropdown">
<Dropdown>
<Dropdown.Toggle variant="success" id="dropdown-basic">
Account
</Dropdown.Toggle>
<Dropdown.Menu>
<Dropdown.Item href="#/action-1">Informations</Dropdown.Item>
<Dropdown.Item href="#/action-2">Settings</Dropdown.Item>
<Dropdown.Item href="#/action-3">Signout</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</li>
</ul>
</nav>
<div class="container-fluid">
<div class="row">
<nav class="col-md-2 d-none d-md-block bg-light sidebar">
<div class="sidebar-sticky">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-Link active" href="#">
<span data-feather="home"></span>
Dashboard <span className="sr-only">(current)</span>
</a>
</li>
<h6 className="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>Assets Management</span>
<a className="d-flex align-items-center text-muted" href="#">
<span data-feather="plus-circle" />
</a>
</h6>
<li className="nav-item">
<Link to="/AssetView">
<a class="nav-link" href="#">
<span data-feather="file"></span>
View All Assets
</a>
</Link>
</li>
</ul>
<h6 className="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>Company Management</span>
<a className="d-flex align-items-center text-muted" href="#">
<span data-feather="plus-circle" />
</a>
</h6>
<ul className="nav flex-column mb-2">
<li className="nav-item">
<Link to="/DepartmentView">
<a class="nav-link" href="#">
<span data-feather="file"></span>
View All Departments
</a>
</Link>
</li>
<li className="nav-item">
<Link to="/AddDepartment">
<a class="nav-link" href="#">
<span data-feather="file"></span>
Add New Department
</a>
</Link>
</li>
<li className="nav-item">
<Link to="/LocationView">
<a class="nav-link" href="#">
<span data-feather="file"></span>
View All Locations
</a>
</Link>
</li>
<li className="nav-item">
<Link to="/AddLocation">
<a class="nav-link" href="#">
<span data-feather="file"></span>
Add New Location
</a>
</Link>
</li>
</ul>
<h6 className="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>Employees Management</span>
<a className="d-flex align-items-center text-muted" href="#">
<span data-feather="plus-circle" />
</a>
</h6>
<ul className="nav flex-column mb-2">
<li className="nav-item">
<Link to="/EmployeeView">
<a class="nav-link" href="#">
<span data-feather="file"></span>
View All Employees
</a>
</Link>
</li>
</ul>
</div>
</nav>
</div>
</div>
<Route exact path="/AssetView" component={AssetView} />
<Route path="/DepartmentView" component={DepartmentView} />
<Route path="/LocationView" component={LocationView} />
<Route path="/EmployeeView" component={EmployeeView} />
<Route path="/AddDepartment" component={AddDepartment} />
<Route path="/AddLocation" component={AddLocation} />
</div>
</BrowserRouter>
)
ReactDOM.render(routing, document.getElementById('root'));
serviceWorker.unregister();
This is how the page looks right now, I really wish to make the content of the page appear in the middle
https://photos.app.goo.gl/BSuZuvGhiQQetmit5
You mean, you have to create a dashboard-like app
Where top and sidebar is static and on click of the sidebar the middle part change
Then you can check this repo
https://github.com/designrevision/shards-dashboard-react
Here is the master page https://github.com/DesignRevision/shards-dashboard-react/blob/master/src/layouts/Default.js
import React from "react";
import PropTypes from "prop-types";
import { Container, Row, Col } from "shards-react";
import MainNavbar from "../components/layout/MainNavbar/MainNavbar";
import MainSidebar from "../components/layout/MainSidebar/MainSidebar";
import MainFooter from "../components/layout/MainFooter";
const DefaultLayout = ({ children, noNavbar, noFooter }) => (
<Container fluid>
<Row>
<MainSidebar />
<Col
className="main-content p-0"
lg={{ size: 10, offset: 2 }}
md={{ size: 9, offset: 3 }}
sm="12"
tag="main"
>
{!noNavbar && <MainNavbar />}
{children}
{!noFooter && <MainFooter />}
</Col>
</Row>
</Container>
);
DefaultLayout.propTypes = {
/**
* Whether to display the navbar, or not.
*/
noNavbar: PropTypes.bool,
/**
* Whether to display the footer, or not.
*/
noFooter: PropTypes.bool
};
DefaultLayout.defaultProps = {
noNavbar: false,
noFooter: false
};
export default DefaultLayout;
The correct answer has been replied by #ravibagul91, thank you.
I removed the class="sidebar-sticky" of the sidebar and add the .sidebar{position:absolute;top:0;bottom:0} in my index.css and it works just fine as the image I just uploaded
https://photos.app.goo.gl/m744U7R4mACAUXq37
Thank you #piyush-dhamecha for the recommendation, it is somewhat similar to what I need, but truth be told, it's still kinda advance for me, but I appreciate it and will keep it for future reference.

Bulma Navbar component is not showing

I am reading Bulma docs, took example to apply it on Codesandbox but the NavBar has a problem.
I imported Bulma as mentioned in docs, copied code, and I suppose Bulma is only css framework so no js to add.
The examples of Hero section that I am using can be found over here
The example provided with Hero head and Hero body and includes Nav bar is not working. The Navbar only as you see example here
import React from "react";
import ReactDOM from "react-dom";
import "./styles.css";
import "bulma/css/bulma.css";
function App() {
return (
<div className="App">
<section class="hero is-primary is-medium">
<div class="hero-head">
<nav class="navbar">
<div class="container">
<div class="navbar-brand">
<a class="navbar-item">
<img
src="https://bulma.io/images/bulma-type-white.png"
alt="Logo"
/>
</a>
<span
class="navbar-burger burger"
data-target="navbarMenuHeroA"
>
<span />
<span />
<span />
</span>
</div>
<div id="navbarMenuHeroA" class="navbar-menu">
<div class="navbar-end">
<a class="navbar-item is-active">Home</a>
<a class="navbar-item">Examples</a>
<a class="navbar-item">Documentation</a>
<span class="navbar-item">
<a class="button is-primary is-inverted">
<span class="icon">
<i class="fab fa-github" />
</span>
<span>Download</span>
</a>
</span>
</div>
</div>
</div>
</nav>
</div>
<div class="hero-body">
<div class="container has-text-centered">
<h1 class="title">Title</h1>
<h2 class="subtitle">Subtitle</h2>
</div>
</div>
<div class="hero-foot">
<nav class="tabs">
<div class="container">
<ul>
<li class="is-active">
<a>Overview</a>
</li>
<li>
<a>Modifiers</a>
</li>
<li>
<a>Grid</a>
</li>
<li>
<a>Elements</a>
</li>
<li>
<a>Components</a>
</li>
<li>
<a>Layout</a>
</li>
</ul>
</div>
</nav>
</div>
</section>
</div>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

Resources