Customization Guide
Native allows for a full customization for the swap widget such as theme customization, external wallet provider, and many more.
You can visit widget.native.org for a live demo and playground.
Wallet Setting & Custom Provider
The Native swap widget allows developers to utilize their existing Dapp connections by passing the walletSettings
prop. The provider passed is used by the widget to enable users to connect their wallets, fetch balances, and submit transactions through the user's connected wallet.
If your app does not maintain its own web3 provider, you can omit the walletSettings
prop. The widget will utilize built-in wallet connection functionality (using the rainbowkit library), making it easy for you to integrate web3 into your app!
If you already have a web3 provider, you can pass your walletSettings
, which includes several pieces of information such as the address
, chainId
, connect
function, and provider
object, directly into the provider prop. Both ethers and web3.js provider objects are compatible with the widget provider, as well as any EIP-1193 provider. You can directly use the providers returned from web3-react or wagmi (both are ethers providers). If the user's wallet is not connected, the widget will prompt them to "Connect wallet" using the connect function.
Example of the custom wallet setting and providers:
Theme Customization
You can customize the colors, font, and background of the swap widget to match the look and feel of your dApp. You can also toggle between light and dark modes. This section explains how to customize each attribute of the widget with your own theme.
Generally, the Native swap widget supports theme customization via the theme
prop, which allows for setting the bg color and text color. The Native swap widget also provides a basic preset to support both light and dark themes.
Example of theme customization can be seen in the following:
Furthermore, to support our KOL and community, we provide a basic profile template to make Widget unique to them
Custom Styling
If the custom theme does not meet your needs and you want further customization, you can pass custom CSS styling through the containerStyle
prop, which directly targets the native component. Each component has its own CSS class. Our custom styling is extended from the styled component library, which supports more advanced CSS selectors such as pseudo classes, pseudo elements, media queries, etc.
Example of custom styling prop
Chain Configuration
By default, the Native swap widget supports both the mainnet and testnet, including Ethereum mainnet, sepolia testnet, BNB mainnet, BNB testnet, Polygon mainnet, and Mumbai testnet.
You can disable some networks and even customize the initial input and output tokens. Note that once you pass the chainSettings
prop, the default supported network is no longer applied. You need to manually choose which networks you support via the isSupported
field.
Example of chain configuration
Last updated