SwipeUI

Field

The shared field language: a label, a filled surface with a focus ring and halo, and a message row that springs open for helper, error, success and counter text.

npx @swipeui/cli add field
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When to use it

  • Giving any custom control, such as a date picker, slider or rating, a proper label, helper, error and success message.
  • Building your own input on the same filled surface, focus ring and halo as SwipeUI's fields with FieldSurface.
  • A picker that opens a sheet or menu: FieldTrigger draws the value, a muted placeholder and a chevron that turns while open.
  • Setting the look of several fields at once: appearance, size, shape and label placement flow from Field to the control inside.

When not to use it

  • Text inputs alone; Text field already includes a Field.
  • Grouping several controls under one heading. Use List section or a heading.
  • Section titles that aren't attached to a control.
  • Buttons. A trigger that runs an action rather than opening a choice is a Button.

Installation

Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.

npx @swipeui/cli add field
  • Adds components/swipeui/ui/field.tsx, components/swipeui/ui/field-context.ts, components/swipeui/ui/field-styles.ts, components/swipeui/ui/field-surface.tsx, components/swipeui/ui/field-message.tsx, components/swipeui/ui/field-glyphs.tsx, components/swipeui/ui/field-action.tsx, components/swipeui/ui/field-trigger.tsx, components/swipeui/ui/use-field-focus.ts and 10 shared helpers.
  • Installs class-variance-authority, react-native-reanimated, react-native-svg, uniwind, react-native-worklets, clsx, tailwind-merge, expo-haptics. In Expo apps it uses npx expo install so versions match your SDK.

Usage

app/sign-up.tsx
import { Field } from '@/components/swipeui/ui/field';

<Field label="Email" helper="Use your work address">
  <EmailInput />
</Field>;

Examples

A picker trigger: the value sits at the start, the placeholder is muted, and while open the ring shows and the chevron turns.

import { Field, FieldTrigger } from '@/components/swipeui/ui/field';

<Field label="Country" helper="Where you pay tax">
  <FieldTrigger
    value={country}
    placeholder="Choose a country"
    open={open}
    onPress={() => setOpen(true)}
  />
</Field>;

Your own control on the same surface, focus ring and halo:

import { FieldSurface } from '@/components/swipeui/ui/field';

function PinBox({ focused, digits }: { focused: boolean; digits: string }) {
  return (
    <FieldSurface focused={focused} size="lg">
      <Text className="font-mono text-title-3">{digits.padEnd(4, '•')}</Text>
    </FieldSurface>
  );
}

API reference

PropTypeDefaultDescription
labelstring—

The visible and spoken name. Placeholders never replace a label. An empty string hides it visually.

helper?string—

Additional instructions, replaced by an error or success message.

error?string—

Validation message. New messages are announced, shake the control once and play an error haptic.

success?string—

Confirmation, such as "Username available". Replaces the helper; an error replaces it.

status?FieldStatus'idle'

Validation state the control shows: a spinner while validating, a check when valid. An error implies invalid.

required?booleanfalse

Whether a value is required.

requiredIndicator?FieldRequiredIndicator'asterisk'

How a required field is marked: a red asterisk, the word, or nothing. "Required" is always spoken.

optionalIndicator?booleanfalse

Show a muted "Optional" after the label.

disabled?booleanfalse

Disables the enclosed control through context.

disabledStyle?FieldDisabledStyle'muted'

muted lightens the field without opacity; dim lowers the whole field to 50%.

appearance?FieldAppearancethe control's own default ('filled')

Surface look passed to the control.

size?FieldSizethe control's own default ('md')

Control size passed to the control.

shape?FieldShapethe control's own default ('preset')

Control shape passed to the control.

labelPlacement?FieldLabelPlacement'above'

Where the label sits. inset and floating are drawn inside the control by Text field and Field trigger.

align?FieldAlign'start'

Where the label and message sit across the row. Compact controls that centre themselves (Number field, OTP input) centre these too.

focusRing?FieldFocusRingthe control's own default ('halo')

Focus indicator passed to the control.

messageMorph?FieldMessageMorph'fade'

How a changed message arrives.

reserveMessageSpace?booleanfalse

Keep one line of room under the control even when there's no message.

count?FieldCount—

A character count shown at the end of the message row. Text field sets this from its counter.

messages?Partial<FieldMessages>FIELD_MESSAGES (English)

Built-in strings, for translation.

motion?MotionOverridethe app's feel

Motion for the message row, ring and label.

id?string—

Stable control identifier; generated when omitted.

childrenReactNode—

