Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion docs/6.x/docs/guides/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ On web, an `IconButton` or icon-only `FAB` labelled with `aria-label`, with no h

`hitSlop` applies only to a touchable that can be pressed. Without a handler, or with `disabled`, a touchable takes no touches outside its bounds, so it doesn't take them from its neighbors.

`RadioButton`, `RadioButton.Android`, `RadioButton.IOS` and `RadioButton.Item` with no press handler and no `RadioButton.Group` no longer take the press. They stay read-only radios, a row around them gets the press, and on web they're no longer a tab stop.
`RadioButton` and `RadioButton.Item` with no press handler and no `RadioButton.Group` no longer take the press. They stay read-only radios, a row around them gets the press, and on web they're no longer a tab stop.

To have something look and announce disabled, pass `disabled`, which keeps the control and its role. Pass it to switch interactivity off at runtime too, instead of removing `onPress`. A touchable renders another element whenever it goes between having a handler or `disabled` and having neither, so its children remount and lose their state and focus. That includes toggling `disabled` on a touchable with no handler. `FAB.Menu` does this for its trigger: a trigger without `onPress` is a disabled button while the menu is closed, so it keeps its element when the menu opens.

Expand Down Expand Up @@ -905,6 +905,28 @@ On web, a menu now closes on the Escape key when it is pressed down, instead of

On Android, an open menu now also keeps the back press: it calls `onDismiss`, and the screen behind no longer goes back. Previously the press reached that screen as well. Without an `onDismiss`, the menu leaves the press to whatever is underneath, so pass one to close the menu on back.

### RadioButton

`RadioButton` renders one Material 3 circular radio control on every platform. The platform-specific components and their prop types are gone. On iOS checked controls no longer render a checkmark; they use the same ring-and-dot indicator as other platforms. `RadioButton` now also forwards `TouchableRipple` props (`accessible`, `onFocus`, `onBlur`, `borderless`, `rippleColor`, ...).

The control now occupies a 48×48dp layout box instead of 36×36dp, so rows containing it may become 12dp taller. The 20dp radio indicator is unchanged. `RadioButton.Item` rows grow from 52dp to 64dp.

#### Interaction state colors

Interaction states are now painted as a Material Design 3 state layer on every platform, so the tint follows the spec: hover & focus fill a flat 40dp layer behind the indicator with `primary` when checked and `onSurface` when not, and press inverts the two. An `error` radio stays on `error` throughout and `color`/`uncheckedColor` replace the role they already override on the ring, so custom radio no longer picks up `primary` halo. The platform ripple is turned off to make room for it; passing `rippleColor` on any platform, `background` on Android or `underlayColor` on iOS turns it back on and disables the built-in press. Setting `rippleEffectEnabled: false` on the `settings` prop of `PaperProvider` still suppresses both.

| v5 | v6 |
| ------------------------------------------------ | ------------------------------------------------------------------------ |
| `RadioButton.Android`, `RadioButton.IOS` | `RadioButton` |
| `RadioButtonAndroidProps`, `RadioButtonIOSProps` | `RadioButtonProps` |
| `RadioButton.Item` `mode="android" \| "ios"` | `mode` removed; `RadioButton.Item` always renders `RadioButton` |
| n/a | new `error` (uses `theme.colors.error`) and `style` (touch-target style) |

```diff
- <RadioButton.IOS value="first" status="checked" onPress={select} />
+ <RadioButton value="first" status="checked" onPress={select} />
```

### Searchbar

