# Custom Components

### Define Custom-Component

Implement your own component like this&#x20;

```markup
<template>
  <div class="ma-3 pa-4 grey lighten-3">
    <v-text-field v-model="input" label="obj.schema.label"></v-text-field>  
    <br>
    type: {{type}}
    <br>
    value: {{value}}
    <br>
    obj: {{obj}}
  </div>
</template>
```

```javascript
// customComponent.vue
<script>
export default {
  name:'customComponent',  
  props: ['type','value', 'obj'],  
  computed:{
    input:{
      get(){  return this.value},
      set(val){ this.$emit('input', val)}  // listen to @input="handler"
    }
  }  
}
</script>

```

### Use Custom-Component

First register your custom component globally in **`main.js`**

```javascript
 // main.js
 // You have to register your Custom-Control Component globally in 'main.js'
 // See: https://vuejs.org/v2/guide/components-registration.html
 
 Vue.component('customComponent', () => import('@/components/customComponent.vue') )
 
 // type:'customComponent' splits to custom-omponent
 // Case-sensitive attribute names don't work with v-bind 
 // https://github.com/vuejs/vue/issues/4212
 
```

and then use your custom-component in **`seCustomComponents.vue`**

```markup
<template>
  <v-form-base
    :model="myModel"
    :schema="mySchema"
    @input="log"
  />
</template>
```

```javascript
// UseCustomComponents.vue
<script>
import VFormBase from '@/components/vFormBase'

/* IMPORTANT !!!
  // You have to register your Custom-Control Component globally in 'main.js'
  // See: https://vuejs.org/v2/guide/components-registration.html
  
  // main.js
  Vue.component('customComponent', () => import('@/components/customcomponent-basic.vue') )
  
  // type:'customComponent' splits to custom-omponent
  // Case-sensitive attribute names don't work with v-bind 
  // https://github.com/vuejs/vue/issues/4212
*/

export default {
  components: { VFormBase},
  name:'UseCustomComponents',
  data () {
    return {
      myModel: {
        custom: 'base',
        // ...
      },
      mySchema: {
        //    ### HERE USE YOUR CUSTOM COMPONENT ####
        custom: { type: 'customComponent', label:'My Component' },
        //...
      }
    }
  },
  methods: {
    log( {  on, id, key, value, params, obj, data, schema, parent, index, event } ){
      // destructure the signature object 
      console.log(on, key, value)
    }    
  }
}
</script>

```

### [Example](https://wotamann.github.io/customcomponentdemo)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wotamann.gitbook.io/vuetify-form-base/schema/custom-component.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
