Skip to main content

@canard/schema-form-antd5-plugin

@canard/schema-form-antd5-plugin npm versionlicense
yarn add @canard/schema-form-antd5-plugin

Ant Design v5 UI plugin for @canard/schema-form. Provides 18 form input components built on antd ^5.10.0, covering strings, numbers, booleans, dates, ranges, and selection controls.

Component Catalog​

Preview​

Full Catalog

See all 18 components in the Component Catalog page.

Installation​

yarn add @canard/schema-form-antd5-plugin

Peer Dependencies​

yarn add antd@>=5.10.0 dayjs@>=1 react@>=18 react-dom@>=18

Quick Setup​

import { registerPlugin } from '@canard/schema-form';
import { plugin } from '@canard/schema-form-antd5-plugin';

registerPlugin(plugin);

Component Mapping​

Components are selected automatically based on JSON Schema properties. Priority order matches the list below (top = highest priority).

ComponenttypeformatformTypeenumNotes
FormTypeInputBooleanSwitchboolean—"switch"—Switch toggle
FormTypeInputStringCheckboxarray—"checkbox"items.enumCheckbox group; items must be string schema
FormTypeInputStringSwitchstring—"switch"2 valuesToggle between two enum values
FormTypeInputUristring"uri" or formType "uri"——URI input with protocol selector
FormTypeInputMonthstring"month"——Month picker
FormTypeInputDatestring"date"——Date picker
FormTypeInputTimestring"time"——Time picker
FormTypeInputMonthRangearray"month-range" or formType "monthRange"——Month range picker; items must be string schema
FormTypeInputDateRangearray"date-range" or formType "dateRange"——Date range picker; items must be string schema
FormTypeInputTimeRangearray"time-range" or formType "timeRange"——Time range picker; items must be string schema
FormTypeInputRadioGroupstring | number | integer—"radio" or "radiogroup"requiredRadio button group
FormTypeInputStringEnumstring——requiredSelect dropdown; also handles string-item arrays with enum
FormTypeInputArrayarray———Dynamic list with add/remove
FormTypeInputSlidernumber | integer—"slider"—Slider input
FormTypeInputTextareastring"textarea" or formType "textarea"——Multi-line textarea
FormTypeInputStringstring———Default text input (password supported via format: "password")
FormTypeInputNumbernumber | integer———Numeric input
FormTypeInputBooleanboolean———Checkbox

Schema Extension Properties​

// Custom schema properties recognized by this plugin
{
formType?: 'switch' | 'radio' | 'radiogroup' | 'checkbox' | 'slider' |
'textarea' | 'uri' | 'dateRange' | 'monthRange' | 'timeRange',
// Standard JSON Schema properties also used for routing:
format?: 'date' | 'time' | 'month' | 'password' | 'uri' |
'textarea' | 'date-range' | 'month-range' | 'time-range',
}

Usage Example​

import { Form } from '@canard/schema-form';

const schema = {
type: 'object',
properties: {
name: { type: 'string' },
age: { type: 'integer' },
active: { type: 'boolean', formType: 'switch' },
role: { type: 'string', enum: ['admin', 'user', 'guest'] },
birthday: { type: 'string', format: 'date' },
bio: { type: 'string', format: 'textarea' },
score: { type: 'number', formType: 'slider', minimum: 0, maximum: 100 },
},
};

<Form jsonSchema={schema} onChange={setValue} />

Context​

The plugin reads context passed to <Form context={...}> for size configuration:

type AntdContext = {
size?: 'small' | 'middle' | 'large';
};
AI Agent Reference

AI Reference​

Package: @canard/schema-form-antd5-plugin v0.10.0 Purpose: Ant Design v5 UI plugin — 18 form input components for @canard/schema-form.

Exports​

import { plugin } from '@canard/schema-form-antd5-plugin';

Peer dependencies​

antd@>=5.10.0, dayjs@>=1, react@>=18

Component mapping (priority order, high → low)​

ComponentTrigger
BooleanSwitchboolean + formType: "switch"
StringCheckboxarray + formType: "checkbox" + items.enum
StringSwitchstring + formType: "switch" + 2 enum values
Uristring + format: "uri"
Month / Date / Timestring + format: "month"/"date"/"time"
MonthRange / DateRange / TimeRangearray + format: "*-range"
RadioGroupstring|number + formType: "radio" + enum
StringEnumstring + enum
Arrayarray (dynamic list)
Slidernumber + formType: "slider"
Textareastring + format: "textarea"
Stringstring (default)
Numbernumber|integer (default)
Booleanboolean (default checkbox)

Context type​

type AntdContext = { size?: 'small' | 'middle' | 'large' };

Schema extensions​

formType: 'switch' | 'radio' | 'radiogroup' | 'checkbox' | 'slider' | 'textarea' | 'uri' | 'dateRange' | 'monthRange' | 'timeRange'