Skip to content

Commit ae9cc91

Browse files
raajnadarferrannp
authored andcommitted
feat: ability to change button text case (#674)
1 parent c0f7f90 commit ae9cc91

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/components/Button.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ type Props = React.ElementConfig<typeof Surface> & {|
4848
* Label text of the button.
4949
*/
5050
children: React.Node,
51+
/**
52+
* Make the label text uppercased. Note that this won't work if you pass React elements as children.
53+
*/
54+
uppercase: boolean,
5155
/**
5256
* Accessibility label for the button. This is read by the screen reader when the user taps the button.
5357
*/
@@ -102,6 +106,7 @@ type State = {
102106
class Button extends React.Component<Props, State> {
103107
static defaultProps = {
104108
mode: 'text',
109+
uppercase: true,
105110
};
106111

107112
state = {
@@ -136,6 +141,7 @@ class Button extends React.Component<Props, State> {
136141
icon,
137142
color: buttonColor,
138143
children,
144+
uppercase,
139145
accessibilityLabel,
140146
onPress,
141147
style,
@@ -262,7 +268,9 @@ class Button extends React.Component<Props, State> {
262268
{React.Children.map(
263269
children,
264270
child =>
265-
typeof child === 'string' ? child.toUpperCase() : child
271+
typeof child === 'string' && uppercase
272+
? child.toUpperCase()
273+
: child
266274
)}
267275
</Text>
268276
</View>

0 commit comments

Comments
 (0)