Convert Figma logo to code with AI

youzan logovant

A lightweight, customizable Vue UI library for mobile web apps.

23,249
9,488
23,249
84

Top Related Projects

🎉 A Vue.js 3 UI Library made by Element team

An enterprise-class UI design language and React UI library

39,994

🐉 Vue Component Framework

26,050

Quasar Framework - Build high-performance VueJS user interfaces in record time

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.

Quick Overview

Vant is a lightweight, customizable mobile UI library for Vue.js. It provides a rich set of components and utilities for building mobile applications, focusing on performance and flexibility. Vant is widely used in production environments and supports both Vue 2 and Vue 3.

Pros

  • Comprehensive component library with 60+ UI components
  • Excellent performance and small bundle size
  • Supports custom themes and internationalization
  • Active development and community support

Cons

  • Primarily focused on mobile development, less suitable for desktop applications
  • Learning curve for developers new to Vue.js or mobile-first design
  • Some advanced customizations may require deeper knowledge of the library

Code Examples

  1. Basic Button Component:
<template>
  <van-button type="primary">Primary Button</van-button>
</template>

<script>
import { Button } from 'vant';

export default {
  components: {
    [Button.name]: Button,
  },
};
</script>
  1. Form with Input and Submit:
<template>
  <van-form @submit="onSubmit">
    <van-field
      v-model="username"
      name="username"
      label="Username"
      placeholder="Username"
      :rules="[{ required: true, message: 'Username is required' }]"
    />
    <van-field
      v-model="password"
      type="password"
      name="password"
      label="Password"
      placeholder="Password"
      :rules="[{ required: true, message: 'Password is required' }]"
    />
    <div style="margin: 16px;">
      <van-button round block type="primary" native-type="submit">
        Submit
      </van-button>
    </div>
  </van-form>
</template>

<script>
import { Form, Field, Button } from 'vant';

export default {
  components: {
    [Form.name]: Form,
    [Field.name]: Field,
    [Button.name]: Button,
  },
  data() {
    return {
      username: '',
      password: '',
    };
  },
  methods: {
    onSubmit(values) {
      console.log('submit', values);
    },
  },
};
</script>
  1. Dialog Component:
<template>
  <van-button type="primary" text="Show Dialog" @click="showDialog" />
</template>

<script>
import { Button, Dialog } from 'vant';

export default {
  components: {
    [Button.name]: Button,
  },
  methods: {
    showDialog() {
      Dialog.confirm({
        title: 'Confirm',
        message: 'Are you sure you want to proceed?',
      })
        .then(() => {
          console.log('Confirmed');
        })
        .catch(() => {
          console.log('Canceled');
        });
    },
  },
};
</script>

Getting Started

  1. Install Vant:
npm i vant
  1. Import and use components in your Vue file:
<template>
  <van-button type="primary">Button</van-button>
</template>

<script>
import { Button } from 'vant';

export default {
  components: {
    [Button.name]: Button,
  },
};
</script>
  1. (Optional) Import all components and styles globally in your main.js:
import { createApp } from 'vue';
import Vant from 'vant';
import 'vant/lib/index.css';
import App from './App.vue';

const app = createApp(App);
app.use(Vant);
app.mount('#app');

Competitor Comparisons

🎉 A Vue.js 3 UI Library made by Element team

Pros of Element Plus

  • More comprehensive component library with a wider range of UI elements
  • Better suited for complex, feature-rich enterprise applications
  • Stronger TypeScript support and integration

Cons of Element Plus

  • Larger bundle size, which may impact initial load times
  • Steeper learning curve due to its extensive API and options
  • Less mobile-friendly compared to Vant's mobile-first approach

Code Comparison

Element Plus example:

<template>
  <el-button type="primary" @click="handleClick">Click me</el-button>
</template>

<script>
import { ElButton } from 'element-plus'
</script>

Vant example:

<template>
  <van-button type="primary" @click="handleClick">Click me</van-button>
</template>

<script>
import { Button as VanButton } from 'vant'
</script>

Both libraries offer similar component usage, but Element Plus generally provides more customization options and props for each component. Vant's components are often simpler and more focused on mobile use cases.

Element Plus is better suited for large-scale, desktop-first applications with complex UI requirements, while Vant excels in mobile-first projects and lightweight applications. The choice between the two depends on the specific needs of your project, target devices, and desired level of customization.

An enterprise-class UI design language and React UI library

