Nativebase: How can I change style of Toast

Created on 19 May 2017  路  8Comments  路  Source: GeekyAnts/NativeBase

I don't find any option to change the style (e.g opacity, backgroundColor,...) of Toast from the document http://docs.nativebase.io/Components.html#Toast

So how can I do that ?

need doc

Most helpful comment

you can pass style object

Toast.show({
 text: "Wrong password!",
 type: "success",
 buttonText: "close",
 style: {
  backgroundColor: "blue"
 }
})              

All 8 comments

@Jasbir23 Need to document Toast styling
Also its been missing in CheatSheet

you can pass style object

Toast.show({
 text: "Wrong password!",
 type: "success",
 buttonText: "close",
 style: {
  backgroundColor: "blue"
 }
})              

@sankhadeeproy007 Can I change fontStyle???

I'm late for the party, but this is in case someone is having a problem with this, I managed to pull this off by doing something like this

const style = { backgroundColor: 'YOUR_BG_COLOR', ...};
const textStyle = { color: 'YOUR_TEXT_COLOR', fontFamily: 'YOUR_FONT_NAME, ... };

Toast.show({
    text: message,
    position: 'bottom',
    duration,
    style: style, // this style will go on the View
    textStyle: textStyle // this style will go on the Text
  });

These props should be added to the docs

Can I change button position?

@Aishwarya-Surana Yes!
Go through Docs

I'm late for the party, but this is in case someone is having a problem with this, I managed to pull this off by doing something like this

const style = { backgroundColor: 'YOUR_BG_COLOR', ...};
const textStyle = { color: 'YOUR_TEXT_COLOR', fontFamily: 'YOUR_FONT_NAME, ... };

Toast.show({
    text: message,
    position: 'bottom',
    duration,
    style: style, // this style will go on the View
    textStyle: textStyle // this style will go on the Text
  });

These props should be added to the docs

@IbraheemAlSaady

style: style, // this style will go on the View

nice response but can this be applied to native-base's Toast? i don't think so!

@eddiesmag

nice response but can this be applied to native-base's Toast? i don't think so!

Sure, you can add styles like this (thanks for originally sharing, @IbraheemAlSaady). I just used the following with the Toast component.

const style = {
  backgroundColor: "rgba(0,0,0,0.6)",
  marginBottom: 70
}

Toast.show({
  text: `Successfully updated ${detail}`,
  buttonText: "Okay",
  duration: 1500,
  buttonStyle: { backgroundColor: "#5cb85c" },
  style
})

Was this page helpful?
0 / 5 - 0 ratings