One editable control and optional accessory content.

className?string—

Classes merged over the field layout.

labelClassName?string—

Classes merged over the label.

style?StyleProp<ViewStyle>—

Native style escape hatch.

testID?string—

Root test identifier; parts append -label, -message, -description and -counter.

Composition and behavior

  • label names the control; placeholders never replace it. An empty label hides it visually and keeps the spoken name.
  • helper, error and success share one row under the control. Its height springs as messages come and go, and a new message rises in. Errors carry an alert glyph; success carries a check that draws on.
  • appearance, size, shape, labelPlacement and focusRing pass down to the control, so a Text field or Field trigger inside picks them up.
  • disabled passes down too. disabledStyle="muted" lightens the control without opacity; dim lowers the whole field to 50% once.
  • required speaks "Required" in the hint and marks the label with a quiet asterisk or the word (requiredIndicator). optionalIndicator adds "Optional".
  • Build your own controls with FieldSurface, FieldAction (a 44pt accessory that keeps focus in the input), FieldGlyph and FieldMessage, all exported from field. useField() gives you the label, hint, state and look.

Field settings

PropDoesDefault
helper / error / successMessages under the controlnone
statusidle, validating, valid or invalididle
required / requiredIndicatorRequired, marked by asterisk, word or nonefalse, asterisk
optionalIndicator"Optional" after the labelfalse
appearancefilled, outline, underline or ghost, for the controlthe control's (filled)
size / shapesm, md, lg; preset or pill, for the controlthe control's
labelPlacementabove, inset, floating or hiddenabove
alignLabel and message at the start, center or end, to match a centred controlstart
focusRinghalo, ring or none, for the controlhalo
messageMorphfade, characters or nonefade
reserveMessageSpaceKeep a line for messages so forms don't movefalse
countA counter at the end of the message rownone
disabled / disabledStyleOff, drawn muted or dimfalse, muted
messagesBuilt-in strings, for translationEnglish
motionA local motion feel or overridethe app's feel

Behavior and gestures

  • Field doesn't respond to touch; it labels and describes the control inside it, and passes the look down through context.
  • When an error appears it replaces the helper (and success) line: the row springs to its new height, the text rises in with an alert glyph, the control shakes once and an error haptic plays.
  • Success messages show in the success colour with a check that draws on.
  • The message row's height springs as messages arrive and leave; reserveMessageSpace keeps one line so the form never moves.
  • A counter at the end of the row rolls its digits; it turns amber near the limit and red at it.
  • Setting disabled turns off the control inside; disabledStyle muted (the default) lightens it without opacity, dim lowers it to 50% once.
  • FieldSurface shows a primary ring and a soft halo while focused and a destructive ring while invalid; focusRing switches the halo or the whole ring off.

Accessibility

  • The label is linked to the control so screen readers read them together; placeholders never replace it.
  • Helper, error and success text become the control's hint. "Required" is spoken; the asterisk is drawn but hidden.
  • New errors and success messages are announced politely without moving focus; on iOS they're announced explicitly once.
  • The counter is hidden from screen readers; text fields announce when 10% remains and when the limit is reached.
  • Nested fields stay separate, so inner controls never steal an outer label.
  • An empty label hides it visually while keeping the spoken name.
  • The halo, ring and glyphs are decorative; FieldTrigger is named "<label>, <value>" and reports expanded.

Motion

  • Uses the toggle, morph, layout, number and press motion roles, so it follows your app's feel. Pass motion to tune this one instance.
  • The ring and halo fade in on the toggle role, and the halo settles from 98% to full size; under Reduce Motion they cross-fade quickly with no scale.
  • Messages rise 4pt as they fade in on the morph role and fade out on its exit timing; the row height springs on the layout role.
  • Counter digits roll on the number role; the success check draws on along its stroke.
  • A new error shakes the control once on the press timing; Reduce Motion keeps it still and the haptic and ring stay.
  • The trigger chevron turns half a turn while open; under Reduce Motion it simply points the other way.

Performance

  • A small context provider; each animated part (ring, halo, underline, message row) is its own leaf, so typing never re-renders the label.
  • The message row measures one plain inner view and springs a single shared value.

Notes for AI

  • Wrap exactly one editable control per Field. Custom controls call useField() for the label, description, state and look, and draw on FieldSurface.
  • Use Text field for text; use FieldTrigger for anything that opens a picker.
  • Pass appearance, size, shape and labelPlacement on Field to set the look for the control inside; the default is filled.
  • Every built-in string is in messages, for translation.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items