본문으로 건너뛰기

@canard/schema-form-antd-mobile-plugin

@canard/schema-form-antd-mobile-plugin npm versionlicense
yarn add @canard/schema-form-antd-mobile-plugin

@canard/schema-form를 위한 Ant Design Mobile UI 플러그인입니다. antd-mobile ^5.0.0 기반의 10개 터치 최적화 폼 입력 컴포넌트를 제공합니다. 모바일 웹 애플리케이션을 위해 설계되었으며, 데스크탑 방식의 입력 대신 스위치와 슬라이더를 선호합니다.

컴포넌트 카탈로그

Preview

전체 카탈로그

10개 컴포넌트 전체를 컴포넌트 카탈로그 페이지에서 확인하세요.

Installation

yarn add @canard/schema-form-antd-mobile-plugin antd-mobile@>=5.0.0

Peer Dependencies

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

Note: antd-mobile is a direct dependency of this plugin, not a peer dependency.

Quick Setup

import { registerPlugin } from '@canard/schema-form';
import { plugin } from '@canard/schema-form-antd-mobile-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 with custom labels
FormTypeInputStringCheckboxarray"checkbox"items.enumCheckbox group; items must be string schema
FormTypeInputStringSwitchstring"switch"2 valuesToggle between two enum values
FormTypeInputRadioGroupstring | number | integer"radio" or "radiogroup"requiredRadio group
FormTypeInputArrayarrayDynamic list with add/remove
FormTypeInputSlidernumber | integer"slider"Slider; also supports range slider for numeric-item arrays
FormTypeInputTextareastring"textarea" or formType "textarea"Multi-line textarea
FormTypeInputStringstringDefault text input (password supported via format: "password")
FormTypeInputNumbernumber | integerStepper component
FormTypeInputBooleanbooleanCheckbox with indeterminate state

Slider Range Support

FormTypeInputSlider activates for numeric range arrays:

// Single value slider
{ type: 'number', format: 'slider' }

// Range slider (array of two numbers)
{
type: 'array',
format: 'slider', // or: items with numeric type + format:'slider'
items: { type: 'number' }
}

Schema Extension Properties

{
formType?: 'switch' | 'radio' | 'radiogroup' | 'checkbox' | 'textarea',
format?: 'slider' | 'textarea' | 'password',
}

Usage Example

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

const schema = {
type: 'object',
properties: {
name: { type: 'string' },
count: { type: 'integer' },
active: { type: 'boolean', formType: 'switch' },
rating: { type: 'number', format: 'slider', minimum: 0, maximum: 5 },
tags: {
type: 'array',
formType: 'checkbox',
items: { type: 'string', enum: ['js', 'ts', 'react'] },
},
},
};

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

Context: Custom Switch Labels

// Pass checkboxLabels through context for BooleanSwitch
<Form
jsonSchema={schema}
context={{ checkboxLabels: { active: { true: 'On', false: 'Off' } } }}
/>
AI Agent Reference

AI Reference

Package: @canard/schema-form-antd-mobile-plugin v0.10.0 Purpose: Ant Design Mobile UI plugin — 10 touch-optimized form components for mobile web.

Exports

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

Peer dependencies

antd-mobile@>=5.0.0 (direct dep), 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
RadioGroupstring|number + formType: "radio" + enum
Arrayarray (dynamic list)
Slidernumber + format: "slider" (also supports range arrays)
Textareastring + format: "textarea"
Stringstring (default)
Numbernumber|integer (Stepper component)
Booleanboolean (default checkbox with indeterminate)

Context: custom switch labels

context={{ checkboxLabels: { fieldName: { true: 'On', false: 'Off' } } }}

Key differences from antd5/antd6

  • No Date/Time/Month/URI pickers (mobile-specific)
  • Number uses Stepper component (not text input)
  • Slider supports range arrays: { type: 'array', format: 'slider', items: { type: 'number' } }