Pros of Ant Design

  • More comprehensive component library with a wider range of UI elements
  • Stronger ecosystem with extensive documentation and community support
  • Better internationalization support out of the box

Cons of Ant Design

  • Larger bundle size, which may impact performance for smaller projects
  • Steeper learning curve due to its extensive API and customization options
  • Less mobile-first approach compared to Vant

Code Comparison

Ant Design (Button component):

import { Button } from 'antd';

const MyComponent = () => (
  <Button type="primary">Click me</Button>
);

Vant (Button component):

import { Button } from 'vant';

const MyComponent = () => (
  <Button type="primary">Click me</Button>
);

Both libraries offer similar basic usage for components like buttons. However, Ant Design typically provides more props and customization options for each component, which can lead to more complex implementations for advanced use cases.

Ant Design is generally better suited for large-scale, feature-rich web applications, especially those requiring a wide variety of UI components and extensive customization. Vant, on the other hand, excels in mobile-first development and offers a more lightweight solution for simpler projects or those primarily targeting mobile devices.

39,994

🐉 Vue Component Framework

Pros of Vuetify

  • More comprehensive UI component library with a wider range of components
  • Follows Material Design guidelines, providing a consistent and modern look
  • Extensive documentation and active community support

Cons of Vuetify

  • Larger bundle size, which may impact initial load times
  • Steeper learning curve due to its extensive feature set
  • Less flexibility in customizing styles without overriding defaults

Code Comparison

Vant example:

<template>
  <van-button type="primary">Primary Button</van-button>
</template>

<script>
import { Button } from 'vant';

export default {
  components: { [Button.name]: Button },
};
</script>

Vuetify example:

<template>
  <v-btn color="primary">Primary Button</v-btn>
</template>

<script>
export default {
  // No additional setup required for basic usage
};
</script>

Both libraries offer easy-to-use components, but Vuetify generally requires less setup for basic usage. Vant's approach allows for more granular control over imported components, potentially resulting in smaller bundle sizes for simpler applications.

26,050

Quasar Framework - Build high-performance VueJS user interfaces in record time

Pros of Quasar

  • Comprehensive framework with support for multiple platforms (web, mobile, desktop)
  • Rich ecosystem with official Quasar CLI, extensions, and app templates
  • Extensive documentation and active community support

Cons of Quasar

  • Steeper learning curve due to its comprehensive nature
  • Larger bundle size compared to Vant's lightweight approach
  • Less focused on mobile-first design compared to Vant

Code Comparison

Quasar component usage:

<template>
  <q-btn color="primary" label="Click me" />
</template>

Vant component usage:

<template>
  <van-button type="primary">Click me</van-button>
</template>

Summary

Quasar is a more comprehensive framework suitable for multi-platform development, while Vant focuses on lightweight mobile UI components. Quasar offers a wider range of features and platform support but comes with a steeper learning curve. Vant provides a simpler, mobile-first approach with a smaller footprint. The choice between the two depends on project requirements, target platforms, and developer preferences.

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.

Pros of Ionic Framework

  • Cross-platform development: Supports iOS, Android, and web with a single codebase
  • Extensive UI components: Offers a rich set of pre-built, customizable components
  • Strong community support: Large user base and active development

Cons of Ionic Framework

  • Performance: Can be slower than native apps, especially for complex applications
  • Learning curve: Requires knowledge of Angular, React, or Vue.js
  • File size: Larger app size compared to native or lightweight alternatives

Code Comparison

Ionic Framework (Angular):

import { Component } from '@angular/core';

@Component({
  selector: 'app-home',
  template: '<ion-button>Click me</ion-button>'
})
export class HomeComponent {}

Vant:

<template>
  <van-button>Click me</van-button>
</template>

<script>
import { Button } from 'vant';

export default {
  components: { [Button.name]: Button }
}
</script>

Key Differences

  • Ionic Framework is a full-fledged cross-platform development solution, while Vant is primarily a UI component library for Vue.js
  • Ionic offers more extensive documentation and resources for building complete mobile applications
  • Vant has a smaller footprint and may be more suitable for lightweight, Vue-specific projects
  • Ionic provides a wider range of UI components and plugins for various mobile features

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.

Pros of Material-UI

  • More comprehensive component library with a wider range of UI elements
  • Stronger ecosystem with extensive documentation and community support
  • Better theming capabilities and customization options

