How to align Bootstrap 5 navbar buttons to the right
How do you align Bootstrap 5 navbar button items to the right? When looking on membership based websites you’ll notice a common theme: login and sign up buttons aligning to the right of the navbar.
So you’ve built a navigation bar on Bootstrap 5 and you’re happy with the way it looks, however there is an aligning issue..
You may have noticed if you’ve copied and pasted the navbar code from Bootstrap documentation they all align to the left. Your question is how do I align a button or buttons to the right on my navbar?
For example, you may want to keep your navbar items aligned to the left but want to have an account login or register button on the right.
Here’s how you do it..
Navbar items all aligned left without buttons
Here’s an example of the standard Bootstrap navigation bar. Here you can see the login and sign up menu items are within the navbar item list.
In order to separate them into buttons and place them on the right hand side of the navbar we’ll need to add another div class.
Navbar items all aligned left with login and sign up buttons added
In the code below you can see I’ve added the div class “text-end” and placed the buttons within that div. The code is deliberately placed underneath the navbar items in order for the buttons to align to the right.