How to Add a Sign In Button to your React Navbar
Tags: webdev, react, tutorial, superflow
Published: 2022-11-08 09:33:55

## Introduction

This article shows you how to implement the sign in button in the react navigation bar. It shows you how to configure the sign in button input, show / hide it, set its caption, listen to the callback and then how to style it.

## Prerequisites

This article assumes that you have read the previous navbar tutorials. In case you haven't you will find a consolidated list in the reference links section. This article assumes that you have installed the Superflows library, have the default navigation bar up and running, have added your brand information, have also customised your menu and have also added the search input. This tutorial takes it forward from there.

## Step 1 - Show / Hide the Sign In Button

The navigation bar comes with an in-built sign in button, which is visible by default. To explicitly show it, set the showSignIn prop to true, as shown:

```
return (
        <div>
                <SfNav showSignIn={true}/>
        </div>
);
```

It renders as follows:

![Signin visible](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q68r1swbtl1z16q74jaz.png)

![Signin visible mobile](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d7exz2jce2yas2pjzoj2.png)

To hide it, set the showSignIn prop to false, as shown:

```
return (
        <div>
                <SfNav showSignIn={false}/>
        </div>
);
```

It renders as follows:

![Signin hidden](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8sk0d5w2hkm2opes6m39.png)

![Signin hidden mobile](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n3ypxjuo8mcm4ct8rn9c.png)

## Step 2 - Set the Sign In Button Caption

To change the sign in button caption, set the signInCaption prop to the appropriate string value, as shown:

```
return (
        <div>
                <SfNav signInCaption="Log In" />
        </div>
);
```

It renders as follows:

![Sign In Caption](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/psgfyaf68nt8hm0ng9pr.png)

![Sign In Caption Mobile](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pdnbmy44xf4m2ri4wj8u.png)

## Step 3 - Handle the Callback

The navigation bar returns a callback if the user presses the sign in button. You can subscribe to this callback by subscribing to the onSignInPressed prop, as shown:

```
return (
        <div>
              <SfNav onSignInPressed={() => {alert('Sign In Pressed!')}}/>
        </div>
);
```

## Step 4 - Styling

You can then customise the look and feel, by using inline css or by class names. The Superflows navigation bar exposes props that facilitate customisation. An example is shown below:

```
return (
        <div>
              <SfNav 
                  stylesSignIn={{backgroundColor: 'black', color: 'white', border: 'solid 1px gray'}}
              />
        </div>
);
```

It renders as follows:

![Signin Styling](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a5goeam6pgj4vtxtgtar.png)

![Signin Styling Mobile](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ozq46vtrnqnimwursjxr.png)

## Reference Links

### Documentation

[This link](https://superflows.dev/docs/building-blocks/nav)

### Example Project For This Tutorial

[This link](https://stackblitz.com/edit/react-ts-vzcmap?file=App.tsx)

### Previous Tutorials of Navbar

- [T1: Getting Started With Navbar](https://blog.superflows.dev/how-to-get-started-with-a-navigation-bar-in-your-react-project-in-2-mins)
- [T2: Insert Brand Info](https://blog.superflows.dev/how-to-customize-the-react-navbar-with-your-brand-info)
- [T3: Customise Menu](https://blog.superflows.dev/how-to-customize-the-menu-of-your-react-navbar)
- [T4: Add Search Functionality](https://blog.superflows.dev/how-to-implement-search-functionality-in-your-react-navbar)

### YouTube Channel

[This link](https://www.youtube.com/channel/UCYNJLCE48yir4DsquciBuDw)

### Discord Community

[This link](https://discord.gg/ksEXS4P9h6)

### Example Projects Collection

[This link](https://stackblitz.com/@superflows-dev/collections/navigation-bar)

## Video Tutorial

{% youtube Zs8TgAlDgJo %}

## Further Reading

You have already seen how to get started with the navigation bar, how to insert brand information into it, how to customise the menu and now, how to configure the search input and how to use the sign in button. The next tutorial will discuss user profiles in the navigation bar.

## Conclusion

This article shows you how to configure the search input. How to show / hide it, how to change the caption, how to add an icon, how to handle callback and how to customise and style it.