List Nav
BsListNav is a component used for displaying a series of item and mainly used for navigation. It can contain an icon, nested items, and provides a consistent styling for organizing the items. But doesn't have the flexibility like BsListTile.
Overview
<bs-list-nav> is a component to create the navigation container and <bs-list-nav-item> is used to create the navigation menu. <bs-list-nav> needs to be placed inside <bs-list-view>, then use <bs-list-nav-item> to compose the navigation menus. The navigation menus created by <bs-list-nav-item> has consistent styling and meets the Material Design specifications.
INFO
- See BsIcon to learn more about how to apply Google Material Symbols to the
iconproperty. - Since Vue MDBootstrap v2.1.0, Google Material Icons are replaced with Google Material Symbols.
Styling
Custom Color
We can also make <bs-list-nav> to have different background color. To achieve this, just style the parent container with the desired background color then use local CSS variables to set the navigation's item color or use global CSS variables for consistent application UI color.
Outer padding
Additionally, we can also add predefined outer padding on the left or right side of the navigation menus. To create the padding, sets the space-around property of the <bs-list-view> component with value: left, right or both.
Item border
We can also give a border to the active navigation's menu. To achieve this, sets the item-border-variant property of <bs-list-view> component with value: left, right, left-right, top, bottom, or top-bottom.
Rounded style
Additionaly, we can also add additional style appearance to the navigation's menu. There are two built-in style appearance, which are: Rounded and Rounded Pill. To achieve this, sets the item-rounded property of <bs-list-view> explicitly to create rounded style, or item-rounded-pill to create rounded pill style to an active navigation menu.
Usage Example
The following are a collection of examples that demonstrate more advanced use of the <bs-list-nav>.
Nested navigation
To create nested navigation list, the child navigation list needs to be wrapped by <bs-list-nav> and placed inside current <bs-list-nav-item>. Optionally, we can define the depth or indent property to customize the indentation from the left side.
Mixed with List Tile
<bs-list-nav> can also be mixed with <bs-list-tile> to display custom and fine tune navigation menus.
Inside Side Drawer
<bs-list-nav> can also be used inside <bs-side-drawer> to create side navigation menus.
CSS Variables
As CSS technology evolves, Vue MDBootstrap introduces local CSS variables and global CSS variables for better customization.
Updated in v2.2.0List View
.md-list {
--md-listview-bg: inherit;
--md-listview-color: var(--navigation-item-foreground);
--md-listview-item-gap: 0;
--md-listview-padding-x: 0;
--md-listview-padding-y: #{vars.$padding-sm};
--md-tile-minheight: 2.5rem;
--md-tile-action-minwidth: 1.5rem;
--md-tile-spacing-x: #{vars.$padding-sm};
--md-tile-spacing-y: 0.375rem;
--md-tile-padding-x: #{vars.$padding-md};
--md-tile-padding-y: #{vars.$padding-sm};
--md-tile-subtitle-font-size: #{math.div((vars.$font-size-base * 90), 100)};
--md-tile-title-font-size: var(--font-size-default);
--md-tile-title-font-weight: var(--font-weight-normal);
--md-tile-active-title-font-weight: var(--font-weight-medium);
--md-tile-disabled-opacity: var(--md-field-readonly-opacity);
--md-tile-indicator-border-color: var(--navigation-item-border-indicator);
--md-tile-indicator-border-width: 4px;
--md-nav-item-padding-x: #{vars.$padding-md};
--md-nav-item-padding-y: #{vars.$padding-xs};
--md-nav-item-line-height: normal;
--md-nav-item-font-size: var(--font-size-default);
--md-nav-item-font-weight: var(--font-weight-normal);
--md-nav-item-active-font-weight: var(--font-weight-medium);
--md-nav-item-disabled-opacity: var(--md-field-readonly-opacity);
}List Nav
.md-list-nav {
--md-nav-item-color: var(--navigation-item-foreground);
--md-nav-item-icon-color: var(--navigation-item-foreground-subtle);
--md-nav-item-divider-color: var(--border-translucent);
--md-nav-item-active-bg: var(--navigation-item-active-background);
--md-nav-item-active-color: var(--navigation-item-active-foreground);
--md-nav-item-active-icon-color: var(--navigation-item-active-foreground-secondary);
--md-nav-item-expanded-bg: var(--navigation-item-expanded-background);
--md-nav-item-hover-bg: var(--navigation-item-hover-background);
}:root {
--navigation-background: var(--background-secondary);
--navigation-item-foreground: var(--foreground);
--navigation-item-foreground-secondary: var(--foreground-subtle);
--navigation-item-foreground-subtle: var(--foreground-subtle-secondary);
--navigation-item-active-background: #{vars.$default-active-bgcolor};
--navigation-item-active-foreground: #{helper.to-oklch(
color.change(color.scale(vars.$default-active-bgcolor, $lightness: -10%), $alpha: 1)
)};
--navigation-item-active-foreground-secondary: #{helper.to-oklch(
color.change(color.scale(vars.$default-active-bgcolor, $lightness: -10%), $alpha: 0.75)
)};
--navigation-item-hover-background: #{vars.$default-hover-bgcolor};
--navigation-item-hover-foreground: var(--foreground);
--navigation-item-hover-foreground-secondary: #{colors.$gray-600};
--navigation-item-expanded-background: oklch(0 0 0 / 0.025);
--navigation-item-border-indicator: var(--md-field-active-indicator);
}SASS mixins
Sometimes, simply creating a new ListNav color variant can be overwhelming, as there are too many CSS variables to modify. For cases like this, Vue MDBootstrap provides SASS mixins to help you create new ListNav color variants.
use 'vue-mdbootstrap/scss/mixins/listview';
@include listview.make-listview-variant($name, $color);API Reference
BsListView
| Property | Type | Default | Description |
|---|---|---|---|
| color deprecated | String | ListView background color. Updated in v2.2.0 Use unified global CSS variables instead. | |
| individual-state | Boolean | false | The ListView doesn't manage each ListTile's state. v2.0.0 |
| item-rounded | Boolean | false | Apply rounded style to the BsListNavItem or BsListTile. v2.0.0 |
| item-rounded-pill | Boolean | false | Apply rounded pill style to the BsListNavItem or BsListTile. v2.0.0 |
| item-border-variant | String | Give border around the active item. Valid values are: left, right, left-right, top, bottom, top-bottom. v2.0.0 | |
| model-value v-model | IListItem | Property that hold the ListView's active item object instance. v2.0.0 | |
| overflow-hidden | Boolean | false | Apply css 'overflow-hidden' or not. |
| single-expand | Boolean | true | If false then more than one item can be expanded. Only applicable to BsListNav. |
| space-around | String | Give padding around each item. Valid values are: both, left, right. |
| Name | Arguments | Description |
|---|---|---|
| change | (value:IListItem, oldValue: IListItem) | Fired immediately when this component's mutate its model-value. v2.0.0 |
| update:model-value | (value:IListItem) | Fired when this component's model-value is updated. v2.0.0 |
| Name | Description |
|---|---|
| default | The outlet slot used to place the main content. |
BsListNav
| Property | Type | Default | Description |
|---|---|---|---|
| child | Boolean | false | Treat the ListNav as child Navigation menus. |
| Name | Description |
|---|---|
| default | The outlet slot used to place the main content. |
BsListNavItem
| Property | Type | Default | Description |
|---|---|---|---|
| active v-model | Boolean | false | Component state and monitored by v-model. |
| active-class | String | 'active' | <router-link> property, configure the active CSS class applied when the link is active. Typically you will want to set this to class name active. |
| badge | String | The text to render as badge label. | |
| badge-color | String | The badge color appearance. v2.0.0 | |
| badge-type | String | Create Badge with pill or label style. v2.0.0 | |
| badge-variant | String | The badge variant, valid values: primary, secondary, success, danger, warning, info, light, dark. | |
| border-off | Boolean | false | Remove border style that have been applied via BsListView to this BsListNavItem. v2.0.0 |
| depth | Number | Item depth level in tree hierarchy (zero based level). | |
| disabled | Boolean | false | Component state. |
| icon | String | Icon to display inside the component. Updated in v2.1.0 Use any valid android icon name from Google Material Symbols with or without a suffix. Valid suffixes are: icon-variant property. | |
| icon-flip | String | Flip the icon, valid values are: horizontal, vertical, both. | |
| icon-pulse | Boolean | false | Apply pulse animation to the icon. |
| icon-rotation | Number | Rotate the icon, valid values are: 90, 180, 270. | |
| icon-size | Number|String | Render the icon at predefined size in pixel. | |
| icon-spin | Boolean | false | Apply spin animation to the icon. |
| icon-variant | String | 'outlined' | Use predefined icon style variant. Valid values are: outlined, rounded, sharp, filled, outlined_filled, rounded_filled, and sharp_filled. v2.1.0 |
| id | String | Sets the component ID. This property value is auto generate. v2.0.0 | |
| indent | Number | Text indentation from left side. | |
| label required | String | The text label to display. | |
| location | RouteLocationAsRelativeGeneric | The navigation location target. v2.0.11 The value must be an object that satisfies the to property of the <RouterLink> component.This is a shortcut to create a <RouterLink> inside the component. See vue-router for more information. | |
| path | String | The route path for the navigation target. This is a shortcut to create a <RouterLink> inside the component. See vue-router for more information. | |
| path-name | String | The path name for the navigation target. v2.0.11 This is a shortcut to create a <RouterLink> inside the component. See vue-router for more information. | |
| pill-off | Boolean | false | Remove rounded pill style that have been applied via BsListView to this BsListNavItem. v2.0.0 |
| ripple-off | Boolean | false | Disabled ripple effect. |
| rounded-off | Boolean | false | Remove rounded style that have been applied via BsListView to this BsListNavItem. v2.0.0 |
| url | String | Absolute or relative URL for the navigation target, when vue-router doesn't exists. |
| Name | Arguments | Description |
|---|---|---|
| click | (evt:Event) | Fired when a non-disabled ListNavItem is clicked. |
| update:active | (value:Boolean) | Fired when this component's state is updated. v2.0.0 |
| Name | Description |
|---|---|
| default | The outlet slot used to place the child navigation. |
