# Creating Custom Input Types

**URL:** <https://forum.builder.io/t/creating-custom-input-types/6670>\
**Category:** General\
**Created:** [October 30, 2024, 1:35pm UTC](https://forum.builder.io/t/creating-custom-input-types/6670 "2024-10-30T13:35:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhs129](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jhs129](https://forum.builder.io/u/jhs129)\
**Post date:** [October 30, 2024, 1:35pm UTC](https://forum.builder.io/t/creating-custom-input-types/6670/1 "2024-10-30T13:35:50Z")

</div>

I am looking for instructions on how to create a custom input type that I can use on components and or models so that I can define a common set of input fields once and re-use them.

For example, here is the definition of a component I have created that has a standard set of input fields to help creating links to content within the CMS. Rather than having to drag in this component as a child to other components I want to be able to define this as a custom input type (similiar to how the Cloudinary plugin defines the cloudinaryImageEditor type).

```auto
Builder.registerComponent(
  dynamic(() => import("@/components/navigation/cmslink")),
  {
    name: "CMS Link",
    inputs: [
      { name: "Label", type: "string", defaultValue: "Link Text" },
      {
        name: "type",
        type: "string",
        enum: ["page", "blog", "url", "text"],
        defaultValue: "page",
      },
      {
        name: "linkPage",
        type: "reference",
        model: "page",
        friendlyName: "Destination",
        showIf: `options.get('type') === 'page'`,
      },
      {
        name: "linkBlog",
        type: "reference",
        model: "blog",
        friendlyName: "Destination",
        showIf: `options.get('type') === 'blog'`,
      },
      {
        name: "linkUrl",
        type: "string",
        friendlyName: "Destination",
        showIf: `options.get('type') === 'url'`,
      },
      {
        name: "linkText",
        type: "string",
        friendlyName: "Destination",
        showIf: `options.get('type') === 'text'`,
      },
    ],
  }
);

```

Has anyone done something like this before / could you provide examples of how to do this? My goal would be to be able to define this custom InputType named ‘cmsLink’ and then use it in registering a component like this:

```auto
Builder.registerComponent(
  dynamic(() => import("@/components/helloworld")),
  {
    name: "Hello World",
    inputs: [
      {
        name: "type",
        type: "cmsLink",
      },
      {
        name: "linkText",
        type: "string",
      },
    ],
  }
);

```

Note, I am working in NextJS

---

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [October 31, 2024, 10:04am UTC](https://forum.builder.io/t/creating-custom-input-types/6670/2 "2024-10-31T10:04:37Z")

</div>

Hello @jhs129,

To create a custom input type in [Builder.io](http://Builder.io) that can be reused for [components](https://www.builder.io/c/docs/custom-components-intro) and models, you need to create a [custom plugin](https://www.builder.io/c/docs/make-a-plugin).

1. Begin by setting up a directory for your plugin, initialize the project, and install necessary dependencies like `@builder.io/app-context` and `@builder.io/react`.
2. Use `Builder.registerEditor()` to define your custom input type. This function takes an options object with a name, the component that will act as the editor, and optional configuration options.
3. 
  - Your custom type editor should be a React component that handles the input logic. It should receive `value` and `onChange` props to manage the data.

Here is an example:

> <https://github.com/BuilderIO/builder/blob/ec51c2682c11daa65c66dd6c0125aa947c983b74/plugins/example-app-campaign-builder/src/plugin.ts>

Feel free to let us know if you have any further questions.

Best regards,

---

<div class="post-metadata">

**Author:** ![jhs129](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jhs129](https://forum.builder.io/u/jhs129)\
**Post date:** [November 6, 2024, 2:28pm UTC](https://forum.builder.io/t/creating-custom-input-types/6670/3 "2024-11-06T14:28:34Z")

</div>

Hi Manish-

Thanks for providing this update. This gives a good example of how to create a plugin but it’s unclear how exactly I would create the custom input type within the plugin. Can you provide a bit more clarity on how to do specifically that?

Thanks,  
John

---

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [November 7, 2024, 5:35am UTC](https://forum.builder.io/t/creating-custom-input-types/6670/4 "2024-11-07T05:35:57Z")

</div>

Hello @jhs129,

To register your custom input type, use the `Builder.registerEditor()` method. This method requires an options object that includes `name`, `component`, and optional `options`. Once registered, your custom type will be available throughout the Builder’s Visual Editor. It can be utilized for custom component inputs, targeting content, model fields, and symbol inputs.

Here is an example:

> <https://github.com/BuilderIO/builder/blob/ec51c2682c11daa65c66dd6c0125aa947c983b74/plugins/bynder-example/src/plugin.ts>

---

<div class="post-metadata">

**Author:** ![qiqi331](https://avatars.discourse-cdn.com/v4/letter/q/dec6dc/32.png) [@qiqi331](https://forum.builder.io/u/qiqi331)\
**Post date:** [November 8, 2024, 1:24am UTC](https://forum.builder.io/t/creating-custom-input-types/6670/5 "2024-11-08T01:24:29Z")

</div>

Yes, you can absolutely make custom input types within [Builder.io](http://Builder.io)! Defining your custom input type, like cmsLink, and then using it inside your component registration is the key. To do that you would need to create a custom input component and pass it to Builder.registerInputType. Then you can refer it in your components as you have already shown. I think it’s something akin to creating your own Cloudinary input, but for your CMS link setup. I haven’t seen a direct example, but that’s what you’d do.
