Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c5ccac1
refactor: updated Dialog to comply with Material3 guidelines
kachmashk Aug 20, 2026
c5b082e
refactor: introduced new Dialog API, updated docs
kachmashk Aug 25, 2026
ff3a235
refactor: added new test cases for new Dialog API
kachmashk Aug 25, 2026
c89fa6a
refactor: updated Examples, duplicated dialogs using new Dialog API
kachmashk Aug 25, 2026
604ad61
docs: updated docs for Dialog compound components
kachmashk Aug 25, 2026
3cc050f
refactor: removed children from Dialog, updated Example, updated tests
kachmashk Aug 27, 2026
f5d993b
refactor: removed cloneElement from DialogActions, changed actions type
kachmashk Aug 27, 2026
fb5ed76
refactor: dropped cloneElement and updated arialabel for Dialog
kachmashk Aug 28, 2026
a61e3fc
docs: updated docs
kachmashk Aug 28, 2026
78e193b
refactor: changed accessibilityLabel into aria-label
kachmashk Aug 28, 2026
40c7a0e
refactor: updated styles for contents in Dialog
kachmashk Aug 28, 2026
8699f6a
docs: updated migration.md
kachmashk Aug 28, 2026
3a4fe91
refactor: updated migration.md
kachmashk Aug 28, 2026
5dd801f
refactor: addressed comments, updated docs
kachmashk Sep 1, 2026
943fd0f
refactor: conflicts fix
kachmashk Sep 2, 2026
be7466c
docs: fixed description for icon prop in Dialog
kachmashk Sep 2, 2026
bb3d49d
refactor: addressed comments
kachmashk Sep 2, 2026
9556234
refactor(dialog): addressed all recent comments
kachmashk Nov 12, 2026
e145888
refactor(dialog): remove 6.x Dialog docs
kachmashk Nov 12, 2026
154fd3d
refactor(dialog): removed old componentDocs6x.json
kachmashk Nov 12, 2026
bf50e9e
refactor: addressed comments
kachmashk Nov 16, 2026
2fbe044
refactor(dialog): updated docs, migration and added tests
kachmashk Nov 16, 2026
4ab86a5
refactor(dialog): make the Dialog parts internal
Doberjohn Nov 17, 2026
8dac248
docs(dialog): list the removed Dialog parts in the migration guide
Doberjohn Nov 17, 2026
60bfcc0
refactor(dialog): drop the removed parts' types and docs data
Doberjohn Nov 17, 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
93 changes: 74 additions & 19 deletions docs/6.x/docs/guides/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,23 +603,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 @@ -629,9 +626,65 @@ 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.

#### `Dialog.Actions`
#### 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**

- **`children`** was removed from `Dialog`. A dialog with children renders none of them.
- **`Dialog.Icon`**, **`Dialog.Title`**, **`Dialog.Content`**, **`Dialog.Actions`** and **`Dialog.ScrollArea`** were removed, with the `DialogActionsProps` and `DialogIconProps` types. `DialogTitleProps`, `DialogContentProps` and `DialogScrollAreaProps` stay, for typing `titleProps`, `contentProps` and `scrollAreaProps`.

Use the dedicated props instead:

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

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. The passed components are laid out in the dialog's actions row, 8dp apart.

**New props**

- **`scrollable`** renders the dialog content inside a scrollable area.
- **`contentProps`** passes props to the `View` that holds the content when `scrollable` is not enabled.
- **`scrollAreaProps`** passes props to the `View` that holds the `ScrollView` and its dividers 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>

`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:
// 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

The dialog no longer injects `compact` on its action 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:

```tsx
// Before (v5)
Expand All @@ -640,11 +693,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
5 changes: 0 additions & 5 deletions docs/component-docs.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ const pages = {
},
Dialog: {
Dialog: 'Dialog/Dialog',
DialogActions: 'Dialog/DialogActions',
DialogContent: 'Dialog/DialogContent',
DialogIcon: 'Dialog/DialogIcon',
DialogScrollArea: 'Dialog/DialogScrollArea',
DialogTitle: 'Dialog/DialogTitle',
},
Divider: 'Divider',
Drawer: {
Expand Down
5 changes: 0 additions & 5 deletions docs/src/data/screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ export const screenshots = {
'DataTable.Row': 'screenshots/data-table-row-cell.png',
'DataTable.Title': 'screenshots/data-table-header.png',
Dialog: 'screenshots/dialog-1.png',
'Dialog.Actions': 'screenshots/dialog-actions.png',
'Dialog.Content': 'screenshots/dialog-content.png',
'Dialog.Icon': 'screenshots/dialog-icon.png',
'Dialog.ScrollArea': 'screenshots/dialog-scroll-area.gif',
'Dialog.Title': 'screenshots/dialog-title.png',
Divider: 'screenshots/divider.png',
'Drawer.CollapsedItem': 'screenshots/drawer-collapsed.png',
'Drawer.Item': 'screenshots/drawer-item.png',
Expand Down
12 changes: 2 additions & 10 deletions docs/src/data/themeColors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,9 @@ export const themeColors = {
},
Dialog: {
'-': {
backgroundColor: 'theme.colors.elevation.level3',
},
},
'Dialog.Icon': {
'-': {
backgroundColor: 'theme.colors.surfaceContainerHigh',
iconColor: 'theme.colors.secondary',
},
},
'Dialog.ScrollArea': {
'-': {
borderColor: 'theme.colors.surfaceVariant',
dividerColor: 'theme.colors.outlineVariant',
},
},
Divider: {
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;
Loading
Loading