Search documentation v0.9.0

Bottom Navigation

Provide quick access to primary navigation items

Source ↗️ Report Issue ↗️

Use the BottomNavigation component to display a fixed menu with primary navigation elements at the bottom of your pages. Being fixed, they remain visible during scrolling and help users easily reach cornerstone content on your website.

Preview
How to use BottomNavigation in Astro
---
import { BottomNavigation } from 'webcoreui/astro'
const items = [
{
icon: 'home',
name: 'Home'
},
{
icon: 'components',
name: 'Components'
},
{
icon: 'github',
name: 'GitHub'
}
]
---
<BottomNavigation items={items} />
How to use BottomNavigation in Svelte
<script>
import { BottomNavigation } from 'webcoreui/svelte'
import { home, components, github } from 'webcoreui/icons'
const items = [
{
icon: home,
name: 'Home'
},
{
icon: components,
name: 'Components'
},
{
icon: github,
name: 'GitHub'
}
]
</script>
<BottomNavigation items={items} />
How to use BottomNavigation in React
import React from 'react'
import { BottomNavigation } from 'webcoreui/react'
import { home, components, github } from 'webcoreui/icons'
const items = [
{
icon: home,
name: 'Home'
},
{
icon: components,
name: 'Components'
},
{
icon: github,
name: 'GitHub'
}
]
const Component = () => (
<BottomNavigation items={items} />
)
export default Component

The BottomNavigation component expects an items prop that describes the navigation items. Each navigation item can have the following properties:

All properties are optional, meaning you can create the navigation with text or icons only:

Navigation with text only
Navigation with icons only

Tooltips

If you use icons only, you may want to provide additional context to users about your navigation items. For this, you can use the tooltip prop that adds a tooltip for the items:

Navigation items with tooltip
How to use tooltips
---
import { BottomNavigation } from 'webcoreui/astro'
const items = [
{
icon: 'home',
tooltip: 'Home'
},
{
icon: 'components',
tooltip: 'Components'
},
{
icon: 'github',
tooltip: 'GitHub'
}
]
---
<BottomNavigation items={items} />

Styles

The component also supports two different stylings. Use the separated prop to add borders between elements, and use the floating prop to make the element rounded and padded around the viewport:

Separated
Floating
You can also use the two props together
<BottomNavigation
items={items}
separated={true}
/>
You can also use the two props together
<BottomNavigation
items={items}
floating={true}
/>

Max width

In its default configuration, the navigation items will equally take up the available space of the viewport:

If you want to limit this, you can use the maxWidth prop which sets a maximum width for the container of the items:

Maximum width set to 400px
<BottomNavigation
items={items}
floating={true}
maxWidth="400px"
/>

You can also set this option globally through overriding the following CSS variable:

If you set the maximum width through CSS, there's no need for the maxWidth prop.
html body {
--w-bottom-navigation-max-width: 400px;
}

API

type BottomNavigationProps = {
items: {
name?: string
href?: string
target?: '_self'
| '_blank'
| '_parent'
| '_top'
| '_unfencedTop'
icon?: string
tooltip?: string
}[]
separated?: boolean
floating?: boolean
maxWidth?: string
className?: string
}
PropPurpose
items Sets the navigation items.
items.name Sets the name of the navigation item.
items.href Sets the link for the navigation item.
items.target Sets the target of the anchor.
items.icon Sets an icon for the navigation item.
items.tooltip Sets a tooltip for the navigation item.
separated Adds borders between the navigation items.
floating Adds paddings around the navigation.
maxWidth Sets the maximum width of the container of items.
className Pass additional CSS classes for the component.

Request improvement for this page