New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@rc-component/input

Package Overview
Dependencies
Maintainers
5
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rc-component/input

React input component

Source
npmnpm
Version
1.4.0
Version published
Weekly downloads
2.2M
28.36%
Maintainers
5
Weekly downloads
 
Created
Source

@rc-component/input

Ant Design Part of the Ant Design ecosystem.

📦 ⌨️ Low-level React input primitives for building polished text fields and textareas.

NPM version npm downloads build status Codecov bundle size dumi

English | 简体中文

Highlights

  • Composable Input, TextArea, and BaseInput primitives.
  • Affix, addon, clear icon, prefix, suffix, and character count support.
  • Autosizing textarea with resize callbacks and imperative refs.
  • TypeScript definitions and semantic classNames / styles slots.
  • Used by Ant Design as the shared input foundation.

Install

npm install @rc-component/input

Usage

import Input from '@rc-component/input';

export default () => <Input allowClear placeholder="Type something" />;
import { TextArea } from '@rc-component/input';

export default () => <TextArea autoSize showCount maxLength={100} />;

Examples

Run the local dumi site:

npm install
npm start

Then open http://localhost:8000.

API

Input

PropertyTypeDefaultDescription
addonAfterReactNode-Element displayed after the input.
addonBeforeReactNode-Element displayed before the input.
allowClearboolean | { disabled?: boolean; clearIcon?: ReactNode; tabIndex?: number }falseShow a clear button for the current value. Set tabIndex: -1 to skip it during Tab navigation.
classNamestring-Class name for the input element.
classNamesInputProps['classNames']-Semantic class names for input slots.
countCountConfig-Custom count strategy, limit, visibility, and exceed formatter.
defaultValuestring | number | readonly string[] | bigint-Initial input value.
disabledbooleanfalseDisable the input.
htmlSizenumber-Native input size attribute.
maxLengthnumber-Native input maxLength attribute.
prefixReactNode-Prefix content inside the input wrapper.
prefixClsstringrc-inputClass name prefix.
showCountboolean | { formatter: ShowCountFormatter }falseShow character count. Prefer count.show for new code.
stylesInputProps['styles']-Semantic styles for input slots.
suffixReactNode-Suffix content inside the input wrapper.
typeInputProps['type']textNative input type. Use TextArea for textarea behavior.
valuestring | number | readonly string[] | bigint-Controlled input value.
onChangeReact.ChangeEventHandler<HTMLInputElement>-Triggered when the value changes.
onClear() => void-Triggered when the clear button is clicked.
onPressEnterReact.KeyboardEventHandler<HTMLInputElement>-Triggered when Enter is pressed.

TextArea

PropertyTypeDefaultDescription
allowClearboolean | { disabled?: boolean; clearIcon?: ReactNode; tabIndex?: number }falseShow a clear button for the current value. Set tabIndex: -1 to skip it during Tab navigation.
autoSizeboolean | { minRows?: number; maxRows?: number }falseAuto resize height by content.
classNamestring-Class name for the textarea.
classNamesTextAreaProps['classNames']-Semantic class names for textarea slots.
countCountConfig-Custom count strategy, limit, visibility, and exceed formatter.
defaultValuestring | number | readonly string[] | bigint-Initial textarea value.
maxLengthnumber-Native textarea maxLength attribute.
prefixClsstringrc-textareaClass name prefix.
showCountboolean | { formatter: ShowCountFormatter }falseShow character count. Prefer count.show for new code.
styleReact.CSSProperties-Inline styles for the textarea.
stylesTextAreaProps['styles']-Semantic styles for textarea slots.
suffixReactNode-Suffix content inside the textarea wrapper.
valuestring | number | readonly string[] | bigint-Controlled textarea value.
onChangeReact.ChangeEventHandler<HTMLTextAreaElement>-Triggered when the value changes.
onClear() => void-Triggered when the clear button is clicked.
onPressEnterReact.KeyboardEventHandler<HTMLTextAreaElement>-Triggered when Enter is pressed.
onResize(size: { width: number; height: number }) => void-Triggered when textarea size changes.

Refs

import type { InputRef, TextAreaRef } from '@rc-component/input';

function focusInput(inputRef: InputRef | null) {
  inputRef?.focus();
}

function blurTextArea(textareaRef: TextAreaRef | null) {
  textareaRef?.blur();
}
RefMethods
InputReffocus(options), blur(), select(), setSelectionRange(), input, nativeElement
TextAreaReffocus(), blur(), resizableTextArea, nativeElement

Development

npm install
npm start
npm test
npm run tsc
npm run compile
npm run build

The dumi site runs at http://localhost:8000 by default.

Release

npm run prepublishOnly

The release flow is handled by @rc-component/np through the rc-np command after the package build.

License

@rc-component/input is released under the MIT license.

Keywords

react

FAQs

Package last updated on 12 Oct 2026

Related posts