## Custom Field Inputs ### Old (Angular) ```ts title="src/plugins/common/ui/components/slider-form-input/slider-form-input.component.ts" import { Component } from '@angular/core'; import { FormControl } from '@angular/forms'; import { IntCustomFieldConfig, SharedModule, FormInputComponent } from '@vendure/admin-ui/core'; @Component({ template: ` {{ formControl.value }} `, standalone: true, imports: [SharedModule], }) export class SliderControlComponent implements FormInputComponent { readonly: boolean; config: IntCustomFieldConfig; formControl: FormControl; } ``` ```ts title="src/plugins/common/ui/providers.ts" import { registerFormInputComponent } from '@vendure/admin-ui/core'; import { SliderControlComponent } from './components/slider-form-input/slider-form-input.component'; export default [ registerFormInputComponent('slider-form-input', SliderControlComponent), ]; ``` ### New (React Dashboard) ```tsx title="src/plugins/my-plugin/dashboard/components/color-picker.tsx" import { Button, Card, CardContent, cn, DashboardFormComponent, Input } from '@vendure/dashboard'; import { useState } from 'react'; import { useFormContext } from 'react-hook-form'; // By typing your component as DashboardFormComponent, the props will be correctly typed export const ColorPickerComponent: DashboardFormComponent = ({ value, onChange, name }) => { const [isOpen, setIsOpen] = useState(false); const { getFieldState } = useFormContext(); const error = getFieldState(name).error; const colors = ['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FECA57', '#FF9FF3', '#54A0FF', '#5F27CD']; return (
{isOpen && ( {colors.map(color => (
); }; ``` ```tsx title="src/plugins/my-plugin/dashboard/index.tsx" import { defineDashboardExtension } from '@vendure/dashboard'; import { ColorPickerComponent } from './components/color-picker'; defineDashboardExtension({ customFormComponents: { // Custom field components for custom fields customFields: [ { // The "id" is a global identifier for this custom component. We will // reference it in the next step. id: 'color-picker', component: ColorPickerComponent, }, ], }, // ... other extension properties }); ```