--- title: Custom Input Components group: Component Gallery --- ## Custom Declarative Input Components In addition to all the [Input Components](/vue/form-inputs) in the Vue Component Library, AutoForm components bound to your declarative Request DTOs can also reference your own Vue Input components. This allows us to continue to benefiting rapid development workflow enabled by the [AutoForm components](/vue/autoform) whilst also being able to deliver the most optimal UX when we need to. CreatorKit's [Email Templates](https://servicestack.net/creatorkit/portal-messages) are a good example of this, which instead of utilizing the standard [LookupInput](/vue/autoform#edit-form) (inferred from [Reference Fields](/vue/autoquerygrid#reference-fields)) to open a modal to select a contact from a Contacts DataGrid it uses a custom `EmailInput` Component to provide an optimal, user-friendly UX that we've come to expect from popular Email clients like gmail to provide a non-modal autocomplete dropdown that automatically searches our contact list as we type. ### Registering Custom Components To make use of a custom Input component we need to register it with the Vue Component Library in [app.mjs](https://github.com/NetCoreApps/CreatorKit/blob/main/CreatorKit/wwwroot/mjs/app.mjs), e.g: ```ts import ServiceStackVue, { useAuth } from "@servicestack/vue" //... ServiceStackVue.component('EmailInput', EmailInput) ServiceStackVue.component('MarkdownEmailInput', MarkdownEmailInput) ``` ### EmailInput This registers the custom `EmailInput` and `MarkdownEmailInput` components defined in [Inputs.mjs](https://github.com/NetCoreApps/CreatorKit/blob/main/CreatorKit/wwwroot/mjs/components/Inputs.mjs) Where we can see that `` is a customized `` with an added `SelectEmail` component that's used to display the Autocomplete email dropdown: ```ts export const EmailInput = { components: { SelectEmail }, template: ` `, emits:['update:modelValue'], } ``` ### MarkdownEmailInput Whilst `` is a customized `` that's been extended with an additional [Insert Template Variables button](https://servicestack.net/creatorkit/portal-messages#template-variables) that enables quick access for users to discover and insert user-defined [Template Variables](https://servicestack.net/creatorkit/customize#template-variables): ```ts export const MarkdownEmailInput = { components: { InsertVariableButton }, template: ` `, emits:['update:modelValue'], } ``` Once registered they can be declaratively used like any other Input Component using the `[Input(Type)]` attribute: ```csharp [Description("Markdown Email")] public class MarkdownEmail : CreateEmailBase, IPost, IReturn { [ValidateNotEmpty] [FieldCss(Field = "col-span-12")] public string Subject { get; set; } [ValidateNotEmpty] [Input(Type="MarkdownEmailInput", Label=""), FieldCss(Field="col-span-12", Input="h-56")] public string? Body { get; set; } public bool? Draft { get; set; } } public abstract class CreateEmailBase { [ValidateNotEmpty] [Input(Type="EmailInput")] public string Email { get; set; } [ValidateNotEmpty] [FieldCss(Field = "col-span-6 lg:col-span-3")] public string FirstName { get; set; } [ValidateNotEmpty] [FieldCss(Field = "col-span-6 lg:col-span-3")] public string LastName { get; set; } } ``` Where they're effortlessly used together to deliver a great, optimal UX in all of CreatorKit's Markdown Email Forms:
### Extending Auto Forms The Email Forms also includes a **Live Preview** component so you can view a HTML Preview of what the Email looks like as-you-type which was created using a customized `` component that's enhanced to include an `` component by using a custom `