Extending @regexAgainstTheMachine answer, to automatically fill (color) the icon according to your theme
.navbar__github:before {
content: "";
display: flex;
height: 24px;
width: 24px;
mask: url(/img/github.svg) no-repeat 100% 100%;
mask-size: cover;
background-color: var(--ifm-navbar-link-color);
}
.navbar__github:hover:before {
background-color: var(--ifm-navbar-link-hover-color);
}
This can be used generically for additional icons
.navbar__icon:before {
content: "";
display: flex;
height: 24px;
width: 24px;
background-color: var(--ifm-navbar-link-color);
}
.navbar__icon:hover:before {
background-color: var(--ifm-navbar-link-hover-color);
}
.navbar__github:before {
mask: url(/img/github.svg) no-repeat 100% 100%;
mask-size: cover;
}
.navbar__twitter:before {
mask: url(/img/twitter.svg) no-repeat 100% 100%;
mask-size: cover;
}
docusaurus.config.js
items: [
{
'aria-label': 'Twitter',
to: twitter,
position: 'right',
className: 'navbar__icon navbar__twitter',
},
{
'aria-label': 'GitHub repo',
to: repo,
position: 'right',
className: 'navbar__icon navbar__github',
},
],