schiehll / react-alert

alerts for React
MIT License
607 stars 99 forks source link

change the black background #168

Closed sarahshul closed 3 years ago

sarahshul commented 3 years ago

Hi, Thanks for the alert, it is really usefull.

Is it possible to change the background of the alert?

I want to change it from black to a different color.

Thanks.

besLisbeth commented 3 years ago

Hi @sarahshul. I think that the most convenient and the right way will be to create your own custom AlertTemplate (it's not so hard). But, you can also add the property to the following AlertTemplate:

import React from "react";
import { render } from "react-dom";
import { positions, Provider } from "react-alert";
import AlertTemplate from "react-alert-template-basic";
import Home from "./Home";

const options = {
  timeout: 5000,
  position: positions.BOTTOM_CENTER
};

const CustomAlertTemplate = (props) => {
  return <AlertTemplate {...props} style={{backgroundColor: 'blue'}}/> //<---- customColor sets here
}

const App = () => (
  <Provider template={CustomAlertTemplate} {...options}>
    <Home />
  </Provider>
);

render(<App />, document.getElementById("root"));

but I think that it's not the best way to do so.