Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e57a1b0
refactor: updated Dialog to comply with Material3 guidelines
kachmashk Aug 20, 2026
efd00b8
refactor: introduced new Dialog API, updated docs
kachmashk Aug 25, 2026
8288d13
refactor: added new test cases for new Dialog API
kachmashk Aug 25, 2026
a1f932c
refactor: updated Examples, duplicated dialogs using new Dialog API
kachmashk Aug 25, 2026
93d847f
docs: updated docs for Dialog compound components
kachmashk Aug 25, 2026
cf46824
refactor: removed children from Dialog, updated Example, updated tests
kachmashk Aug 27, 2026
6dcadc8
refactor: removed cloneElement from DialogActions, changed actions type
kachmashk Aug 27, 2026
72b5ded
refactor: dropped cloneElement and updated arialabel for Dialog
kachmashk Aug 28, 2026
f05a569
docs: updated docs
kachmashk Aug 28, 2026
376ff2d
refactor: changed accessibilityLabel into aria-label
kachmashk Aug 28, 2026
e8f15f8
refactor: updated styles for contents in Dialog
kachmashk Aug 28, 2026
3a46ed1
docs: updated migration.md
kachmashk Aug 28, 2026
8d8fee8
refactor: updated migration.md
kachmashk Aug 28, 2026
60afb66
refactor: addressed comments, updated docs
kachmashk Sep 1, 2026
aea53f6
refactor: conflicts fix
kachmashk Sep 2, 2026
2d9773e
docs: fixed description for icon prop in Dialog
kachmashk Sep 2, 2026
0d66b25
refactor: addressed comments
kachmashk Sep 2, 2026
02a6c6a
refactor(dialog): addressed all recent comments
kachmashk Nov 12, 2026
88fb119
refactor(dialog): remove 6.x Dialog docs
kachmashk Nov 12, 2026
292e764
refactor(dialog): removed old componentDocs6x.json
kachmashk Nov 12, 2026
687c821
refactor: addressed comments
kachmashk Nov 16, 2026
d802f69
refactor(dialog): updated docs, migration and added tests
kachmashk Nov 16, 2026
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
87 changes: 70 additions & 17 deletions docs/6.x/docs/guides/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -573,23 +573,20 @@ const buttonRef = React.useRef<React.ComponentRef<typeof View>>(null);

```diff
-<Portal>
- <Dialog visible={visible} onDismiss={hideDialog}>
- <Dialog.Title>Alert</Dialog.Title>
- </Dialog>
- <Dialog visible={visible} onDismiss={hideDialog} title="Alert" />
-</Portal>
+<Dialog visible={visible} onDismiss={hideDialog}>
+ <Dialog.Title>Alert</Dialog.Title>
+</Dialog>
+<Dialog visible={visible} onDismiss={hideDialog} title="Alert" />
```

The dialog now has the `dialog` role. On web, the dialog's accessible name is set automatically by `Dialog.Title`. You can specify a different name with the new `aria-label` prop, e.g. when the dialog has no title:
The dialog now has the `dialog` role. Its accessible name is set automatically from the `title` prop. A string title is used as the `aria-label` on all platforms. Any other title is linked through `aria-labelledby`, which applies on web only, so on iOS and Android the dialog has no name unless you set `aria-label`. You can specify a different name with the new `aria-label` prop, e.g. when the dialog has no title:

```jsx
<Dialog visible={visible} onDismiss={hideDialog} aria-label="Delete file">
<Dialog.Content>
<Text>Are you sure?</Text>
</Dialog.Content>
</Dialog>
<Dialog
visible={visible}
onDismiss={hideDialog}
content="Are you sure?"
aria-label="Delete file"
/>
```

`Dialog` follows the same back button, Escape key and focus behavior as `Modal`, including the `initialFocusRef` and `restoreFocusRef` props. As with `Modal`, focus returns on iOS and Android only when you pass `restoreFocusRef`.
Expand All @@ -599,6 +596,60 @@ When the dialog is `dismissable`, screen reader users can dismiss it with a visu
- The default elevation changed from level `1` to level `3`.
- The `style` prop no longer configures the background color or border radius. You can override `theme.colors.surfaceContainerHigh` and `theme.shapes.corner.extraLarge` using the `theme` prop instead.

#### Prop-based API

The Paper 6.x `Dialog` now supports a simplified prop-based API for common dialog layouts. If your dialog previously composed `Dialog.Title`, `Dialog.Content`, and `Dialog.Actions` via `children`, migrate to the dedicated `icon`, `title`, `content`, and `actions` props.

