setToastConfig
You can change some configs globally.
bgColor
You can change the default bgColors for each type of toast.
The default colors are:
Info: #7890f0
Success: #35d0ba
Warning: #ff9100
Error: #d92027
An example changing the default success' bgColor to olive:
import { useToast } from 'react-native-rooster';
const { setToastConfig } = useToast();
setToastConfig({
bgColor: {
success: 'olive',
},
})
font
You can change the custom fontFamily for the texts.
option | required | default | Description |
---|---|---|---|
fontFamilyRegular | No | React-Native default font | Changes the regular font used within toasts |
fontFamilyBold | No | React-Native default font | Changes the bold font used within toasts |
Note: You must have previously configured the desired custom font in your project.
An example changing fontFamilyBold
to Montserrat
family:
import { useToast } from 'react-native-rooster';
const { setToastConfig } = useToast();
setToastConfig({
font: {
fontFamilyBold: 'Montserrat-Bold',
},
})
timeToDismiss
You can change the default toast's time to dismiss.
option | required | default (ms) |
---|---|---|
timeToDismiss | No | 1500 |
To change this to 4000ms you can just do:
import { useToast } from 'react-native-rooster';
const { setToastConfig } = useToast();
setToastConfig({
timeToDismiss: 4000
})