suiss/ui · Component
Input
A single-line text field for entering and editing short values.
Input is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Input renders a native input element with a bordered control style. It supports every native input type, including email, password, number, search and file, and adds a size prop for four heights.
Use it for short, free-form values. For multi-line text use a textarea, for icons, buttons or text attached to the field use InputGroup, and for one-time codes use InputOTP.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
- Install the following dependencies and add the
cnhelper:
- Copy and paste the following code into your project.
- Update the import paths to match your project setup.
Usage
Examples
Sizes
Use the size prop to set the height. Choose a size that matches neighboring controls such as a Button, as shown here.
Types
Set the native type attribute for email, password, number and search fields.
With value
Set defaultValue for an uncontrolled field that starts with a value, or use value with onChange to control it.
File
Set type="file" for a file picker. Give it an accessible name, as with any input.
Invalid
Set aria-invalid to show the error style.
Disabled
Set disabled to stop the input from being focused or edited.
Accessibility
- Renders a native
input, so the role follows itstype:textboxby default,spinbuttonfornumberandsearchboxforsearch. - Needs an accessible name from an associated label or
aria-label. - Set
aria-invalidto communicate a validation error. - A disabled input cannot be focused or edited.
API Reference
Input
The text field.
| Prop | Type | Default |
|---|---|---|
size | "sm" | "md" | "default" | "lg" | "default" |
Also accepts the props of React.ComponentProps<"input">.
size sets the height and text size: lg is 54px with 17px text for forms such as sign-in pages, default is 44px, md is medium and sm is the most compact with a smaller radius. It replaces the native size attribute. Give every input a visible label, for example with FieldLabel inside a Field, or set aria-label when a visible label is not possible. The input sets data-slot="input" and data-size for styling.
Web preview
Input wraps a TextInput through the field control primitive. It tracks its own focused, filled, invalid and disabled state and styles itself from that state: a focus border while editing, a destructive border and tint when invalid, and 50% opacity when disabled.
It comes in three sizes: default (44 pt), md and sm. Use the default size for forms on a full screen, and the smaller sizes inside dense layouts such as toolbars or sheets.
Installation
- Install the following dependencies:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/input.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/input.tsx:
- Update the import paths to match your project setup.
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/input.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Examples
Types
Pass a TextInput prop such as secureTextEntry, keyboardType or inputMode to get the matching field type.
Web preview
Sizes
The sm, md, default and lg sizes, each next to a matching button. lg is 54 tall with 17 point text, for forms such as sign-in screens.
Web preview
With value
An input that starts with a defaultValue.
An input that starts with a value.
Web preview
With label
An input inside a Field with a label and description.

Invalid
An input inside an invalid Field with an error message. Inside a Field, set invalid on the field instead of on the input.
Web preview
Controlled
A controlled input that mirrors its value below.

Disabled
A disabled input.
Web preview
Accessibility
- Inside a
Field, the input is linked to the field label throughaccessibilityLabelledByand gets the label asaccessibilityLabeland the description asaccessibilityHint. disabledis set inaccessibilityStateand makes the input non-editable.- Outside a
Field, give the input anaccessibilityLabel; a placeholder alone is not a label.
API Reference
Input
The text field.
| Prop | Type | Default |
|---|---|---|
size | InputSize | "default" |
Also accepts the props of React.ComponentProps<typeof InputPrimitive.Root>.
size sets the height and text size. The value works controlled with value and onValueChange(value, details), or uncontrolled with defaultValue. Inside a Field, the input picks up the field's label, description, invalid and disabled state. className can be a function that receives the state (focused, invalid, disabled, filled, …) and returns classes. Fields have a border outline; focus turns it to ring with a solid ring, and an invalid field gets a thicker destructive border with a tint.
.textFieldStyle(.input)
Style that creates InputStyle.
| Parameter | Type | Default |
|---|---|---|
size | InputStyle.Size: .default | .md | .sm | .lg | .default |
InputSize
Values: Default, Md, Sm, Lg.
Input
The text field.
| Parameter | Type | Default |
|---|---|---|
value | String | - |
onValueChange | (String) -> Unit | - |
modifier | Modifier | Modifier |
size | InputSize: Default | Md | Sm | Lg | InputSize.Default |
enabled | Boolean | LocalFieldState.current.enabled |
readOnly | Boolean | false |
invalid | Boolean | LocalFieldState.current.invalid |
placeholder | String? | null |
keyboardOptions | KeyboardOptions | KeyboardOptions.Default |
keyboardActions | KeyboardActions | KeyboardActions.Default |
visualTransformation | VisualTransformation | VisualTransformation.None |
interactionSource | MutableInteractionSource? | null |

