Skip to content

ActionBar - Vant 4

ActionBar

🚀 Create powerful bottom action bars that make user interactions a breeze!

Intro

The ActionBar component is your go-to solution for creating sleek, interactive bottom navigation bars! Perfect for e-commerce apps, social platforms, or any mobile interface where you need quick access to key actions. Think of it as your app's command center - always within thumb's reach! 📱✨

Install

Ready to add some action to your app? Let's get the ActionBar components registered! Simply use app.use() to make them available throughout your application. For more creative registration methods, check out our Component Registration guide! 🎯

js
import { createApp } from'vue'; import { ActionBar, ActionBarIcon, ActionBarButton } from'vant'; const app = createApp(); app.use(ActionBar); app.use(ActionBarIcon); app.use(ActionBarButton);

Usage

Basic Usage - Your First Action Bar! 🎉

Let's create a simple yet powerful action bar with icons and buttons. This example shows you how easy it is to build an interactive bottom navigation that users will love!

html
js
import { showToast } from'vant'; exportdefault { setup() { constonClickIcon = () => showToast('Click Icon'); constonClickButton = () => showToast('Click Button'); return { onClickIcon, onClickButton, }; }, };

Icon Badge - Grab Attention! 🔴

Want to notify users about new messages or updates? Use the badge prop to add eye-catching badges to your icons. Perfect for shopping carts, notifications, or any count that matters!

html

Custom Icon Color - Make It Yours! 🎨

Express your brand personality by customizing icon colors. Whether you want subtle grays or vibrant brand colors, it's just a prop away!

html

Custom Button Color - Stand Out! ✨

Make your call-to-action buttons impossible to ignore with custom colors. Support for gradients means your buttons can be as stunning as your imagination!

html

API

ActionBar Props

AttributeDescriptionTypeDefault
safe-area-inset-bottomWhether to enable bottom safe area adaptationbooleantrue
placeholderWhether to generate a placeholder elementbooleanfalse

ActionBarIcon Props

AttributeDescriptionTypeDefault
textButton textstring-
iconIconstring-
colorIcon colorstring#323233

| icon-class | Icon class name | string | Array | object | '' | | icon-prefix | Icon className prefix | string | van-icon | | dot | Whether to show red dot | boolean | - | | badge | Content of the badge | number | string | - | | badge-props | Props of Badge, see Badge - props | BadgeProps | - |

| url | Link URL | string | - | | to | The target route should navigate to when clicked on, same as the to prop of Vue Router | string | object | - |

| replace | If true, the navigation will not leave a history record | boolean | false |

ActionBarButton Props

AttributeDescriptionTypeDefault
textButton textstring-
typeButton type, Can be set to default``primary``success``warning``dangerstringdefault
colorButton color, support linear-gradientstring-
iconLeft Iconstring-
disabledWhether to disable buttonbooleanfalse
loadingWhether to show loading statusbooleanfalse
urlLinkstring-
toThe target route should navigate to when clicked on, same as the to prop of Vue Router*stringobject*

| replace | If true, the navigation will not leave a history record | boolean | false |

ActionBarIcon Slots

NameDescription
defaultText
iconCustom icon

ActionBarButton Slots

NameDescription
defaultButton content

Types

The component exports the following type definitions:

ts
importtype { ActionBarProps, ActionBarIconProps, ActionBarButtonProps, } from'vant';

Theming

CSS Variables

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

NameDefault ValueDescription
--van-action-bar-backgroundvar(--van-background-2)-
--van-action-bar-height50px-
--van-action-bar-icon-width48px-
--van-action-bar-icon-height100%-
--van-action-bar-icon-colorvar(--van-text-color)-
--van-action-bar-icon-size18px-
--van-action-bar-icon-font-sizevar(--van-font-size-xs)-
--van-action-bar-icon-active-colorvar(--van-active-color)-
--van-action-bar-icon-text-colorvar(--van-text-color)-
--van-action-bar-icon-backgroundvar(--van-background-2)-
--van-action-bar-button-height40px-
--van-action-bar-button-warning-colorvar(--van-gradient-orange)-
--van-action-bar-button-danger-colorvar(--van-gradient-red)-

Explore more components and features to enhance your mobile app experience:

  • Button - Learn about button components and styling options
  • Badge - Master badge components for notifications and counts
  • Icon - Discover the complete icon library and usage
  • ConfigProvider - Customize themes and global configurations
  • Advanced Usage - Component registration and advanced techniques
  • Vant 4 Overview - Explore all Vant 4 features and components

Enterprise-level mobile solution based on Vant