Gathering detailed insights and metrics for formkit-element
Gathering detailed insights and metrics for formkit-element
Gathering detailed insights and metrics for formkit-element
Gathering detailed insights and metrics for formkit-element
npm install formkit-element
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Element plus for FormKit.
Most of the components are based on Element plus, attributes directly pass to the element plus component.
1. This library require Element plus and FormKit to be installed.
If you are using nuxt, you can use FormKit nuxt module to install FormKit.
2. Create formkit.config.ts if using nuxt
1import { DefaultConfigOptions } from '@formkit/vue' 2import { createElementPlugin } from 'formkit-element' 3 4const config: DefaultConfigOptions = { 5 plugins: [createElementPlugin()] 6}
1const app = createApp(App); 2 3import { plugin, defaultConfig } from '@formkit/vue' 4import { createElementPlugin } from "formkit-element"; 5app.use(plugin, defaultConfig({ 6 plugins: [createElementPlugin()] 7}))
1 <FormKit type="form" v-model="data"> 2 3 <FormKit type="el-input" name="input4" label="el-input" validation="required" /> 4 5 <FormKit type="el-input" name="input5" label="el-input (placeholder)" validation="required" 6 placeholder="this is a placeholder" clearable /> 7 8 <FormKit type="el-password" name="password1" label="el-password" validation="required" show-password clearable placeholder="this is a password" /> 9 10 <FormKit type="el-textarea" name="textarea" label="el-textarea" placeholder="this is a textarea" /> 11 12 <FormKit type="el-select" name="select2" label="el-select" clearable :options="{ 13 mercury: 'Mercury', 14 venus: 'Venus', 15 earth: 'Earth', 16 mars: 'Mars', 17 jupiter: 'Jupiter', 18 saturn: 'Saturn', 19 uranus: 'Uranus', 20 neptune: 'Neptune' 21 }" /> 22 23 <FormKit type="el-select" name="select2" label="el-select (multiple)" :options="{ 24 mercury: 'Mercury', 25 venus: 'Venus', 26 earth: 'Earth', 27 mars: 'Mars', 28 jupiter: 'Jupiter', 29 saturn: 'Saturn', 30 uranus: 'Uranus', 31 neptune: 'Neptune' 32 }" multiple /> 33 34 <FormKit type="el-rate" name="rate2" label="el-rate" /> 35 36 <FormKit type="el-switch" name="switch3" label="el-switch" /> 37 38 <FormKit type="el-date-picker" name="date3" label="el-date-picker" /> 39 <FormKit type="el-time-picker" name="time2" label="el-time-picker" /> 40 <FormKit type="el-color-picker" name="color12" label="el-color-picker" /> 41 </FormKit>
When using attributes `form-item` the component will be wrapped in a el-form-item component.
1 <FormKit type="el-form" v-model="data" ref="elf" id="elform"> 2 <FormKit type="el-input" label="input3" name="input3" validation="required" placeholder="testing3" clearable form-item /> 3 4 <FormKit type="el-select" label="Select" name="select" :options="{ 5 mercury: 'Mercury', 6 venus: 'Venus', 7 earth: 'Earth', 8 mars: 'Mars', 9 jupiter: 'Jupiter', 10 saturn: 'Saturn', 11 uranus: 'Uranus', 12 neptune: 'Neptune', 13 }" 14 validation="required" clearable placeholder="select placeholder" filterable multiple form-item /> 15 16 <FormKit type="el-checkbox" label="Checkbox1" name="cb1" validation="required" form-item/> 17 18 <FormKit type="el-rate" label="Rate" name="rate1" form-item/> 19 <FormKit type="el-switch" label="Switch" name="switch1" form-item/> 20 <FormKit type="el-time-picker" label="Time Picker 1" name="time_picker_1" form-item/> 21 <FormKit type="el-input-number" label="input nubmer 1" name="input_number_1" form-item/> 22 23 <FormKit type="el-radio-group" label="Radio Group" name="radio1" :options="{ 24 mercury: 'Mercury', 25 venus: 'Venus', 26 earth: 'Earth', 27 mars: 'Mars', 28 jupiter: 'Jupiter', 29 saturn: 'Saturn', 30 uranus: 'Uranus', 31 neptune: 'Neptune', 32 }" validation="required" form-item/> 33 34 35 <FormKit type="el-slider" label="Slider1" name="slider1" /> 36 <FormKit type="el-slider" label="Slider2" name="slider2" :min="100" :max="200" :step="2" /> 37 38 <FormKit type="el-color-picker" label="ColorPicker" name="color1" /> 39 40 41 </FormKit>
1<FormKit type="form" v-model="data"> 2 <FormKit type="el-rate" label="elFormRate" name="rate" form-item/> 3 4 <FormKit type="el-rate" label="elRate" name="rate" help="help text" /> 5 6 <FormKit type="el-rate" label="elRate" name="rate" :texts="['oops', 'disappointed', 'normal', 'good', 'great']" 7 show-text /> 8 9 <FormKit type="el-rate" label="elRate (allow-half)" name="rate_half" allow-half /> 10</FormKit>
Custom template of select options
1<script setup> 2import { ref } from "vue"; 3const data = ref({}); 4 5const cities = [ 6 { 7 value: 'Beijing', 8 label: 'Beijing', 9 }, 10 { 11 value: 'Shanghai', 12 label: 'Shanghai', 13 }, 14 { 15 value: 'Nanjing', 16 label: 'Nanjing', 17 }, 18 { 19 value: 'Chengdu', 20 label: 'Chengdu', 21 }, 22 { 23 value: 'Shenzhen', 24 label: 'Shenzhen', 25 }, 26 { 27 value: 'Guangzhou', 28 label: 'Guangzhou', 29 }, 30] 31 32</script> 33<template> 34 <FormKit type="el-select" label="select (Custom template)" name="input1" :options="cities"> 35 <template #option="{ item }"> 36 <span style="float: left">{{ item.label }}</span> 37 <span style=" 38 float: right; 39 color: var(--el-text-color-secondary); 40 font-size: 13px; 41 ">{{ item.value }} 42 </span> 43 </template> 44 </FormKit> 45<template>
1<FormKit type="group" v-model="data"> 2 <FormKit type="el-date-picker" label="el-date-picker" name="date1" validation="required" /> 3 <FormKit type="el-date-range-picker" label="el-date-range-picker" name="date2" /> 4</FormKit>
1 <FormKit type="group" v-model="data"> 2 <FormKit type="el-switch" label="el-switch" name="switch1" /> 3 <FormKit type="el-switch" label="el-switch (size)" name="switch2" size="large" /> 4 <FormKit type="el-switch" name="swtich3" active-text="Pay by month" inactive-text="Pay by year" /> 5 </FormKit>
1<FormKit type="group" v-model="data"> 2 <FormKit type="el-time-picker" label="el-time-picker" name="time1" /> 3 <FormKit type="el-time-picker" label="el-time-picker (range)" name="time2" is-range /> 4</FormKit>
1<script setup> 2import { ref } from "vue"; 3const data = ref({}) 4const createFilter = (queryString) => { 5 return (restaurant) => { 6 return ( 7 restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0 8 ) 9 } 10} 11 12const restaurants = ref([ 13 { value: 'vue', link: 'https://github.com/vuejs/vue' }, 14 { value: 'element', link: 'https://github.com/ElemeFE/element' }, 15 { value: 'cooking', link: 'https://github.com/ElemeFE/cooking' }, 16 { value: 'mint-ui', link: 'https://github.com/ElemeFE/mint-ui' }, 17 { value: 'vuex', link: 'https://github.com/vuejs/vuex' }, 18 { value: 'vue-router', link: 'https://github.com/vuejs/vue-router' }, 19 { value: 'babel', link: 'https://github.com/babel/babel' }, 20]) 21 22let querySearch = (queryString, cb) => { 23 const results = queryString 24 ? restaurants.value.filter(createFilter(queryString)) 25 : restaurants.value 26 // call callback function to return suggestions 27 cb(results) 28} 29 30</script> 31<template> 32 33 34 <pre wrap>{{ data }}</pre> 35 <FormKit type="group" v-model="data"> 36 <FormKit type="el-autocomplete" label="el-autocomplete" name="value1" placeholder="Please Input" 37 :fetch-suggestions="querySearch" /> 38 </FormKit> 39 40 41 42</template>
1<script setup> 2import { ref } from "vue"; 3const data = ref({}) 4</script> 5 6<template> 7 <pre wrap>{{ data }}</pre> 8 <FormKit type="group" v-model="data"> 9 <FormKit type="el-upload" label="elUpload" name="upload"> 10 <el-button type="primary" size="small">select file</el-button> 11 </FormKit> 12 13 <FormKit type="el-upload" label="elFormUpload" name="upload1" form-item> 14 <el-button type="primary" size="small">select file</el-button> 15 </FormKit> 16 </FormKit> 17</template>
1<script setup> 2import { ref } from 'vue' 3let form = ref({}) 4 5let data = [{ 6 label: "Level one 1", 7 value: 1, 8 9 children: [{ 10 label: "Level two 1-1", 11 value: 2, 12 children: [{ 13 label: "Level three 1-1-1", 14 value: 3 15 }, { 16 label: "Level three 1-1-2", 17 value: 4 18 }, { 19 label: "Level three 1-1-3", 20 value: 5 21 }] 22 }] 23 24}] 25</script> 26 27<template> 28 <form-kit type="form" v-model="form"> 29 <form-kit type="el-tree-select" name="treeselect" :data="data" label="el-tree-select" :render-after-expand="false" /> 30 31 <form-kit type="el-tree-select" name="treeselect2" :data="data" label="el-tree-select (checkbox)" show-checkbox :render-after-expand="false" /> 32 33 <form-kit type="el-tree-select" name="treeselect3" :data="data" label="el-tree-select (multiple)" multiple :render-after-expand="false" /> 34 </form-kit> 35</template> 36
Due to the limitation of vue3, the submit event of el-form is not supported. You can use the submit attribute of FormKit to submit the form.
1const data=ref({}) 2let onSubmit=()=>{ 3 console.log('submited') 4} 5
1 <FormKit type="el-form" v-model="data" :submit="onSubmit"> 2 ... 3 </FormKit>
No vulnerabilities found.
No security vulnerabilities found.