**Removed props**

- **`children`** was removed from `Dialog`

Use the dedicated props instead:

- **`Dialog.Icon`** → **`icon`**
- **`Dialog.Title`** → **`title`**
- **`Dialog.Content`** → **`content`**
- **`Dialog.Actions`** → **`actions`**

The new **`actions`** prop is more customizable because it accepts **`React.ReactNode[]`**. Unlike the previous `Dialog.Actions` children behavior, the dialog no longer injects **`compact`** and **`uppercase`** into action components automatically. When **`actions`** is provided, the passed components are rendered through **`Dialog.Actions`** internally.

**New props**

- **`scrollable`** renders the dialog content inside a scrollable area.
- **`contentProps`** passes props to the internal `Dialog.Content` when `scrollable` is not enabled.
- **`scrollAreaProps`** passes props to the internal `Dialog.ScrollArea` when `scrollable` is enabled.
- **`scrollViewProps`** passes props to the internal `ScrollView` when `scrollable` is enabled.
- **`aria-label`** overrides the title as the dialog's accessible name. Set it when the `title` isn't a string, since iOS and Android can't use `aria-labelledby`.
- **`aria-labelledby`** is the `nativeID` of an element that provides the dialog's accessible name. It takes precedence over the title and is applied on web only.

```tsx
// Before (v5)
<Portal>
<Dialog visible={visible} onDismiss={hideDialog}>
<Dialog.Title>Alert</Dialog.Title>
<Dialog.Content>
<Text variant="bodyMedium">This is a simple dialog</Text>
</Dialog.Content>
<Dialog.Actions>
<Button onPress={hideDialog}>Done</Button>
</Dialog.Actions>
</Dialog>
</Portal>

// After (v6)
<Dialog
visible={visible}
onDismiss={hideDialog}
title="Alert"
content="This is a simple dialog"
actions={[
<Button key="done" onPress={hideDialog}>
Done
</Button>,
]}
/>
```

#### `Dialog.Actions`

