Creating a sidebar using reactjs and bootstrap - html

I have a react project in which I need bootstrap sidebar which looks one of metronics https://preview.keenthemes.com/metronic/demo1/index.html theme. I tried hard but couldn't copy it as I am not master of CSS.I need sidebar same as metronics. How could I make sidebar with the rotating caret and icons.
I have tried react-bootstrap but couldn't make it. Do i need to add custom css?
Thanks in advance
My sidebar component :
function SideBar(){
return(
<nav className="navbar navbar-dark align-items-start sidebar sidebar-dark accordion bg-gradient-primary p-0">
<div className="container-fluid d-flex flex-column p-0">
<Link className="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="#">
<div className="sidebar-brand-icon rotate-n-15"></div>
<div className="sidebar-brand-text mx-3"><span>ProjectName </span>
</div>
<Button className="rounded-circle border-0" ></Button>
</Link>
<ul className="nav navbar-nav text-light">
<li className="nav-item">
<Link to="/index">
<FaIcons.FaTachometerAlt/>
<span>Dashboard</span>
</Link>
</li>
<li className="nav-item">
<Link to="/profile">
<FaIcons.FaUser/>
<span>Profile</span>
</Link>
</li>
<li className="nav-item">
<Link to="/table">
<FaIcons.FaTable/>
<span>Table</span>
</Link>
</li>
</ul>
</div>
</nav>
)
}

Related

How to place elements lower than sticky navbar in Bootstrap?

I can't find information on how to use bootstrap to place all subsequent div lower than header.
I have it written like this:
<header className="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a className="navbar-brand px-3 fs-4" href="/">Todos</a>
<div className="collapse navbar-collapse" id="navbarSupportedContent">
<ul className="navbar-nav mr-auto">
<li className="nav-item active">
<Link className="nav-link fs-4" to="/about">List <span className="sr-only"></span></Link>
</li>
<li className="nav-item active px-3 fs-4">
<Link className="nav-link" to="/homepage"> Add <span className="sr-only"></span></Link>
</li>
</ul>
</div>
</header>
And now that I have added a button to this page it appears in the upper left corner, not below. There is also an overlap if I go to another page . Since I am new to this, I will be glad to help.
<div className="mbtn">
<button onClick={() => setType('books')} className="btn btn-outline-primary">Пользователи</button>
</div>

can't see the cart icon responsive mode

My cart icon in the navbar toggle is not showing up when I go into a smaller display.
I am using bootstrap 5 for the navbar, I can click on the bottom of the toggler and it brings me to the my cart page but I can't see the actual icon.
Anyone have an idea on how I can fix this?
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.8.1/font/bootstrap-icons.css">
<nav class="navbar navbar-expand-sm bg-dark navbar-dark sticky-top">
<div class="container">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navmenu">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navmenu">
Meat
<ul class="navbar-nav">
<li class="nav-item px-4">
Fruits & Vegetables
</li>
<li class="nav-item px-4">
Dairy & Eggs
</li>
<li class="nav-item px-4">
Snack
</li>
<li class="nav-item px-4">
Drinks
</li>
<li class="nav-item px-4">
Bakery
</li>
<i class="bi bi-basket2-fill h2 cart-color"></i>
</ul>
</div>
</div>
</nav>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
your cart icon element is exist but on a tablet, the size would go out of range of the screen.
you can fix this issue by trying to use one of these methods :
1 - try to re-responsive the navbar (with bootstrap you can use COl styling)
for this method try to read grid doc from the bootstrap website: https://getbootstrap.com/docs/5.1/components/navbar/
2 : you can give the icon "position absolute".
but I won't suggest this method because it is not so professional.

Nav also moves when applying margin top in TailWind

