Skip to content

Commit aa8bdd9

Browse files
committed
docs: update Button usage in guides to label prop
Update the hand-written guide snippets (icons, react-navigation, ripple effect) and the docs-site example components to use the new `label` prop instead of children. The generated component reference pages are derived from the JSDoc and will be regenerated by the docs build.
1 parent 2616c98 commit aa8bdd9

5 files changed

Lines changed: 40 additions & 36 deletions

File tree

docs/docs/guides/03-icons.mdx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ You can pass the name of an icon from [`MaterialDesignIcons`](https://pictogramm
2727
Example:
2828

2929
```js
30-
<Button icon="camera">Press me</Button>
30+
<Button icon="camera" label="Press me" />
3131
```
3232

3333
:::note
@@ -63,15 +63,14 @@ Remote image:
6363
```js
6464
<Button
6565
icon={{ uri: 'https://avatars0.githubusercontent.com/u/17571969?v=3&s=400' }}
66-
>
67-
Press me
68-
</Button>
66+
label="Press me"
67+
/>
6968
```
7069

7170
Local image:
7271

7372
```js
74-
<Button icon={require('../assets/chameleon.jpg')}>Press me</Button>
73+
<Button icon={require('../assets/chameleon.jpg')} label="Press me" />
7574
```
7675

7776
### 3. A render function
@@ -88,9 +87,8 @@ Example:
8887
style={{ width: size, height: size, tintColor: color }}
8988
/>
9089
)}
91-
>
92-
Press me
93-
</Button>
90+
label="Press me"
91+
/>
9492
```
9593

9694
### 4. Use custom icons
@@ -131,15 +129,14 @@ Example for using an image source:
131129
},
132130
direction: 'rtl',
133131
}}
134-
>
135-
Press me
136-
</Button>
132+
label="Press me"
133+
/>
137134
```
138135

139136
Example for using an icon name:
140137

141138
```js
142-
<Button icon={{ source: 'add-a-photo', direction: 'rtl' }}>Press me</Button>
139+
<Button icon={{ source: 'add-a-photo', direction: 'rtl' }} label="Press me" />
143140
```
144141

145142
You can also use a render function. Along with `size` and `color`, you have access to `direction` which will either be `'rtl'` or `'ltr'`. You can then decide how to render your icon component accordingly.
@@ -163,7 +160,6 @@ Example of using a render function:
163160
]}
164161
/>
165162
)}
166-
>
167-
Press me
168-
</Button>
163+
label="Press me"
164+
/>
169165
```

docs/docs/guides/09-react-navigation.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ function HomeScreen({ navigation }) {
8686
return (
8787
<View style={style.container}>
8888
<Text>Home Screen</Text>
89-
<Button mode="contained" onPress={() => navigation.navigate('Details')}>
90-
Go to details
91-
</Button>
89+
<Button
90+
mode="contained"
91+
onPress={() => navigation.navigate('Details')}
92+
label="Go to details"
93+
/>
9294
</View>
9395
);
9496
}

docs/docs/guides/11-ripple-effect.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ The `rippleColor` prop is available for every pressable component which allows y
1919
rippleColor="#FF000020"
2020
icon="camera"
2121
mode="contained"
22-
onPress={() => console.log('Pressed')}>
23-
Press me
24-
</Button>
22+
onPress={() => console.log('Pressed')}
23+
label="Press me"
24+
/>
2525
```
2626
2727
## Disable ripple effect in all components

docs/src/components/BannerExample.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,19 @@ const BannerExample = () => {
7474
>
7575
<Stack spacing={16}>
7676
<Stack direction="row" spacing={8} style={styles.row}>
77-
<Button loading onPress={() => {}}>
78-
Loading
79-
</Button>
80-
<Button mode="contained-tonal" icon="camera" onPress={() => {}}>
81-
Icon
82-
</Button>
83-
<Button icon="camera" mode="contained" onPress={() => {}}>
84-
Press me
85-
</Button>
77+
<Button loading onPress={() => {}} label="Loading" />
78+
<Button
79+
mode="contained-tonal"
80+
icon="camera"
81+
onPress={() => {}}
82+
label="Icon"
83+
/>
84+
<Button
85+
icon="camera"
86+
mode="contained"
87+
onPress={() => {}}
88+
label="Press me"
89+
/>
8690
<FAB icon="plus" size="small" onPress={() => {}} />
8791
<FAB icon="plus" size="medium" onPress={() => {}} />
8892
<FAB icon="plus" size="large" onPress={() => {}} />

docs/src/components/GetStartedButtons.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ const GetStartedButton = () => {
3636
return (
3737
<View style={styles.container}>
3838
<Link to="/docs/guides/getting-started" style={noTextDecoration}>
39-
<Button mode="contained" style={styles.button} onPress={noop}>
40-
Get started
41-
</Button>
39+
<Button
40+
mode="contained"
41+
style={styles.button}
42+
onPress={noop}
43+
label="Get started"
44+
/>
4245
</Link>
4346
<Button
4447
mode="outlined"
@@ -47,9 +50,8 @@ const GetStartedButton = () => {
4750
'https://snack.expo.dev/@react-native-paper/react-native-paper-example_v5'
4851
)
4952
}
50-
>
51-
Try on Snack
52-
</Button>
53+
label="Try on Snack"
54+
/>
5355
</View>
5456
);
5557
};

0 commit comments

Comments
 (0)