Skip to content

Commit 50ad345

Browse files
authored
Support rendering a bottomAccessory in TextField (#1737)
1 parent f58d4de commit 50ad345

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

demo/src/screens/incubatorScreens/IncubatorTextFieldScreen.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ export default class TextFieldScreen extends Component {
228228
placeholder="Enter text..."
229229
multiline
230230
showCharCounter
231+
bottomAccessory={
232+
<Text text100>
233+
{Assets.emojis.grapes} {Assets.emojis.melon} {Assets.emojis.banana}
234+
</Text>
235+
}
231236
charCounterStyle={{color: Colors.blue30}}
232237
maxLength={20}
233238
fieldStyle={styles.withFrame}

generatedTypes/src/incubator/TextField/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export declare type TextFieldProps = MarginModifiers & PaddingModifiers & Typogr
2525
* Pass to render a trailing element
2626
*/
2727
trailingAccessory?: ReactElement;
28+
/**
29+
* Pass to render a bottom element below the input
30+
*/
31+
bottomAccessory?: ReactElement;
2832
/**
2933
* Pass to add floating placeholder support
3034
*/

generatedTypes/src/incubator/TextField/usePreset.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export default function usePreset({ preset, ...props }: InternalTextFieldProps):
156156
charCounterStyle?: import("react-native").TextStyle | undefined;
157157
leadingAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
158158
trailingAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
159+
bottomAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
159160
validateOnStart?: boolean | undefined;
160161
validateOnChange?: boolean | undefined;
161162
validateOnBlur?: boolean | undefined;
@@ -486,6 +487,7 @@ export default function usePreset({ preset, ...props }: InternalTextFieldProps):
486487
charCounterStyle?: import("react-native").TextStyle | undefined;
487488
leadingAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
488489
trailingAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
490+
bottomAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
489491
validateOnStart?: boolean | undefined;
490492
validateOnChange?: boolean | undefined;
491493
validateOnBlur?: boolean | undefined;
@@ -1048,6 +1050,7 @@ export default function usePreset({ preset, ...props }: InternalTextFieldProps):
10481050
charCounterStyle?: import("react-native").TextStyle | undefined;
10491051
leadingAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
10501052
trailingAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
1053+
bottomAccessory?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
10511054
validateOnStart?: boolean | undefined;
10521055
validateOnChange?: boolean | undefined;
10531056
validateOnBlur: boolean;

src/incubator/TextField/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export type TextFieldProps = MarginModifiers &
5252
* Pass to render a trailing element
5353
*/
5454
trailingAccessory?: ReactElement;
55+
/**
56+
* Pass to render a bottom element below the input
57+
*/
58+
bottomAccessory?: ReactElement;
5559
/**
5660
* Pass to add floating placeholder support
5761
*/
@@ -140,6 +144,7 @@ const TextField = (props: InternalTextFieldProps) => {
140144
// Accessory Buttons
141145
leadingAccessory,
142146
trailingAccessory,
147+
bottomAccessory,
143148
// Validation
144149
enableErrors, // TODO: rename to enableValidation
145150
validationMessageStyle,
@@ -236,6 +241,7 @@ const TextField = (props: InternalTextFieldProps) => {
236241
testID={`${props.testID}.validationMessage`}
237242
/>
238243
)}
244+
{bottomAccessory}
239245
{showCharCounter && <CharCounter maxLength={others.maxLength} charCounterStyle={charCounterStyle}/>}
240246
</View>
241247
</View>

0 commit comments

Comments
 (0)