The misspelled `traileringIcon` props have been renamed:
Expand Down
2 changes: 0 additions & 2 deletions docs/component-docs.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ const pages = {
ProgressBar: 'ProgressBar',
RadioButton: {
RadioButton: 'RadioButton/RadioButton',
RadioButtonAndroid: 'RadioButton/RadioButtonAndroid',
RadioButtonGroup: 'RadioButton/RadioButtonGroup',
RadioButtonIOS: 'RadioButton/RadioButtonIOS',
RadioButtonItem: 'RadioButton/RadioButtonItem',
},
Searchbar: 'Searchbar',
Expand Down
17 changes: 2 additions & 15 deletions docs/src/data/screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,11 @@ export const screenshots = {
Modal: 'screenshots/modal.gif',
ProgressBar: 'screenshots/progress-bar.png',
RadioButton: {
'Android (enabled)': 'screenshots/radio-enabled.android.png',
'Android (disabled)': 'screenshots/radio-disabled.android.png',
'iOS (enabled)': 'screenshots/radio-enabled.ios.png',
'iOS (disabled)': 'screenshots/radio-disabled.ios.png',
},
'RadioButton.Android': {
enabled: 'screenshots/radio-enabled.android.png',
disabled: 'screenshots/radio-disabled.android.png',
},
Comment thread
jacekAtCK marked this conversation as resolved.
Resolved
'RadioButton.Group': {
Android: 'screenshots/radio-button-group-android.gif',
iOS: 'screenshots/radio-button-group-ios.gif',
},
'RadioButton.IOS': {
enabled: 'screenshots/radio-enabled.ios.png',
disabled: 'screenshots/radio-disabled.ios.png',
},
'RadioButton.Item': 'screenshots/radio-item.ios.png',
// The iOS radio assets show a checkmark that 6.x no longer draws.
'RadioButton.Group': 'screenshots/radio-button-group-android.gif',
Searchbar: {
bar: 'screenshots/searchbar.png',
view: 'screenshots/searchbar-view.png',
Expand Down
46 changes: 30 additions & 16 deletions example/src/Examples/RadioButtonExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

import ScreenWrapper from '../ScreenWrapper';

type State = 'normal' | 'normal-ios' | 'normal-item' | 'custom';
type State = 'normal' | 'normal-item' | 'custom';

const RadioButtonExample = () => {
const [checked, setChecked] = React.useState<State>('normal');
Expand All @@ -19,26 +19,15 @@ const RadioButtonExample = () => {
<ScreenWrapper style={styles.container}>
<TouchableRipple onPress={() => setChecked('normal')}>
<View style={styles.row}>
<Text>Normal - Material Design</Text>
<Text>Normal</Text>
<View pointerEvents="none">
<RadioButton.Android
<RadioButton
value="normal"
status={checked === 'normal' ? 'checked' : 'unchecked'}
/>
</View>
</View>
</TouchableRipple>
<TouchableRipple onPress={() => setChecked('normal-ios')}>
<View style={styles.row}>
<Text>Normal 2 - IOS</Text>
<View pointerEvents="none">
<RadioButton.IOS
value="normal-ios"
status={checked === 'normal-ios' ? 'checked' : 'unchecked'}
/>
</View>
</View>
</TouchableRipple>
<TouchableRipple onPress={() => setChecked('custom')}>
<View style={styles.row}>
<Text>Custom</Text>
Expand All @@ -58,11 +47,31 @@ const RadioButtonExample = () => {
onPress={() => setChecked('normal-item')}
/>
<View style={styles.row}>
<Text>Checked (Disabled)</Text>
<Text>Error (Checked)</Text>
<RadioButton value="error" status="checked" error />
</View>
<View style={styles.row}>
<Text>Error (Unchecked)</Text>
<RadioButton value="error-unchecked" status="unchecked" error />
</View>
<RadioButton.Item
label="Error - Item (Checked)"
value="error-item"
status="checked"
error
/>
<RadioButton.Item
label="Error - Item (Unchecked)"
value="error-item-unchecked"
status="unchecked"
error
/>
<View style={styles.row}>
<Text style={styles.disabledLabel}>Checked (Disabled)</Text>
<RadioButton value="first" status="checked" disabled />
</View>
<View style={styles.row}>
<Text>Unchecked (Disabled)</Text>
<Text style={styles.disabledLabel}>Unchecked (Disabled)</Text>
<RadioButton value="second" status="unchecked" disabled />
</View>
<RadioButton.Item
Expand Down Expand Up @@ -94,6 +103,11 @@ const styles = StyleSheet.create({
paddingVertical: 8,
paddingHorizontal: 16,
},
// Standalone RadioButton has no label of its own; dim the demo label to
// match the disabled control (RadioButton.Item dims its label for you).
disabledLabel: {
opacity: 0.38,
},
});

export default RadioButtonExample;
4 changes: 2 additions & 2 deletions example/src/Examples/RadioButtonGroupExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ const RadioButtonGroupExample = () => {
</View>
<View style={styles.row}>
<Text>Second</Text>
<RadioButton.Android value="second" />
<RadioButton value="second" />
</View>
<View style={styles.row}>
<Text>Third</Text>
<RadioButton.IOS value="third" />
<RadioButton value="third" />
</View>
</RadioButton.Group>
</List.Section>
Expand Down
38 changes: 15 additions & 23 deletions example/src/Examples/RadioButtonItemExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,47 @@ import ScreenWrapper from '../ScreenWrapper';

const RadioButtonItemExample = () => {
const [checkedDefault, setCheckedDefault] = React.useState(true);
const [checkedAndroid, setCheckedAndroid] = React.useState(true);
const [checkedIOS, setCheckedIOS] = React.useState(true);
const [checkedLeadingControl, setCheckedLeadingControl] =
React.useState(true);
const [checkedDisabled, setCheckedDisabled] = React.useState<boolean>(true);
const [checkedError, setCheckedError] = React.useState(true);
const [checkedLabelVariant, setCheckedLabelVariant] = React.useState(true);

return (
<ScreenWrapper style={styles.container}>
<RadioButton.Item
label="Default (will look like whatever system this is running on)"
label="Default (trailing control)"
status={checkedDefault ? 'checked' : 'unchecked'}
onPress={() => setCheckedDefault(!checkedDefault)}
value="default"
/>
<RadioButton.Item
label="Material Design"
mode="android"
status={checkedAndroid ? 'checked' : 'unchecked'}
onPress={() => setCheckedAndroid(!checkedAndroid)}
value="android"
/>
<RadioButton.Item
label="iOS"
mode="ios"
status={checkedIOS ? 'checked' : 'unchecked'}
onPress={() => setCheckedIOS(!checkedIOS)}
value="iOS"
/>
<RadioButton.Item
label="Default with leading control"
label="Leading control"
status={checkedLeadingControl ? 'checked' : 'unchecked'}
onPress={() => setCheckedLeadingControl(!checkedLeadingControl)}
value="iOS"
value="leading"
position="leading"
/>
<RadioButton.Item
label="Disabled checkbox"
label="Error"
status={checkedError ? 'checked' : 'unchecked'}
onPress={() => setCheckedError(!checkedError)}
value="error"
error
/>
<RadioButton.Item
label="Disabled"
status={checkedDisabled ? 'checked' : 'unchecked'}
onPress={() => setCheckedDisabled(!checkedDisabled)}
value="iOS"
value="disabled"
disabled
/>
<RadioButton.Item
label="Default with titleLarge title variant"
label="titleLarge label variant"
labelVariant="titleLarge"
status={checkedLabelVariant ? 'checked' : 'unchecked'}
onPress={() => setCheckedLabelVariant(!checkedLabelVariant)}
value="default"
value="variant"
/>
</ScreenWrapper>
);
Expand Down
Loading
Loading