Search code examples
reactjsjsxdocusaurus

How do I add a button to the navbar?


I've just started using Docusaurus and I want to add a Sign Up button to the navbar (yes, I know that it's for documentation only). I have tried swizzleing the componenets but I've had no luck. I think it has something to do with this react code:

<Link
        className="button button--secondary button--lg"
        to="/docs/intro">
        Sign Up
</Link>

Solution

  • Docusaurus supports adding buttons to the navbar by extending the default theme in a configuration file.

    To add a simple signup button you can create a docusaurus.config.js file in the root directory of your site.

    module.exports = {
      themeConfig: {
        navbar: {
          items: [
            {
              to: 'docs/intro',
              label: 'Signup',
              position: 'left',
              className: 'button button--secondary button--lg'
            },
          ],
        },
      },
    };