Skip to main content

Sidebar widgets

Sidebar widgets are flexible containers that provide a lot of patterns that are helpful in a variety of sidebar uses.

In its simplest form, .s-sidebarwidget is comprised of a .s-sidebarwidget--content section and optional .s-sidebarwidget--header and .s-sidebarwidget--footer sections. Together these classes create a widget with appropriate inner spacing for you to put whatever you want into it.

By default the content is a flex container. If you require display: block instead, add the d-block class.
<div class="s-sidebarwidget">
<div class="s-sidebarwidget--header">
<h2></h2>
<a class="s-sidebarwidget--action"></a>
</div>
<div class="s-sidebarwidget--content">

<button class="s-btn s-btn__tonal s-sidebarwidget--action"></button>
</div>
<div class="s-sidebarwidget--footer">
<button class="s-btn s-btn__tonal s-sidebarwidget--action"></button>
</div>
</div>

Community Achievements

Track
You’ve earned 3 new badges this week! Keep contributing to unlock more achievements and privileges within the community.
The examples of s-sidebarwidget--header are shown with h2 elements, but the appropriate heading level may differ depending on context. Please use the appropriate heading level for your context to ensure heading levels only increase by 1.

If different sections are required within the body of the sidebar you may use multiple s-sidebarwidget--content elements which will space things appropriately.

<div class="s-sidebarwidget">
<div class="s-sidebarwidget--content">
<img src="…" class="bar-md mr8">
<div class="lh4">
<strong>balpha</strong><br>
contributed 6 edits<br>
joined 8 months ago
</div>
</div>
<div class="s-sidebarwidget--content">
<img src="…" class="bar-md mr8">
<div class="lh4">
<strong>Paweł</strong><br>
contributed 7 edits<br>
joined 1 year 10 months ago
</div>
</div>
<div class="s-sidebarwidget--content">
<img src="…" class="bar-md mr8">
<div class="lh4">
<strong>Aaron Shekey</strong><br>
contributed 3 edits<br>
joined 5 months ago
</div>
</div>
</div>
demo avatar
balpha
contributed 6 edits
joined 8 months ago
demo avatar
Paweł
contributed 7 edits
joined 1 year 10 months ago
demo avatar
Aaron Shekey
contributed 3 edits
joined 5 months ago

Three modifier classes are available for changing the background color of an s-sidebarwidget: s-sidebarwidget__yellow, s-sidebarwidget__blue, and s-sidebarwidget__green.

<div class="s-sidebarwidget s-sidebarwidget__yellow"></div>
<div class="s-sidebarwidget s-sidebarwidget__green"></div>
<div class="s-sidebarwidget s-sidebarwidget__blue"></div>

A common use for sidebar widgets is as a navigation block or table of contents, including a highlight of the page/section that the user is currently looking at.

The recommended pattern, as shown in the example below, is to make the s-sidebarwidget a nav element, and for each group of links to create a ul with the class s-sidebarwidget--items, within which each li is of class s-sidebarwidget--item.

The currently active navigation item should have the aria-current attribute set to "page" (if it is a direct link to the very page that the user is looking at) or "true" (in all other cases, e.g. if it is a link to a page that is conceptually a parent or the current page). This aria-current attribute should be placed on the a element.

<nav class="s-sidebarwidget">
<div class="s-sidebarwidget--header">
<h2 class="fs-subheading">
Personal Information
</h2>
</div>
<div class="s-sidebarwidget--content">
<ul class="s-sidebarwidget--items">
<li class="s-sidebarwidget--item">
<a href="…">
Edit Profile
</a>
</li>
<li class="s-sidebarwidget--item">
<a href="…" aria-current="page">
Developer Story Preferences
</a>
</li>
<li class="s-sidebarwidget--item">
<a href="…">
Job Match Preferences
</a>
</li>
</ul>
</div>
<div class="s-sidebarwidget--header">
<h2 class="fs-subheading">
Site Settings
</h2>
</div>
<div class="s-sidebarwidget--content">
<ul class="s-sidebarwidget--items">
<li class="s-sidebarwidget--item">
<a href="…">Preferences</a>
</li>
<li class="s-sidebarwidget--item">
<a href="…">Flair</a>
</li>
</ul>
</div>
</nav>

If you have a second level of navigation, you can add a ul of class s-sidebarwidget--subnav to the top-level item. Highlighting the currently active navigation is a little more constrained in this case:

If the currently active top-level element has a subnavigation, the top-level aria-current must be on the a, not the li.

The currently active second-level element must have its aria-current on the li, not the a.

<nav class="s-sidebarwidget">
<div class="s-sidebarwidget--content">
<ul class="s-sidebarwidget--items">
<li class="s-sidebarwidget--item">
<a href="…">Asking</a>
</li>
<li class="s-sidebarwidget--item d-block">
<a href="…" aria-current="true">Our model</a>
<ul class="s-sidebarwidget--subnav">
<li>
<a href="…">Be nice</a>
</li>
<li aria-current="page">
<a href="…">What kind of behavior is expected of users?</a>
</li>
<li>
<a href="…">How do I find topics I’m interested in?</a>
</li>
</ul>
</li>
<li class="s-sidebarwidget--item">
<a href="…">Reputation &amp; Moderation</a>
</li>
<li class="s-sidebarwidget--item">
<a href="…">Answering</a>
</li>
</ul>
</div>
</nav>
How’d we do?
Anonymously upvote, downvote, or send additional feedback below.
Deploys by Netlify