This is a discussion that started on the Foundry Forum as a side-step to another discussion, but I’m continuing it here as it’s not really Foundry-centric. It does use some Foundry stacks, although it could easily use any other.
I started a new project this week which had a very sepecific requirement for the nav bar. I’m building the project in Foundry as I need to use Alloy, but Foundry didn’t really have the menu setup I needed, so I figured I’d make my own.
This is a demo of it: Pre-built projects for Rapidweaver
The version I’m making for the project is a little more complex, in terms of items in the nav bar, but for the purpose of this discussion the simpler one will suffice.
How it’s made…
- Elixirs Flux CSS grid stack does the column stuff. With a grid item each for the logo, header, links in the middle, the button and finally the mobile menu.
- The Logo is just a Foundry Icon stack.
- The header is just a regular header stack.
- The links are Foundry Button Group stack.
- The button is a Foundry Button stack.
- The mobile menu is Tav’s PopDrop Menu with another Foundry Button Group inside the dropdown.
It’s really all simple stuff. The hardest bit was getting the grid items in Flux set to the right widths for each breakpoint. But that was just a few minutes trail and error session.
In terms of layout, content and how it behaves at various screen widths it all works perfectly. And in terms of code weight, it’s actually the same as many navbar stacks, give or take 20kbs. (I tested it against quite a few).
The pros… Well, they are pretty obvious: You have complete and utter control over what to put in the menu and how it works at different breakpoints. Nice! But what about the cons?
I’ve seen it written on many a forum post that making using a homemade navbar is a bad idea. And so despite me making a load of them over the years (I’m a bit obsessed with navbars!) I’ve never used one on a live site. But I don’t really know why!
I did ask over on the Foundry forum if using this sort of homemade nav bar was a bad idea, and Adam said…
This is definitely a generalization, but navigation is nothing more than linked unordered lists, often in a columnized layout of some sort. The thing some might cringe at is making sure the markup is correct. Generally you want to have a
<nav>
element surrounding the navigation as a whole indicating that the content within is some sort of site navigation. Is this 100% necessary though? No.
This was an interesting point, and one I’d never considered. Clearly, given the elements the homemade navbar is made of, there are going to be no <nav>
tags. So to keep things right I’m guessing they need to be added, somehow.
So really, I’d like to get the views of some of the folk here about this idea. Not so much whether to use <nav>
tags or not, but if there are any other cons to this idea? I can see none. But perhaps I’m missing something?
And on the subject of the <nav>
, if they are going to be added, to what elements? To the whole thing? Or just the navigation elements (buttons etc.)?