`Dialog.Actions` no longer injects `compact` on its buttons, and the default [`Button`](#button) mode is now `filled`. Add `mode="text"` to each button. At the default `small` size, the buttons are **40dp** tall, the Material Design 3 size for dialog actions. The `compact` text buttons in 5.x were **38dp** tall. For a more compact look, also add `size="extra-small"`, which is **32dp** tall:
Expand All @@ -610,11 +661,13 @@ When the dialog is `dismissable`, screen reader users can dismiss it with a visu
</Dialog.Actions>

// After (v6)
<Dialog.Actions>
<Button mode="text" onPress={hide}>
Done
</Button>
</Dialog.Actions>
<Dialog
actions={[
<Button key="done" mode="text" onPress={hide}>
Done
</Button>,
]}
/>
```

### Menu
Expand Down
22 changes: 12 additions & 10 deletions example/src/DrawerItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,11 @@ function DrawerItems() {
</Text>
</>
)}
<Dialog visible={showRTLDialog} onDismiss={_handleDismissRTLDialog}>
<Dialog.Title>Changing to RTL</Dialog.Title>
<Dialog.Content>
<Dialog
visible={showRTLDialog}
onDismiss={_handleDismissRTLDialog}
title="Changing to RTL"
content={
<Text variant="bodyMedium">
Due to Expo Go limitations it is impossible to change RTL
dynamically. To do so, you need to create a development build of
Expand All @@ -250,13 +252,13 @@ function DrawerItems() {
<Text variant="labelMedium">app.json</Text> within{' '}
<Text variant="labelMedium">example</Text> directory.
</Text>
<Dialog.Actions>
<Button mode="text" onPress={_handleDismissRTLDialog}>
Ok
</Button>
</Dialog.Actions>
</Dialog.Content>
</Dialog>
}
actions={[
<Button key="ok-btn" onPress={_handleDismissRTLDialog}>
Ok
</Button>,
]}
/>
</DrawerContentScrollView>
);
}
Expand Down
10 changes: 6 additions & 4 deletions example/src/Examples/DialogExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ const DialogExample = () => {
visible={_getVisible('dialog6')}
close={_toggleDialog('dialog6')}
/>
<DialogWithDismissableBackButton
visible={_getVisible('dialog7')}
close={_toggleDialog('dialog7')}
/>
{Platform.OS === 'android' && (
<DialogWithDismissableBackButton
visible={_getVisible('dialog7')}
close={_toggleDialog('dialog7')}
/>
)}
<DialogWithUndismissableBackButton
visible={_getVisible('dialog8')}
close={_toggleDialog('dialog8')}
Expand Down
18 changes: 0 additions & 18 deletions example/src/Examples/Dialogs/DialogTextComponent.tsx

This file was deleted.

43 changes: 29 additions & 14 deletions example/src/Examples/Dialogs/DialogWithCustomColors.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, Dialog, Palette } from 'react-native-paper';
import { StyleSheet } from 'react-native';

import { TextComponent } from './DialogTextComponent';
import { Button, Dialog, Palette, Text } from 'react-native-paper';

const DialogWithCustomColors = ({
visible,
Expand All @@ -12,26 +12,41 @@ const DialogWithCustomColors = ({
return (
<Dialog
onDismiss={close}
visible={visible}
aria-label="Alert"
theme={{
colors: {
surfaceContainerHigh: Palette.primary10,
},
}}
visible={visible}
>
<Dialog.Title style={{ color: Palette.primary95 }}>Alert</Dialog.Title>
<Dialog.Content>
<TextComponent style={{ color: Palette.primary95 }}>
title={
<Text variant="headlineSmall" style={styles.text}>
Alert
</Text>
}
content={
<Text variant="bodyMedium" style={styles.text}>
This is a dialog with custom colors
</TextComponent>
</Dialog.Content>
<Dialog.Actions>
<Button mode="text" textColor={Palette.primary95} onPress={close}>
</Text>
}
actions={[
<Button
mode="text"
key="ok-btn"
onPress={close}
textColor={Palette.primary95}
>
Ok
</Button>
</Dialog.Actions>
</Dialog>
</Button>,
]}
/>
);
};

const styles = StyleSheet.create({
text: {
color: Palette.primary95,
},
});

export default DialogWithCustomColors;
31 changes: 14 additions & 17 deletions example/src/Examples/Dialogs/DialogWithDismissableBackButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Button, Dialog, Palette } from 'react-native-paper';

import { TextComponent } from './DialogTextComponent';

const DialogWithDismissableBackButton = ({
visible,
close,
Expand All @@ -14,23 +12,22 @@ const DialogWithDismissableBackButton = ({
visible={visible}
dismissable={false}
dismissableBackButton
>
<Dialog.Title>Alert</Dialog.Title>
<Dialog.Content>
<TextComponent>
This is an undismissable dialog, however you can use hardware back
button to close it!
</TextComponent>
</Dialog.Content>
<Dialog.Actions>
<Button mode="text" textColor={Palette.tertiary50} disabled>
title="Alert"
content="This is an undismissable dialog, however you can use hardware back button to close it!"
actions={[
<Button
mode="text"
key="disagree-btn"
onPress={close}
textColor={Palette.tertiary50}
>
Disagree
</Button>
<Button mode="text" onPress={close}>
</Button>,
<Button mode="text" key="agree-btn" onPress={close}>
Agree
</Button>
</Dialog.Actions>
</Dialog>
</Button>,
]}
/>
);

export default DialogWithDismissableBackButton;
53 changes: 22 additions & 31 deletions example/src/Examples/Dialogs/DialogWithIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@
import { StyleSheet } from 'react-native';

import { Button, Dialog, Palette } from 'react-native-paper';

import { TextComponent } from './DialogTextComponent';

const DialogWithIcon = ({
visible,
close,
}: {
visible: boolean;
close: () => void;
}) => {
return (
<Dialog onDismiss={close} visible={visible}>
<Dialog.Icon icon="alert" />
<Dialog.Title style={styles.title}>Dialog with Icon</Dialog.Title>
<Dialog.Content>
<TextComponent>
This is a dialog with new component called DialogIcon. When icon is
displayed you should center the header.
</TextComponent>
</Dialog.Content>
<Dialog.Actions>
<Button mode="text" onPress={close} textColor={Palette.error50}>
Disagree
</Button>
<Button mode="text" onPress={close}>
Agree
</Button>
</Dialog.Actions>
</Dialog>
);
};
}) => (
<Dialog
onDismiss={close}
visible={visible}
icon="alert"
title="Dialog with Icon"
content="This is a dialog with a component called DialogIcon. When the icon is displayed, the title is centered automatically."
actions={[
<Button
mode="text"
key="disagree-btn"
onPress={close}
textColor={Palette.error50}
>
Disagree
</Button>,
<Button mode="text" key="agree-btn" onPress={close}>
Agree
</Button>,
]}
/>
);

const styles = StyleSheet.create({
title: {
textAlign: 'center',
},
});
export default DialogWithIcon;
Loading
Loading