Skip to content
Focsd homeFocsd homeFocsd
Forms

Bottom navigation

A bar of three to five top-level destinations along the bottom of a phone screen.

  • Tag: focsd-bottom-nav
  • Pattern: Navigation landmark (links)
  • Category: Navigation

Example

HTML
<focsd-bottom-nav position="static" hide-above="0" label="Main">
<focsd-bottom-nav-item
href="#home"
icon="home"
label="Home"
current></focsd-bottom-nav-item>
<focsd-bottom-nav-item
href="#search"
icon="search"
label="Search"></focsd-bottom-nav-item>
<focsd-bottom-nav-item
href="#inbox"
icon="inbox"
label="Inbox"
badge="3"></focsd-bottom-nav-item>
<focsd-bottom-nav-item
href="#profile"
icon="user"
label="Profile"></focsd-bottom-nav-item>
</focsd-bottom-nav>

Usage

Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.

<script type="module">
import '@focsd-dev/components/focsd-bottom-nav.js';
</script>
<focsd-bottom-nav position="static" hide-above="0" label="Main">…</focsd-bottom-nav>

API

Attributes

AttributePropertyTypeDefault
labellabelstring—
positionposition'fixed' | 'sticky' | 'static'fixed
hide-abovehideAbovenumberHIDE_ABOVE

Slots

SlotDescription
(default)The focsd-bottom-nav-item elements.

CSS parts

Style the inside of the component with ::part(), for example focsd-bottom-nav::part(nav).

PartDescription
navThe nav element.
listThe list element.

Accessibility

  • A navigation landmark named "Main" (set label for another name) holding real links. Open in a new tab, copy the address and modifier clicks all work, and without JavaScript each one still goes to its page.
  • The current item has aria-current="page", and is shown with a heavier label and a bar above it, so it is never only a color. In forced colors it gets an outline.
  • A badge joins the link's name, so a screen reader hears "Inbox, 3 new", not a bare 3. The visible badge is hidden from assistive technology.
  • Items are at least 48 px wide and tall. On a phone with a home indicator the bar pads itself by the safe-area inset.
  • Use three to five items. Fewer or more logs a warning, because more than five crowds the targets.
  • It shows below 768 px by default and hides on wider screens (hide-above, in px; 0 never hides). Give wider screens a sidebar or a header navigation instead.
  • Fixed to the bottom by default, the element keeps the bar's height in the page, so the last of your content is never covered. position="sticky" and "static" are the alternatives.
  • Place the bar last in the page, after all other content. Placed first, the space it keeps is at the top and the bar covers the last content.
  • A fixed bar covers what scrolls under it, so a focused element could end up hidden behind it (WCAG 2.4.11). Set scroll-padding-block-end on html to the bar's height: calc(var(--focsd-bottom-nav-height, 4rem) + env(safe-area-inset-bottom)). The component cannot set it from inside its shadow root.
  • To use a client-side router, register it once with setLinkHandler, as in the router recipes.

Keyboard

KeyAction
TabMove between the links
EnterFollow the focused link