File tree 3 files changed +67
-0
lines changed
Libraries/Components/TextInput
packages/rn-tester/js/examples/TextInput
3 files changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -532,6 +532,13 @@ export type Props = $ReadOnly<{|
532
532
*/
533
533
editable ?: ?boolean ,
534
534
535
+ /** `readOnly` works like the `readonly` attribute in HTML.
536
+ * If `true`, text is not editable. The default value is `false`.
537
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly
538
+ * for more details.
539
+ */
540
+ readOnly ?: ?boolean ,
541
+
535
542
forwardedRef ?: ?ReactRefSetter <
536
543
React . ElementRef < HostComponent < mixed >> & ImperativeMethods ,
537
544
> ,
@@ -1381,6 +1388,7 @@ const ExportedForwardRef: React.AbstractComponent<
1381
1388
allowFontScaling = true ,
1382
1389
rejectResponderTermination = true ,
1383
1390
underlineColorAndroid = 'transparent' ,
1391
+ readOnly = false ,
1384
1392
...restProps
1385
1393
} ,
1386
1394
forwardedRef : ReactRefSetter <
@@ -1392,6 +1400,7 @@ const ExportedForwardRef: React.AbstractComponent<
1392
1400
allowFontScaling = { allowFontScaling }
1393
1401
rejectResponderTermination = { rejectResponderTermination }
1394
1402
underlineColorAndroid = { underlineColorAndroid }
1403
+ editable = { ! readOnly }
1395
1404
{ ...restProps }
1396
1405
forwardedRef = { forwardedRef }
1397
1406
/>
Original file line number Diff line number Diff line change @@ -347,6 +347,35 @@ exports.examples = ([
347
347
) ;
348
348
} ,
349
349
} ,
350
+ {
351
+ title : 'Editable and Read only ',
352
+ render : function ( ) : React . Node {
353
+ return (
354
+ < View >
355
+ < TextInput
356
+ placeholder = "editable text input using editable prop"
357
+ style = { styles . default }
358
+ editable
359
+ />
360
+ < TextInput
361
+ placeholder = "uneditable text input using editable prop"
362
+ style = { styles . default }
363
+ editable = { false }
364
+ />
365
+ < TextInput
366
+ placeholder = "editable text input using readOnly prop"
367
+ style = { styles . default }
368
+ readOnly = { false }
369
+ />
370
+ < TextInput
371
+ placeholder = "uneditable text input using readOnly prop"
372
+ style = { styles . default }
373
+ readOnly
374
+ />
375
+ </ View >
376
+ ) ;
377
+ } ,
378
+ } ,
350
379
{
351
380
title : 'Fixed number of lines' ,
352
381
platform : 'android' ,
Original file line number Diff line number Diff line change @@ -621,6 +621,35 @@ exports.examples = ([
621
621
) ;
622
622
} ,
623
623
} ,
624
+ {
625
+ title : 'Editable and Read only ',
626
+ render : function ( ) : React . Node {
627
+ return (
628
+ < View >
629
+ < TextInput
630
+ placeholder = "editable text input using editable prop"
631
+ style = { styles . default }
632
+ editable
633
+ />
634
+ < TextInput
635
+ placeholder = "uneditable text input using editable prop"
636
+ style = { styles . default }
637
+ editable = { false }
638
+ />
639
+ < TextInput
640
+ placeholder = "editable text input using readOnly prop"
641
+ style = { styles . default }
642
+ readOnly = { false }
643
+ />
644
+ < TextInput
645
+ placeholder = "uneditable text input using readOnly prop"
646
+ style = { styles . default }
647
+ readOnly
648
+ />
649
+ </ View >
650
+ ) ;
651
+ } ,
652
+ } ,
624
653
{
625
654
title : 'TextInput Intrinsic Size' ,
626
655
render : function ( ) : React . Node {
You can’t perform that action at this time.
0 commit comments