You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`children`|`ReactNode`| — | The floating label text |
76
+
|`style`|`ViewStyle`| — | Style for the outer container `View`|
77
+
|`inputStyle`|`TextInputProps['style']`| — | Style applied to the inner `TextInput`|
78
+
|`labelStyle`|`TextStyle`| — | Style applied to the animated label |
79
+
|`disabled`|`boolean`|`false`| Disables the input (`editable={false}`); also sets `accessibilityState.disabled` automatically |
80
+
|`value`|`string`| — | Controlled value; animates the label when changed externally |
81
+
|`secureTextEntry`|`boolean`|`false`| Hides input text (password field); also sets `textContentType` and `autoComplete` automatically |
82
+
|`errorMessage`|`string`| — | Error text rendered below the input and announced by screen readers |
83
+
|`helperText`|`string`| — | Helper text rendered below the input and announced by screen readers |
84
+
|`password`|`boolean`| — |**Deprecated** — use `secureTextEntry` instead |
85
+
|`myRef`|`React.Ref<TextInput>`| — |**Deprecated** — use the standard `ref` prop instead |
84
86
85
87
### `FloatingLabelHandle` (ref)
86
88
@@ -92,6 +94,138 @@ ref.current?.clear();
92
94
93
95
---
94
96
97
+
## Accessibility
98
+
99
+
`react-native-floating-labels` is designed to work correctly with screen readers (VoiceOver on iOS, TalkBack on Android) and meets WCAG 2.1/2.2 AA, Section 508, and the React Native accessibility model out of the box — with no extra configuration required for common cases.
100
+
101
+
### Label association (accessibilityLabel)
102
+
103
+
The component automatically derives `accessibilityLabel` from the `children` string so screen readers announce the label when the input is focused.
104
+
105
+
```tsx
106
+
// Screen readers announce "Email" when this input receives focus
107
+
<FloatingLabel>Email</FloatingLabel>
108
+
```
109
+
110
+
Override it by passing `accessibilityLabel` explicitly:
On web (react-native-web), `accessibilityLabel` is mapped to `aria-label` automatically.
117
+
118
+
### Disabled state
119
+
120
+
When `disabled={true}` is passed, the component automatically sets `accessibilityState={{ disabled: true }}` on the input so screen readers announce it as unavailable.
121
+
122
+
```tsx
123
+
<FloatingLabeldisabled>Email</FloatingLabel>
124
+
```
125
+
126
+
Override or extend `accessibilityState` as needed — your values take precedence:
Add an `accessibilityHint` to give users extra context:
154
+
155
+
```tsx
156
+
<FloatingLabelsecureTextEntryaccessibilityHint="Must be at least 8 characters">
157
+
Password
158
+
</FloatingLabel>
159
+
```
160
+
161
+
### Error messages
162
+
163
+
Pass `errorMessage` to render error text below the input. It is announced by screen readers whenever the value changes (via `accessibilityLiveRegion="polite"`).
Pass `helperText` to render supplementary guidance below the input. Like `errorMessage`, it uses `accessibilityLiveRegion="polite"` for dynamic announcements.
176
+
177
+
```tsx
178
+
<FloatingLabelhelperText="We'll never share your email">Email</FloatingLabel>
179
+
```
180
+
181
+
### Focus indicators
182
+
183
+
The component does not enforce focus styles — this keeps it flexible for any design system. To implement a WCAG 2.2-compliant visible focus indicator, use `onFocus`/`onBlur` with `inputStyle`:
WCAG 2.2 requires the focus indicator to have a contrast ratio of at least 3:1 against adjacent colors.
198
+
199
+
### Touch target size
200
+
201
+
Apple and Google both recommend a minimum touch target of **44×44dp**. The component's default height is 40dp. To meet the recommendation, set `style` on the container:
0 commit comments