Built-in Modal
component supports basic theming. You can create your custom theme or extend the default one.
Extending a built-in theme
Inject a serialized theme into global styles so the Modal will use CSS variables generated by the theme.
import 'w3r-modal/style.css'
import { cssStringFromTheme, defaultTheme } from 'w3r-modal'
const cssString = cssStringFromTheme({ ...defaultTheme /* override theme values here */ })
export const App = () => {
return (
<>
<style jsx global>
{`
:root {
${cssString}
}
`}
</style>
</>
)
}
Creating a theme from scratch
Below is a table of all theme values used by Modal
. All of them are necessary to set for the modal to display properly. There is a built-in Theme
type for easier value mapping.
Prop | Default | Usage |
---|---|---|
colors.modalText | #212226 | All modal text |
colors.modalCloseButton | #212226 | Color inherited by the close button |
colors.modalCloseButtonHover | #808593 | Hover state color of the close button |
colors.modalBackground | white | Modal background |
colors.modalBackdrop | rgba(0, 0, 0, 0.3) | Modal overlay background |
font | sans-serif | Font used by the modal |
radii.modal | 8px | Border radius of the modal |
radii.icon | 8px | Wallet icon border radius |
shadow | 0px 5px 30px rgba(154, 154, 154, 0.2) | Modal drop shadow |
After setting all the variables, setup the theme like this:
import 'w3r-modal/style.css'
import { cssStringFromTheme } from 'w3r-modal'
import { myTheme } from '../theme'
const cssString = cssStringFromTheme(myTheme)
export const App = () => {
return (
<>
<style jsx global>
{`
:root {
${cssString}
}
`}
</style>
</>
)
}