Skip to content

Commit 465f972

Browse files
committed
Add accessibility and font size customization
Introduces comprehensive WCAG 2.1 AA accessibility support, including screen reader roles, live region, custom labels/hints, font scaling, color contrast validation, haptic feedback, and dynamic sizing utilities. Adds per-toast and global font size overrides, updates Toast component and types for accessibility props, and exposes new utilities for sizing and accessibility. Updates documentation and example app to demonstrate new features.
1 parent 8df53da commit 465f972

File tree

13 files changed

+2014
-162
lines changed

13 files changed

+2014
-162
lines changed

README.md

Lines changed: 710 additions & 13 deletions
Large diffs are not rendered by default.

example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
},
1111
"dependencies": {
1212
"@expo/metro-runtime": "~6.1.2",
13-
"expo": "~54.0.16",
13+
"expo": "^54.0.17",
1414
"expo-status-bar": "~3.0.8",
1515
"react": "19.1.0",
1616
"react-dom": "19.1.0",
1717
"react-native": "0.81.4",
18-
"react-native-safe-area-context": "^5.6.0",
18+
"react-native-safe-area-context": "^5.6.1",
1919
"react-native-web": "~0.21.2"
2020
},
2121
"private": true,

example/src/App.tsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type ButtonConfig = {
1616
label: string;
1717
type: ToastType;
1818
persistent?: boolean;
19+
customFontSize?: boolean;
1920
};
2021

2122
type ToggleOption<T> = {
@@ -28,6 +29,7 @@ const BUTTONS: ButtonConfig[] = [
2829
{ label: 'Warning toast', type: 'warning' },
2930
{ label: 'Info toast', type: 'info' },
3031
{ label: 'Error toast', type: 'error' },
32+
{ label: 'Large Font Toast', type: 'success', customFontSize: true },
3133
{ label: 'Persistent toast', type: 'info', persistent: true },
3234
];
3335

@@ -80,6 +82,17 @@ const ToastDemo: React.FC = () => {
8082
return;
8183
}
8284

85+
if (config.customFontSize) {
86+
addToast({
87+
type: config.type,
88+
title: 'Custom Font Sizes',
89+
message: 'This toast uses larger fonts for emphasis.',
90+
titleFontSize: 20,
91+
messageFontSize: 18,
92+
});
93+
return;
94+
}
95+
8396
addToast({
8497
type: config.type,
8598
title: config.type.toUpperCase(),
@@ -191,6 +204,14 @@ const ToastDemo: React.FC = () => {
191204
keyboard when needed.
192205
</Text>
193206
</View>
207+
208+
<View style={styles.tipBanner}>
209+
<Text style={styles.tipEmoji}>🎨</Text>
210+
<Text style={styles.tipText}>
211+
Try the "Large Font Toast" button to see per-toast font size
212+
customization!
213+
</Text>
214+
</View>
194215
</View>
195216

196217
<Text style={styles.helper}>Tap any button to trigger a toast.</Text>
@@ -360,7 +381,15 @@ const styles = StyleSheet.create({
360381
});
361382

362383
const App: React.FC = () => (
363-
<ToastProvider>
384+
<ToastProvider
385+
initialConfig={{
386+
font: {
387+
// Customize font sizes globally (optional)
388+
titleFontSize: 17,
389+
messageFontSize: 14,
390+
},
391+
}}
392+
>
364393
<ToastDemo />
365394
</ToastProvider>
366395
);

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"@react-native/babel-preset": "0.82.1",
6969
"@react-native/eslint-config": "^0.82.1",
7070
"@release-it/conventional-changelog": "^10.0.1",
71-
"@testing-library/react-native": "^12.5.2",
71+
"@testing-library/react-native": "^13.3.3",
7272
"@types/jest": "^30.0.0",
7373
"@types/react": "^19.2.2",
7474
"babel-plugin-react-compiler": "^1.0.0",
@@ -79,11 +79,11 @@
7979
"eslint-plugin-prettier": "^5.5.4",
8080
"jest": "^30.2.0",
8181
"prettier": "^3.6.2",
82-
"react": "19.1.0",
82+
"react": "19.1.1",
8383
"react-native": "0.82.1",
8484
"react-native-builder-bob": "^0.40.13",
85-
"react-native-safe-area-context": "^4.12.5",
86-
"react-test-renderer": "19.1.0",
85+
"react-native-safe-area-context": "^5.6.1",
86+
"react-test-renderer": "19.1.1",
8787
"release-it": "^19.0.5",
8888
"typescript": "^5.9.3"
8989
},

0 commit comments

Comments
 (0)