Building Responsive Websites with Ant Design and Vue 3

Getting Started

To get started, you’ll need to create a new Vue 3 app and install the ant-design-vue package. You can do this by running the following commands:


npm install @vue/cli -g
vue create my-app
cd my-app
npm install ant-design-vue

Registering Ant Design

Once you’ve installed the ant-design-vue package, you’ll need to register it in your Vue 3 app. You can do this by updating the src/main.js file with the following code:


import { createApp } from 'vue'
import App from './App.vue'
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';

createApp(App).use(Antd).mount('#app')

Using Ant Design Components

Ant Design provides a wide range of components that you can use to build your application. Here’s an example of how to use the Button component:


<a-button type="primary">Primary Button</a-button>

Form Handling

Ant Design also provides a powerful form handling system. Here’s an example of how to use it:


<a-form :model="formState" name="basic" autocomplete="off" @finish="onFinish" @finishFailed="onFinishFailed">
  <a-form-item name="username" label="Username" :rules="[{ required: true, message: 'Please input your username!' },]>
    <a-input v-model:value="formState.username" />
  </a-form-item>

  <a-form-item name="password" label="Password" :rules="[{ required: true, message: 'Please input your password!' },]>
    <a-input-password v-model:value="formState.password" />
  </a-form-item>

  <a-form-item name="remember" class="login-remember">
    <a-checkbox v-model:checked="formState.remember">Remember me</a-checkbox>
  </a-form-item>

  <a-form-item class="login-submit">
    <a-button type="primary" html-type="submit">Submit</a-button>
  </a-form-item>
</a-form>

Using Ant Design Icons

Ant Design also provides a wide range of icons that you can use in your application. Here’s an example of how to use the Rocket icon:


<rocket-icon />

Leave a Reply

Your email address will not be published. Required fields are marked *