-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I add Theme? #112
Comments
Hi @uncle-link. Sorry this issue seems to have slipped by unnoticed. So, tell me if I understand. You need your React element to be rendered within a If so, there are two options:
Swal.fire({
title: (
<ThemeProvider theme={theme}>
<Typography>Hello</Typography>
</ThemeProvider>
)
})
const SwalReactContext = ({ children }) => (
<ThemeProvider theme={theme}>
{children}
</ThemeProvider>
)
const MySwal = Swal.mixin({ SwalReactContext })
MySwal.fire({
title: <Typography>Hello</Typography>
}) Option # 2 would be a bit more work, but would make things more simple and less repetitive. Not just for you but also for other developers in the same situation. And not just when providing Material UI theme context, but also when providing any kind of context. The choice is yours. :) Please let me know if/how you've resolved this. If I didn't understand correctly, please clarify for me. Thanks! |
@uncle-link That is correct. There is currently no Probably you want to go with option # 1 (refer to my comment above), which is the only way to accomplish what you want with this library as-is. |
Our project has material ui, and when I use title: hello, user interface will override by default Tpyography theme, which inject later, so I think the Swal is independent system, so I need add Theme to the component Typography. So can I add Theme in the Swal root?
The text was updated successfully, but these errors were encountered: