Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
10b7acf
fix: make hidden banner content inert and fix region semantics
lukemorawski Nov 13, 2026
e5f2694
fix: call show/hide animation callbacks only on animation finished
lukemorawski Nov 13, 2026
2dca9a4
fix: announce banner on every show and stop focus restore crashing web
lukemorawski Nov 13, 2026
2872525
fix: keep a touchableRef passed through an action
lukemorawski Nov 13, 2026
d809243
refactor: drop the type casts flagged in review
lukemorawski Aug 20, 2026
1f3be42
refactor: drop the as any casts from the animation mocks
lukemorawski Aug 20, 2026
e62c969
fix: reflow actions on measured width instead of flex wrap
lukemorawski Nov 13, 2026
05861a5
fix: address review on test ids, focus, action refs and icon role
lukemorawski Nov 13, 2026
3060180
test: follow main's button test ids in banner tests
lukemorawski Nov 13, 2026
523bd74
fix: use main's host instance ref types in banner
lukemorawski Nov 13, 2026
fabf491
fix: focus the host instance directly on web
lukemorawski Nov 13, 2026
47c73d1
test: update banner snapshots after rebase
lukemorawski Nov 13, 2026
f2c1cfa
chore(example): label the banner example FABs
lukemorawski Nov 17, 2026
a93515c
fix(banner): address review on layout, inert, announce and focus rescue
lukemorawski Nov 17, 2026
9d8c48c
test(banner): cover reshow without actions, drop style reflow tests
lukemorawski Nov 17, 2026
e9e1e7c
chore(example): use the review wording for the urgent FAB label
lukemorawski Nov 17, 2026
49808c7
docs(migration): add the banner changes
lukemorawski Nov 17, 2026
f1100c8
fix(banner): follow the reduce motion api from #5235
lukemorawski Nov 18, 2026
6e8faf8
fix(banner): type host refs for legacy RN types
lukemorawski Nov 18, 2026
fc3d468
Merge branch 'main' into feat/banner-a11y-inert-when-hidden
Doberjohn Dec 4, 2026
9fe01df
feat(banner)!: take the text as message and the rest as content
Doberjohn Dec 4, 2026
4a40720
fix(banner): keep a re-shown banner when a late hide report arrives
Doberjohn Dec 4, 2026
13a4a27
fix(banner): drop animation reports from an earlier visible change
Doberjohn Dec 4, 2026
96494da
fix(banner): keep the cleanup a consumer touchableRef returns
Doberjohn Dec 4, 2026
f4fb1b7
fix(banner): fall back to the message when an action can't take focus
Doberjohn Dec 5, 2026
88cd963
fix(banner): wrap inline actions that would squeeze the message
Doberjohn Dec 5, 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
62 changes: 62 additions & 0 deletions docs/6.x/docs/guides/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,68 @@ const theme = {
};
```

`Banner` no longer takes `children`. Pass the text as the `message` string, and anything that isn't plain text, such as a `TextInput`, as `content`. TypeScript reports `children`, and in JavaScript they're ignored:

```diff
-<Banner visible={visible} actions={actions}>
- There was a problem processing a transaction on your credit card.
-</Banner>
+<Banner
+ visible={visible}
+ actions={actions}
+ message="There was a problem processing a transaction on your credit card."
+/>
```

The message is plain text, so rich inline text such as bold words or links goes. Put it in `content`, which renders below the message, outside the message's `Text` and outside the live region. A `TextInput` in `content` keeps its focus while you type on iOS, which it didn't inside the message:

```diff
-<Banner visible={visible} actions={actions}>
- Confirm your email
- <TextInput label="Email" value={email} onChangeText={setEmail} />
-</Banner>
+<Banner
+ visible={visible}
+ actions={actions}
+ message="Confirm your email"
+ content={<TextInput label="Email" value={email} onChangeText={setEmail} />}
+/>
```

A hidden `Banner` is now inert while it animates out, then its message, content and actions unmount. The content loses its local state on hide.

`onShowAnimationFinished` and `onHideAnimationFinished` run only after a `visible` change whose animation finished, not on mount or when interrupted. Under [reduce motion](#reduce-motion) the animation takes 0 ms and still counts as finished.

At most 2 actions render, the rest are ignored with a dev warning. On a window 600dp or wider the actions sit next to the message, and drop below it when they would leave it less than half the banner's width. The breakpoint follows the window, not the banner.

The message no longer has the `alert` role. Screen readers announce it politely when the banner goes from hidden to visible, not when it mounts visible or when `message` or `urgent` changes. The content isn't announced. Set the new `urgent` prop for messages that should interrupt:

```diff
-<Banner visible={visible} actions={actions}>
- Your payment failed.
-</Banner>
+<Banner
+ visible={visible}
+ actions={actions}
+ message="Your payment failed."
+ urgent
+/>
```

In tests with React Native Testing Library, `getByRole('alert')` no longer finds the banner, with or without `urgent`. Find the message by its text instead:

```diff
-screen.getByRole('alert');
+screen.getByText('Your payment failed.');
```

The icon is hidden from screen readers. Set `iconAccessibilityLabel` if it carries its own meaning.

When a focused action is removed, focus moves to the action that takes its place, or the one before it, or the message:

- **Web:** keyboard focus moves. On hide, focus returns to the element that had it when the banner showed.
- **iOS and Android:** the screen reader cursor moves if the action was just pressed. Keyboard focus doesn't move, and nothing is restored on hide.

### DataTable

- `DataTable.Title` text has a letter spacing of 0.5, and its sort icon rotates with the `standard` easing curve instead of ease-in-out.
Expand Down
66 changes: 60 additions & 6 deletions example/src/Examples/BannerExample.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Dimensions, Image, Platform, StyleSheet, View } from 'react-native';

import { Banner, FAB, Palette, useTheme } from 'react-native-paper';
import { Banner, FAB, Palette, TextInput, useTheme } from 'react-native-paper';

import ScreenWrapper from '../ScreenWrapper';

Expand All @@ -12,6 +12,9 @@ const PHOTOS = Array.from({ length: 24 }).map(
const BannerExample = () => {
const [visible, setVisible] = React.useState<boolean>(true);
const [useCustomTheme, setUseCustomTheme] = React.useState<boolean>(false);
const [urgent, setUrgent] = React.useState<boolean>(false);
const [emailVisible, setEmailVisible] = React.useState<boolean>(false);
const [email, setEmail] = React.useState<string>('');
const defaultTheme = useTheme();

const customTheme = {
Expand All @@ -27,6 +30,12 @@ const BannerExample = () => {
return (
<View style={styles.container}>
<Banner
urgent={urgent}
message={
urgent
? 'Urgent: this message interrupts the screen reader.'
: 'Two line text string with two actions. One to two lines is preferable on mobile.'
}
actions={[
{
label: `Set ${useCustomTheme ? 'default' : 'custom'} theme`,
Expand All @@ -46,10 +55,26 @@ const BannerExample = () => {
console.log('Completed closing animation')
}
theme={useCustomTheme ? customTheme : defaultTheme}
>
Two line text string with two actions. One to two lines is preferable on
mobile.
</Banner>
/>
<Banner
visible={emailVisible}
message="Confirm your email to keep getting receipts."
content={
<TextInput
label="Email"
value={email}
onChangeText={setEmail}
autoCapitalize="none"
keyboardType="email-address"
/>
}
actions={[
{
label: 'Confirm',
onPress: () => setEmailVisible(false),
},
]}
/>
<ScreenWrapper>
<View style={styles.grid}>
{PHOTOS.map((uri) => (
Expand All @@ -64,7 +89,24 @@ const BannerExample = () => {
))}
</View>
</ScreenWrapper>
<FAB icon="eye" style={styles.fab} onPress={() => setVisible(!visible)} />
<FAB
icon="email"
aria-label={emailVisible ? 'Hide email banner' : 'Show email banner'}
style={styles.emailFab}
onPress={() => setEmailVisible(!emailVisible)}
/>
<FAB
icon="eye"
aria-label={visible ? 'Hide banner' : 'Show banner'}
style={styles.fab}
onPress={() => setVisible(!visible)}
/>
<FAB
icon="alert"
aria-label={urgent ? 'Make banner not urgent' : 'Make banner urgent'}
style={styles.urgentFab}
onPress={() => setUrgent(!urgent)}
/>
</View>
);
};
Expand Down Expand Up @@ -113,6 +155,18 @@ const styles = StyleSheet.create({
bottom: 0,
margin: 16,
},
emailFab: {
alignSelf: 'flex-start',
position: 'absolute',
bottom: 0,
margin: 16,
},
urgentFab: {
alignSelf: 'flex-end',
position: 'absolute',
bottom: 0,
margin: 16,
},
});

export default BannerExample;
9 changes: 4 additions & 5 deletions example/src/Examples/ThemeExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ const ThemeExample = () => {
return (
<PaperProvider>
<ScreenWrapper contentContainerStyle={styles.container}>
<Banner visible>
React Native Paper automatically adapts theme based on system
preferences. Please change system theme to dark/light to see the
effect
</Banner>
<Banner
visible
message="React Native Paper automatically adapts theme based on system preferences. Please change system theme to dark/light to see the effect"
/>
<List.Section title={`Theme based on the source color`}>
<List.Item
title="Themed Sport App"
Expand Down
16 changes: 8 additions & 8 deletions example/src/Examples/TooltipExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ const TooltipExample = () => {
return (
<>
<ScreenWrapper>
<Banner visible>
A tooltip is displayed upon
{Platform.OS !== 'web'
? ' tapping and holding a screen element or component'
: ' hovering over a screen element or component'}
. Continuously display the tooltip as long as the user long-presses or
hovers over the element.
</Banner>
<Banner
visible
message={`A tooltip is displayed upon ${
Platform.OS !== 'web'
? 'tapping and holding a screen element or component'
: 'hovering over a screen element or component'
}. Continuously display the tooltip as long as the user long-presses or hovers over the element.`}
/>
<List.Section title="Icon Buttons">
<View style={styles.iconButtonContainer}>
{formOfTransport.map((transport, index) => (
Expand Down
Loading
Loading