Cons of Material-UI

  • Larger bundle size, which may impact performance for smaller projects
  • Steeper learning curve due to its extensive API and features
  • Less mobile-first approach compared to Vant's mobile-oriented design

Code Comparison

Material-UI:

import { Button, TextField } from '@material-ui/core';

<Button variant="contained" color="primary">
  Submit
</Button>
<TextField label="Username" variant="outlined" />

Vant:

import { Button, Field } from 'vant';

<Button type="primary">Submit</Button>
<Field label="Username" />

Summary

Material-UI offers a more comprehensive set of components and stronger ecosystem support, making it suitable for large-scale web applications. However, it comes with a larger bundle size and steeper learning curve. Vant, on the other hand, is more lightweight and mobile-focused, making it ideal for mobile web applications or projects with simpler UI requirements. The code comparison shows that both libraries offer similar basic components, but Material-UI provides more customization options out of the box.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

logo

Vant

A lightweight, customizable Vue UI library for mobile web apps.

npm version Coverage Status downloads

Documentation   ·   Documentation (backup)   ·   中文介绍


Features

  • 🚀 1KB Component average size (min+gzip)
  • 🚀 80+ High quality components
  • 🚀 Zero third-party dependencies
  • 💪 90%+ Unit test coverage
  • 💪 Written in TypeScript
  • 📖 Extensive documentation and demos
  • 📖 Provide Sketch and Axure design resources
  • 🍭 Support Vue 2 & Vue 3
  • 🍭 Support Nuxt 2 & Nuxt 3, provide Vant Module for Nuxt
  • 🍭 Support Tree Shaking
  • 🍭 Support Custom Theme
  • 🍭 Support Accessibility (still improving)
  • 🍭 Support Dark Mode
  • 🍭 Support SSR
  • 🌍 Support i18n, built-in 30+ languages

Install

Using npm to install:

# install latest Vant for Vue 3 project
npm i vant

# install Vant 2 for Vue 2 project
npm i vant@latest-v2

Using yarn, pnpm, or bun:

# with yarn
yarn add vant

# with pnpm
pnpm add vant

# with Bun
bun add vant

Scaffold

It is recommended to use Rsbuild to create a scaffold project.

Rsbuild is a build tool based on Rspack, developed by the author of Vant, with first-class build speed and development experience, providing first-priority support for Vant.

You can create a Rsbuild project with the following command:

npm create rsbuild@latest

Please visit the Rsbuild repository for more information.

Quickstart

import { createApp } from 'vue';
// 1. Import the components you need
import { Button } from 'vant';
// 2. Import the components style
import 'vant/lib/index.css';

const app = createApp();

// 3. Register the components you need
app.use(Button);

See more in Quickstart.

Browser Support

Vant 2 supports modern browsers and Android >= 4.0、iOS >= 8.0.

Vant 3/4 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3).

Official Ecosystem

ProjectDescription
vant-weappWeChat MiniProgram UI
vant-demoCollection of Vant demos
vant-cliScaffold for UI library
vant-iconsVant icons
vant-touch-emulatorUsing vant in desktop browsers
vant-nuxtVant module for Nuxt

Community Ecosystem

ProjectDescription
3lang3/react-vantReact mobile UI Components based on Vant
vant-aliappAlipay MiniProgram UI
vant-themeOnline theme preview built on Vant UI
@antmjs/vantuiMobile UI Components based on Vant, supporting Taro and React
TaroifyTaroify is the Taro version of Vant
vant-playgroundVant Playground
sfc-playground-vantVant Playground
vue3-h5-templateMobile project template based on Vant
vue3-vant-mobileMobile project template based on Vant
vscode-common-intellisenseA VS Code extension that provides better intellisense to Vant developers
nuxt-vant-mobileNuxt ⁴ project template based on Vant, out of the box

Links

Preview

You can scan the following QR code to access the demo:

Core Team

Core contributors of Vant and Vant Weapp:

chenjiahancookfrontw91pangxie1991rex-zsdnemo-shen
chenjiahancookfrontwangnaiyipangxierex-zsdnemo-shen
LindysenJakeLaoyulandluckwjw-gavininottnzhousg
LindysenJakeLaoyulandluckwjw-gavininottnzhousg

All Contributors

Thanks to the following friends for their contributions to Vant:

contributors

Contribution Guide

Please make sure to read the Contributing Guide before making a pull request.

Start On Web IDE

https://github.dev/youzan/vant

LICENSE

Vant is MIT licensed.

NPM DownloadsLast 30 Days