Skip to content

ContactCard - Vant 4

ContactCard

Intro

Display contact information in the form of cards.

Install

Register component globally via app.use, refer to Component Registration for more registration ways.

js
import { createApp } from'vue'; import { ContactCard } from'vant'; const app = createApp(); app.use(ContactCard);

Usage

Add Contact

html
js
import { showToast } from'vant'; exportdefault { setup() { constonAdd = () => showToast('add'); return { onAdd, }; }, };

Edit Contact

html
js
import { ref } from'vue'; import { showToast } from'vant'; exportdefault { setup() { const tel = ref('13000000000'); const name = ref('John Snow'); constonEdit = () => showToast('edit'); return { tel, name, onEdit, }; }, };

Uneditable

html

API

Props

AttributeDescriptionTypeDefault
typeCan be set to editstringadd
nameNamestring-
telPhonestring-
add-textAdd card textstringAdd contact info
editableWhether to allow editing of contactsbooleantrue

Events

EventDescriptionArguments
clickEmitted when component is clickedevent: MouseEvent

Types

The component exports the following type definitions:

ts
importtype { ContactCardType, ContactCardProps } 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-contact-card-paddingvar(--van-padding-md)-
--van-contact-card-add-icon-size40px-
--van-contact-card-add-icon-colorvar(--van-primary-color)-
--van-contact-card-title-line-heightvar(--van-line-height-md)-

Enterprise-level mobile solution based on Vant