Before we start you should know that the Connect button is a part of the DynamicWidget, but can also be used seperately through the Dynamic Connect Button component. It doesn’t matter which one you use here, the techniques will affect both!
The easiest way to achieve this is to utilize the default CSS variables.We’ll focus on the background color, main color and the text color here but there are more variables available such as the border, shadow etc. You can find the full reference here.First we’ll need to make sure in our CSS we use the following class name:
Copy
Ask AI
.dynamic-shadow-dom {}
Now we add add the following variables to that class:
We can also change the text of the button and the font used. For the font, the approach is exactly the same as for the colors, we just need to use the correct variables.
For the text itself, we will use the innerButtonComponent prop on the DynamicWidget. This prop allows us to pass in a JSX element that will be rendered as the button.
Copy
Ask AI
<DynamicWidget innerButtonComponent={<button>My Custom Connect Wallet Button</button>}> {/* ... rest of your app ... */}</DynamicWidget>
This is as simple as a visit to the design section of your Dynamic dashboard.Under the “Themes” section, choose any of the available themes, save when prompted, and you’ll be live immediately with your new design!
The logged in widget is the widget is the part of the DynamicWidget that renders the Dynamic User Profile component. As with the Connect button, you can use the Widget or the Widget Content component, this guide will work for both.Let’s say in this example we want to do two things:
Remove the network picker from the logged in widget.
Rotate the wallet icon using animations in the logged in widget.
There is no CSS variable to do this, so it means we will use a CSS override.Once you have found the class names you want to override, and know what css you wish to apply instead, we need to declare the css as a string literal, ideally stored under a variable called cssOverrides in whichever component you’re initialising DynamicContextProvider.
Copy
Ask AI
const cssOverrides = ` .dynamic-widget-inline-controls__account-control > img { animation: rotation 2s infinite linear } @keyframes rotation { from { transform: rotate(0deg); } to { transform: rotate(359deg); } }; `;
Then, you can use this variable as a setting for DynamicContextProvider:
Copy
Ask AI
<DynamicContextProvider settings={{ cssOverrides, }}> {/* ... rest of your app ... */}</DynamicContextProvider>
Note that you can also pass a JSX element rather than a string, but more on that hereThat’s it! Run your app. Once logged in, you should no longer see your network picker and the wallet icon should be happily spinning!
Note that is you need to add extra content to the widget, not just style the
existing content differently, we recommend following the custom widget
content guide.
Here we see how to reach beyond the confines of the components themselves, and extending the flow into your own application using callbacks and functions.You cannot implement a welcome screen inside the Dynamic modal, but you can of course create your own in your application. This raises the question about how to trigger it at the right time.The answer is to use the onAuthSuccess callback. This callback is triggered when the user has successfully authenticated with Dynamic.
Copy
Ask AI
<DynamicContextProvider settings={{ events: { onAuthSuccess: (args) => { console.log("onAuthSuccess was called", args); }, }, }}> {/* ... rest of your app ... */}</DynamicContextProvider>
The second part of the puzzle is to check if this is a new user or not, since we might want a different experience for new users. We can do this by checking the “newUser” property on the object supplied by the callback above.This is because the callback supplies you with the user object, and this is a representation of the UserProfile which contains the newUser boolean.
Copy
Ask AI
onAuthSuccess: (args) => { if(args.user.newUser) { console.log("This is a new user") } },
If this is indeed a new user, you can replace the console log above with your own logic to call your welcome screen component, and voila!
For more information on the design customization options available, check out the design customization section.If you have any questions at all about these techniques or how to achieve a certain design use case, don’t hesitate to ask in the community slack.