JGuang

VirtualInput <Experimental></Experimental>

VirtualInput <Experimental></Experimental> · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

VirtualInput <Experimental></Experimental>

Consistent with the appearance and usage of the Input input box.

Install

npm install antd-mobile@5.43.0

antd-mobile is for mobile web, not React Native or Mini Programs. React 19 projects must register createRoot with unstableSetRender at the entry, or imperative APIs such as Toast and Dialog cannot render. Switch dark mode with <html data-prefers-color-scheme="dark">.

Examples come from the official Ant Design Mobile repository (MIT) at the commit published as npm 5.43.0. Presentation helpers such as DemoBlock are JGuang rewrites, not antd-mobile APIs.

Consistent with the appearance and usage of the Input input box.

When to Use

When you need to use it with the virtual keyboard.

Demos

VirtualInput

Props

NameDescriptionTypeDefault
clearableWhether to enable the clear icon, the virtual input box will be cleared after clicking the clear iconbooleanfalse
onBlurTriggered when element lose focus() => void-
onClearTrigger when clear button clicked() => void-
onClickTriggered when element get clicked(e: React.MouseEvent<HTMLDivElement>) => void-
onFocusTriggered when element get focus() => void-
placeholderThe placeholder textstring-
valueThe input valuestring''
cursorCursor related configuration, movable indicates whether it can be adjusted, onMove is the cursor movement callback{ movable?: boolean; onMove?: (position: number) => void }{ movable: false }

Strictly speaking, VirtualInput is not a form field component. It just displays the data.

Ref

NameDescriptionType
blurLet the input box lose focus() => void
focusLet the input box get focus() => void

CSS Variables

NameDescriptionDefaultGlobal
--caret-colorThe color of caret.var(--adm-color-primary)--adm-virtual-input-caret-color
--caret-widthThe width of caret.2px--adm-virtual-input-caret-width
--colorText color.var(--adm-color-text)-
--disabled-colorText color when disabled.var(--adm-color-weak)-
--font-sizeText font size.17px-
--placeholder-colorPlaceholder text color.var(--adm-color-light)-
--text-alignThe alignment of text.left-