When I try to apply margin-top to a container, the container moves, but so does the nav bar, do you guys know what can I do? I am using TailwindCSS, please check the images:
First Image
Second Image
<header>
<nav class="w-full bg-white fixed flex border-b-2 border-opacity-50 z-10">
<a class="" href="#home">
<img class="mx-48 p-2 w-24" src="assets/logo/dfnr.png" alt="Diefonro logo" />
</a>
<ul class="nav-list flex text-gray-500 relative left-40 font-bold mt-1">
<li class="p-3 mx-2 hover:text-gray-800">
Home
</li>
<li class="p-3 mx-1 hover:text-gray-800">
About
</li>
<li class="p-3 mx-2 hover:text-gray-800">
Services
</li>
<li class="p-3 mx-2 hover:text-gray-800">
Portfolio
</li>
<li class="p-3 mx-2 hover:text-gray-800">
Contact
</li>
</ul>
</nav>
</header>
<main>
<div class="container mt-16 mx-auto bg-gray-700" id="home">
<p class="text-3xl">Hi! This is</p>
<h1 class="title gradient-title">DIEFONRO</h1>
<p class="pos-text">Junior Front-End Developer</p>
<button class="hire">HIRE ME</button>
<button class="get-cv">GET CV</button>
<img src="assets/img/Diefonro.png" alt="diefonro's ilustration" class="main-img" />
</div>
</main>
I think adding top-0 to the <nav> will fulfill your wish.

Navbar list alignment issues in bootstrap

<div class="container"> <!--main div-->
<div>
<nav class="navbar navbar-light bg-light">
<img id="logo" src="logo_white_background.jpg"></img>
<ul class="navbar-nav list-unstyled">
<li class="nav-item">
<button>Login</button><!--Login Link-->
</li>
<li class="nav-item ml-2">
<button>Explore Live Experiments</button><!--Current Available Live Courses Link-->
</li>
</ul>
</nav>
</div>
</div>
</body>
This code works fine to give me the desired navbar. However the login and the explore experiments button don't align to the right. In Spite of trying to add mr-auto and mr-right to the ul. Tried doing custom css align right but no response. How do i make the two buttons go the right of the nav bar?
Can you please check the below code? Hope it will work for you. If you add bootstrap 4 then it's working fine and you want to set the button in the same line then you have to add flex-direction in .navbar-nav so it's work as per your requirement.
Please refer to this link: https://jsfiddle.net/yudizsolutions/syakr3j5/
.navbar-nav {
flex-direction: row !important;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<!--main div-->
<div>
<nav class="navbar navbar-light bg-light">
<img id="logo" src="logo_white_background.jpg">
<ul class="navbar-nav list-unstyled d-flex">
<li class="nav-item">
<button>Login</button>
<!--Login Link-->
</li>
<li class="nav-item ml-2">
<button>Explore Live Experiments</button>
<!--Current Available Live Courses Link-->
</li>
</ul>
</nav>
</div>
</div>
<nav class="navbar navbar-light bg-light d-flex">
<img id="logo" src="logo_white_background.jpg"></img>
<ul class="navbar-nav list-unstyled ml-auto">
<li class="nav-item">
<button>Login</button><!--Login Link-->
</li>
<li class="nav-item ml-2">
<button>Explore Live Experiments</button><!--Current Available Live Courses Link-->
</li>
</ul>
</nav>
add d-flex class on <nav> and ml-auto on <ul>

bootstrap 4.5.3 centering navbar text with icon

i have navbar with two menu, want to center menu icon and text but i dont't find the class to used.
how can i do it ?
im sorry for my bad english
here my code
<body class="text-center">
<div class="bg-login">
<div class="container">
<nav class="navbar navbar-dark sticky-top h-100">
<ul class="nav navbar-nav ml-auto nav-fill">
<li class="navbar-item">
<a class="navbar-brand" href="#" id="navlink">
<span data-feather="globe"></span>
EN-US
</a>
</li>
<li class="navbar-item">
<a class="navbar-brand" href="#">
<span data-feather="globe"></span>
en-uk
</a>
</li>
</ul>
</nav>
</div>
</div>
<script type="text/javascript">
feather.replace()
</script>
</body>
jsfiddle : https://jsfiddle.net/lexavey/jywL5ves/12/
im use
<ul class="nav navbar-nav ml-auto nav-fill">
because i want navigation i right side like this https://prnt.sc/wb1d3s
my problem is center verticaly https://prnt.sc/wb1hp1
add flex classes to the container div
<div class="container d-flex justify-content-center">
You can use these classes in Nav elements
<a class="navbar-brand d-flex align-items-center" href="#" id="navlink">