element-plus-formkitelement-plus-formkit
  • 中文
  • English
  • 中文
  • English
  • Quick Start
  • Formkit API
  • Config API
  • Modules
  • Expose
  • Slot
  • Basic Demo
  • Extension Methods

Modules

The form components that make up the FormKit system are listed below. If these modules are not what you expect, you can also customize the modules using registerModule.

cascader

Cascading Selectors

When a dataset has a clear hierarchical structure, cascading selectors can be used to view and select items level by level.

Cascading Selectors
Template
<formkit
    :config="[
        {
            type: 'cascader',
            label: 'Cascading Selectors',
            key: 'cascaderValue',
            options: options,
            props: { placeholder: 'Please select data', clearable: true }
        }
    ]"
    v-model="dataset">
</formkit>
TypeScript
<script setup lang="ts">
import formkit from 'element-plus-formkit';
import { ref, computed } from 'vue';

const dataset = ref({})

const options = ref([
  {
    value: 'guide',
    label: 'Guide',
    children: [
      {
        value: 'disciplines',
        label: 'Disciplines',
        children: [
          { value: 'consistency', label: 'Consistency' },
          { value: 'feedback', label: 'Feedback' },
          { value: 'efficiency', label: 'Efficiency' },
          { value: 'controllability', label: 'Controllability' }
        ]
      }
    ]
  }
])
</script>

Tips

Native Element Plus ElCascader API Please write it in the props field.

input

Input field

Name
<formkit
    :config="[
        {
            type: 'input',
            label: 'Name',
            key: 'password',
            props: { placeholder: 'Please enter your name.', clearable: true }
        }
    ]"
    v-model="dataset">
</formkit>

Tips

Native Element Plus Input API Please write in the props field.

switch

Indicates switching between two mutually exclusive states, commonly used to trigger “on/off” functions.

Switch
Multiple contents
<formkit
    :config="[
        {
            type: 'switch',
            label: 'Switch',
            key: 'switchValue',
            props: {
                inlinePrompt: true,
                activeText: 'Display multiple pieces of content in full',
                inactiveText: 'Multiple contents'
            }
        }
    ]"
    v-model="dataset">
</formkit>

Tips

Native Element Plus ElSwitch API Please write it in the props field.

select

Select field, when there are too many options, a dropdown menu is used to display and select the content.

Selector
Please select.
<formkit
    :config="[
        {
            type: 'select',
            label: 'Selector',
            key: 'select1',
            props: { placeholder: 'Please select.', clearable: true },
            options: [
                { name: 'Option one', id: 1 },
                { name: 'Option two', id: 2 },
                { name: 'Option three', id: 3 }
            ]
        }
    ]"
    v-model="dataset">
</formkit>

Select also supports dynamic loading of options through the requester field.

Selector
Please select.
Template
<formkit
    :config="[
        {
            type: 'select',
            label: 'Selector',
            key: 'select1',
            props: { placeholder: 'Please select.', clearable: true },
            requester: fetchOptions,
            handler: (response: any) => response?.items || []
        }
    ]"
    v-model="dataset">
</formkit>
TypeScript
<script setup lang="ts">
import formkit from 'element-plus-formkit';
import { ref, computed } from 'vue';

const dataset = ref({})

function fetchOptions() {
    return new Promise((r, j) => {
        setTimeout(() => {
           r({
            code: 200,
            items: [
                { name: 'Option one', id: 1 },
                { name: 'Option two', id: 2 },
                { name: 'Option three', id: 3 }
            ]
           })
        }, 2000)
    })
}
</script>

handler serves as an additional auxiliary field. It is invoked after the completion of the requester to process the requester's return value into a form executable by the ELselect option. Naturally, if your requester's return value already conforms to the ELselect option's expected type, its use is unnecessary.

checkbox

In a group of options, multiple items can be selected.

Checkbox
<formkit
    :config="[
        {
            type: 'checkbox',
            label: 'Checkbox',
            key: 'checkbox',
            options: [
                { name: 'Option one', id: 1 },
                { name: 'Option two', id: 2 },
                { name: 'Option three', id: 3 }
            ]
        }
    ]"
    v-model="dataset">
</formkit>

showAllCheck property is used to represent the indeterminate state of the checkbox, generally used to implement the effect of full selection.

Select All checkbox

output:

Template
<formkit
    :config="[
        {
            type: 'checkbox',
            label: 'Select All checkbox',
            key: 'checkbox',
            props: { showAllCheck: true },
            options: [
                { name: 'Option one', id: 1 },
                { name: 'Option two', id: 2 },
                { name: 'Option three', id: 3 }
            ]
        }
    ]"
    v-model="dataset">
