The header is the primary navigation of your page.
A header consists of the following elements:
.header
as container for everything. This should be a <header>
element for semantic reasons.
.header--container
that is either centered or not (with or without .container
). This contains all header items, in this order:
.header--brand
), which contains the brand name and information for the current site, in this order:
a.header--instance-name
)a.header--site-name
).header--menu
), which contains the menu items of the header:
a.header--item
).header--separator
)a.header--item.is-complex.is-mobile-menu
), with
.header--menu-bars
), with exactly three, empty <span>
elementsa.header--item.is-complex
), with either
.header--item-image
), or.header--item-icon
)Furthermore any header item can have one .header--alert
notification with one number in it. All header items with images can have one .header--trust-level
to indicate a "trust level" or other level/permission of the currently logged in user.
Header items that link to the currently shown page should be highlighted with the class .is-active
.
By default, all header menu items, except for the mobile bars menu, disappear at small screen sizes. You can "save" them, by adding the class .is-visible-on-mobile
.
<header class="header">
<div class="container header--container">
<div class="header--brand">
<a class="header--instance-name" href="#">Codidact</a>
<a class="header--site-name" href="#">Gibberish</a>
</div>
<div class="header--menu">
<a class="header--item" href="#">question</a>
<a class="header--item is-active" href="#">tags</a>
<a class="header--item" href="#">users</a>
<div class="header--separator"></div>
<a class="header--item" href="#"><span class="header--alert">1</span>mod</a>
<a class="header--item" href="#">help</a>
<a class="header--item" href="#">discussions</a>
<a class="header--item is-mobile-menu is-complex" href="#!">
<span class="header--menu-bars">
<span></span>
<span></span>
<span></span>
</span>
</a>
<a class="header--item is-visible-on-mobile is-complex" href="#">
<img src="https://placekitten.com/100/100" class="header--item-image" alt="..." />
<span class="header--alert">1</span>
<span class="header--trust-level">5</span>
</a>
</div>
</div>
</header>
You can also add a background color:
<header class="header h-bg-yellow-050">
<div class="container header--container">
<div class="header--brand">
<a class="header--instance-name" href="#">Codidact</a>
<a class="header--site-name" href="#">Gibberish</a>
</div>
<div class="header--menu">
<a class="header--item" href="#">question</a>
<a class="header--item is-active" href="#">tags</a>
<a class="header--item" href="#">users</a>
<div class="header--separator"></div>
<a class="header--item" href="#"><span class="header--alert">1</span>mod</a>
<a class="header--item" href="#">help</a>
<a class="header--item" href="#">discussions</a>
<a class="header--item is-mobile-menu is-complex" href="#!">
<span class="header--menu-bars">
<span></span>
<span></span>
<span></span>
</span>
</a>
<a class="header--item is-visible-on-mobile is-complex" href="#">
<img src="https://placekitten.com/100/100" class="header--item-image" alt="..." />
<span class="header--alert">1</span>
<span class="header--trust-level">5</span>
</a>
</div>
</div>
</header>
If you want a darker background, you will also need to add .is-dark
to the header
<header class="header is-dark h-bg-green-700">
<div class="container header--container">
<div class="header--brand">
<a class="header--instance-name" href="#">Codidact</a>
<a class="header--site-name" href="#">Gibberish</a>
</div>
<div class="header--menu">
<a class="header--item" href="#">question</a>
<a class="header--item is-active" href="#">tags</a>
<a class="header--item" href="#">users</a>
<div class="header--separator"></div>
<a class="header--item" href="#"><span class="header--alert">1</span>mod</a>
<a class="header--item" href="#">help</a>
<a class="header--item" href="#">discussions</a>
<a class="header--item is-mobile-menu is-complex" href="#!">
<span class="header--menu-bars">
<span></span>
<span></span>
<span></span>
</span>
</a>
<a class="header--item is-visible-on-mobile is-complex" href="#">
<img src="https://placekitten.com/100/100" class="header--item-image" alt="..." />
<span class="header--alert">1</span>
<span class="header--trust-level">5</span>
</a>
</div>
</div>
</header>
If your header has only a brand site name and some simple menu items, you can have a small header by adding .is-small
. This can be combined with other modifiers
<header class="header is-small h-bg-tertiary-800 is-dark">
<div class="container header--container">
<div class="header--brand">
<a class="header--site-name" href="#">Gibberish</a>
</div>
<div class="header--menu">
<a class="header--item" href="#">question</a>
<a class="header--item is-active" href="#">tags</a>
<a class="header--item" href="#">users</a>
<div class="header--separator"></div>
<a class="header--item" href="#">help</a>
<a class="header--item is-mobile-menu is-complex" href="#!">
<span class="header--menu-bars">
<span></span>
<span></span>
<span></span>
</span>
</a>
</div>
</div>
</header>
Header slides are a supplementary component to headers. They allow for drop down and mobile menus.
Header slides have the .header-slide
class. You can also make large header slides with .is-large
If you plan to use a header slide as mobile menu, you should add all header items to it, that are removed from normal view and use a Menu component.
<div class="header-slide is-active">
<div class="menu">
<a class="menu--item" href="#">question</a>
<a class="menu--item is-active" href="#">tags</a>
<a class="menu--item" href="#">users</a>
<a class="menu--item" href="#">mod<span class="badge is-status"></span></a>
<a class="menu--item" href="#">help</a>
<a class="menu--item" href="#">discussions</a>
</div>
</div>
<div class="header-slide is-large is-active">
<h3 class="h-m-0 h-m-b-1">Search this site</h3>
<div class="grid is-nowrap">
<input class="form-element">
<div class="h-m-1">
<button class="button is-filled">
<i class="fa fa-search"></i>
</button>
</div>
</div>
</div>
Co-Design provides standard JavaScript to position the header slides. Give your slide an id or an unique class and give the trigger the attribute data-header-slide="[query]"
, where the query is a CSS selector for the slide.
<header class="header is-small h-bg-red-800 is-dark">
<div class="container header--container">
<div class="header--brand">
<a class="header--site-name" href="#">Gibberish</a>
</div>
<div class="header--menu">
<div class="header--separator"></div>
<a class="header--item is-visible-on-mobile" href="#" data-header-slide="#example-header-slide-large">Search</a>
<a class="header--item is-visible-on-mobile" href="#" data-header-slide="#example-header-slide">Open Slide</a>
</a>
</div>
</div>
</header>
<div class="header-slide" id="example-header-slide">
<p>Hello World!</p>
</div>
<div class="header-slide is-large" id="example-header-slide-large">
<h3 class="h-m-0 h-m-b-1">Search this site</h3>
<div class="grid is-nowrap">
<input class="form-element">
<div class="h-m-1">
<button class="button is-filled">
<i class="fa fa-search"></i>
</button>
</div>
</div>
</div>