iamhosseindhv / notistack

Highly customizable notification snackbars (toasts) that can be stacked on top of each other
https://notistack.com
Other
3.93k stars 298 forks source link

Is there a way to customize font-size and line-height? #44

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi @iamhosseindhv!

Great job! I use notistack quite often but I have a question. How can I customize font-size and line-height properties on SnackbarItem component? It seems like they are hardcoded: https://github.com/iamhosseindhv/notistack/blob/master/src/SnackbarItem/SnackbarItem.styles.js#L10

Thanks in advance!

iamhosseindhv commented 5 years ago

@czelusniakdawid You can do so by overriding classes. see material-ui docs for more info.

example: https://codesandbox.io/s/3qr4owqnmq

const styles = {
  base: {
    fontSize: 33,
  },
};

const App = ({ classes }) => (
    <SnackbarProvider
      maxSnack={3}
      classes={{
        base: classes.base,
      }}
    >
        <MessageButtons />
    </SnackbarProvider>
);
elitan commented 5 years ago

Is there a way to do this on the SnackbarProvider-component directly?

Something like:

    <SnackbarProvider
      maxSnack={3}
      classes={{
        base: { fontSize: 33 }
      }}
    >
iamhosseindhv commented 5 years ago

@elitan Classes prop only accepts string values (i.e. name of the class) and not objects.

elitan commented 5 years ago

@elitan Classes prop only accepts string values (i.e. name of the class) and not objects.

I am not sure how that relates to my question.

iamhosseindhv commented 5 years ago

Meaning that value for the key base (in your example), must be a string, while you are passing an object.

<SnackbarProvider
      maxSnack={3}
      classes={{
        base: { fontSize: 33 } // <-- object ❌
        base: 'name-of-the-class' // <-- string ✅
      }}
    >

code example: https://codesandbox.io/s/2014qr4vvn