</formkit>
Script
import formkit, { setConfigure } from 'element-plus-formkit';
import en from 'element-plus/es/locale/lang/en';
import { ref, computed } from 'vue';

const dataset = ref({})

setConfigure('lang', en);

Tips

Of course, when your options need to be obtained dynamically, you can still use the requester in conjunction with the handler to accomplish this. For details, refer to select requester.

radio

In a group of options, only one item can be selected.

Single-selection box

output:

<formkit
    :config="[
        {
            type: 'radio',
            label: 'Single-selection box',
            key: 'radio',
            options: [
                { name: 'Option one', id: 1 },
                { name: 'Option two', id: 2 },
                { name: 'Option three', id: 3 }
            ]
        }
    ]"
    v-model="dataset">
</formkit>

output: {{ dataset.radio }}

Tips

Of course, when your options need to be obtained dynamically, you can still use the requester in conjunction with the handler to accomplish this. For details, refer to select requester.

inputNumber

Number input box, only standard numeric values are allowed. You can define the range. For detailed API parameters, please refer to ElInputNumber API.

Stepping input box
PrefixSuffix

output:

<formkit
    :config="[
        {
            type: 'inputNumber',
            label: 'Stepping input box',
            key: 'inputNumber',
            props: {
                min: 0,
                max: 10,
                style: { width: '100%' },
                prefix: 'Prefix',
                suffix: 'Suffix'
            }
        }
    ]"
    v-model="dataset">
</formkit>

output: {{ dataset.inputNumber }}

Warning

When you need to use the ElInputNumber native API, you need to wrap it with props.

address

Has a hierarchical region address selector. Using this module requires passing in a requester as the data source.

Address selector
output:
<formkit
    :config="[
        {
            type: 'address',
            label: 'Address selector',
            key: 'address',
            props: {
                style: { width: '50%' },
                level: 2,
                placeholder: 'Please select an address',
                requester: (pid: number) => {
                    return fetchOptions()
                },
                handler: (response: any) => response?.items || []
            }
        }
    ]"
    v-model="dataset">
</formkit>
output: {{ dataset.address }}

Warning

Unlike select, checkbox, radio, etc. modules that need to dynamically get options, the requester of the address module needs to be wrapped with props.

popover

Text pop-up layer module selector

popover props parameter

Text pop-up layer
Please click to select
<formkit
    :config="[
        {
            type: 'popover',
            label: 'Text pop-up layer',
            key: 'popover',
            props: {
                placeholder: 'Please click to select',
                props: { multiple: true }
            },
            options: [
                { name: 'Option one', id: 1, children: [{ name: 'Option one-1', id: 11 }] },
                { name: 'Option two', id: 2 },
                { name: 'Option three', id: 3 }
            ]
        }
    ]"
    v-model="dataset">
</formkit>

Tips

Of course, when your options need to be obtained dynamically, you can still use the requester in conjunction with the handler to accomplish this. For details, refer to select requester.

remoteSearchSelect

Remote query selector with dropdown functionality.

Remote query selector
Please enter query content

Output remoteSearchSelect:

Output onChooseCallback:

<formkit
    :config="[
        {
            type: 'remoteSearchSelect',
            label: 'Remote query selector',
            key: 'remoteSearchSelect',
            props: {
                labelKey: 'name',
                valueKey: 'id',
                initialValue: null,
                placeholder: 'Please enter query content',
                requester: (searchName: string) => fetchOptions(),
                handler: (response: any) => response?.items || [],
                onChoose: (item: any) => dataset.onChooseCallback = item
            }
        }
    ]"
    v-model="dataset">
</formkit>

Typically, selectors for remotely loading data are difficult to control for default data handling. This is because backend data queries often require item.name, while data binding typically uses item.id. To address this, we introduce a new parameter (initialValue) for control. When the initialValue parameter is non-empty, we immediately pass it as an argument to the requester you provide after the component finishes loading.

rate

Rating selector

Rating
<formkit
    :config="[
        {
            type: 'rate',
            label: 'Rating',
            key: 'rate',
            props: { 'allow-half': false, colors: ['#F7BA2A', '#F7BA2A', '#F7BA2A'], size: 'large' }
        }
    ]"
    v-model="dataset">
</formkit>

Tips

Native Element Plus Rate API Please write it in the props field.

datePicker

Used for selecting or entering dates

Date Picker

Output: -

