I'm having an issue with nextjs/reactjs. I have two tsx files: index.tsx and customAlert.tsx. The issue that I'm having is that the alert doesn't seem to change colour even though the css classes are added to the alert html element. For css I'm using tailwind and it works fine and it's not the issue.
pages/_app.tsx
import type { AppProps } from "next/app"
import "tailwindcss/tailwind.css"
export default function MyApp({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}
components/customAlert.tsx
export default function customAlert(status: string, title: string, message: string) {
const types: {[key: string]: any} = {success: "green", error: "red", warning: "yellow"}
const colour = types[status]
return (
<>
<div id="alert" className="absolute bottom-0 right-0 mb-4 mr-4">
<div className={`bg-${colour}-500 text-white font-bold rounded-t px-4 py-2`}>
{title}
</div>
<div className={`border border-t-0 border-${colour}-400 rounded-b bg-${colour}-100 px-4 py-3 text-${colour}-700`}>
<p>{message}</p>
</div>
</div>
</>
)
}
pages/index.tsx
import customAlert from "../components/customAlert"
export default function Index() {
return(
<div>
{customAlert("success", "hi mom", "hi mom")}
</div>
)
}