Field
A form field component with label, input, and validation support.
Installation
npm install @cleartrip/ct-design-field
# or
pnpm add @cleartrip/ct-design-field
Peer dependencies
# Required for all targets
npm install react
# Web only
npm install react-dom
# React Native only
npm install react-native
Usage
Basic
import { Field } from '@cleartrip/ct-design-field';
function Example() {
return (
<Field>
{/* Basic usage */}
</Field>
);
}
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
id | string | — | No | field id |
placeholder | string | — | No | field placeholder text |
placeholderType | `'default' | 'labeled' | 'floating'` | — |
value | string | — | ✅ Yes | field value |
FieldVariant
SM— smMD— md
FieldType
TEXT— textNUMBER— numberPHONE— phone
Accessibility
- The component follows accessibility best practices
- Ensure proper ARIA attributes are provided where needed
- Test with screen readers to ensure usability
Migration
If migrating from a previous version:
- import { Field } from 'yagami/core/components';
+ import { Field } from '@cleartrip/ct-design-field';