<formkit
    :config="[
        {
            type: 'datePicker',
            label: 'Date Picker',
            key: 'datePickerValue',
            props: { valueFormat: 'YYYY-MM-DD', placeholder: 'Click to select a date' }
        }
    ]"
    v-model="dataset">
</formkit>

<p>Output: {{ dataset.datePickerValue || "-" }}</p>

Tips

Native ElDatePicker APIPlease write inside the props.

timePicker

Time Selector

Used for selecting or entering dates

Time Selector

输出:-

<formkit
    :config="[
        {
            type: 'timePicker',
            label: 'Time Selector',
            key: 'timePickerValue',
            props: { placeholder: 'Click to select time' }
        }
    ]"
    v-model="dataset">
</formkit>

<p>Output: {{ dataset.timePickerValue || "-" }}</p>

Tips

Native ElDatePicker APIPlease write inside the props.

timeSelect

For selecting or entering dates

The available time range is 00:00-23:59

Time Selection
Click To Time Selection

Output: -

<formkit
    :config="[
        {
            type: 'timeSelect',
            label: 'Time Selection',
            key: 'timeSelectValue',
            props: { placeholder: 'Click To Time Selection', start: '08:30', end: '18:30' }
        }
    ]"
    v-model="dataset">
</formkit>

<p>Output: {{ dataset.timeSelectValue || "-" }}</p>

Tips

Native ElTimeSelect APIPlease write inside the props.

upload

Uploader

Click to upload files.

Uploader

The use of the uploader requires configuration.setConfigure upload

template
<formkit
    :config="[
        {
            type: 'upload',
            label: 'Uploader',
            key: 'uploadValue',
            props: {
                limit: 4,
                afterUpload: (response) => {
                    return response.data
                }
            }
        }
    ]"
    v-model="dataset">
</formkit>
typescript
<script setup lang="ts">
import formkit, { setConfigure } from 'element-plus-formkit';
import type { UploadRequesterOptions } from 'element-plus-formkit/types/formkit-types'
import { ref, computed } from 'vue';

const dataset = ref({})

setConfigure('upload', async (file: File, options: UploadRequesterOptions) => {
    const url = URL.createObjectURL(file)
    return new Promise((r, j) => {
        setTimeout(() => {
           r({
                code: 200,
                data: url || "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
           })
        }, 2000)
    })
})
</script>

slider

Slider selector

Select within a fixed range by dragging the slider.

Output: -

Slider selector
0°C
8°C
37°C
50%

<formkit
    :config="[
        {
            type: 'slider',
            label: 'Slider selector',
            key: 'sliderValue',
            props: {
                range: true,
                marks: {
                    0: '0°C',
                    8: '8°C',
                    37: '37°C',
                    50: {
                        style: {
                        color: '#1989FA',
                        },
                        label: '50%',
                    }
                }
            }
        }
    ]"
    v-model="dataset">
</formkit>

Tips

Native ElSlider APIPlease write inside the props.

treeSelect

A tree selector with dropdown menus, combining the functionality of the el-tree and el-select components.

Time Selection
Select

Output: -

<formkit
    :config="[
        {
            type: 'treeSelect',
            label: 'Time Selection',
            key: 'timeSelectValue',
            props: {
                'render-after-expand': false,
                style: { width: '240px' },
                data: [
                    {
                        value: '1',
                        label: 'Level one 1',
                        children: [
                            {
                                value: '1-1',
                                label: 'Level two 1-1',
                                children: [
                                    {
                                        value: '1-1-1',
                                        label: 'Level three 1-1-1'
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        value: '2',
                        label: 'Level one 2',
                        children: [
                            {
                                value: '2-1',
                                label: 'Level two 2-1',
                                children: [
                                    {
                                        value: '2-1-1',
                                        label: 'Level three 2-1-1'
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        value: '3',
                        label: 'Level one 3',
                        children: [
                            {
                                value: '3-1',
                                label: 'Level two 3-1',
                                children: [
                                    {
                                        value: '3-1-1',
                                        label: 'Level three 3-1-1'
                                    }
                                ]
                            },
                            {
                                value: '3-2',
                                label: 'Level two 3-2',
                                children: [
                                    {
                                        value: '3-2-1',
                                        label: 'Level three 3-2-1'
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        }
    ]"
    v-model="dataset">
</formkit>

<p>Output: {{ dataset.timeSelectValue || "-" }}</p>

Tips

Native ElTreeSelect APIPlease write inside the props.

Last Updated:: 1/14/26, 7:28 AM
Contributors: NicolasHome, wangyueyue
Prev
Config API
Next
Expose