SdkViews
Views are a new feature as of SDK V0.19, please be aware there may be breaking changes in the future.
What is it?
Views are used to customize the kind of UI that shows up at any point in time in your application.
How does it work?
Views are used primarily in the overrides prop of the DynamicContextProvider. You pass in an array of configurations for each view you want to customize, each view has its own set of options.
Supported views:
Login View
The SdkViewType.Login
is used to adjust the login/signup UI options programmatically.
When using the login view, you add an object to the views array. This object should have type: SdkViewType.Login
and sections
which is an array of SdkViewSection objects.
SdkViewSection structure
Field | Description |
---|---|
alignment?: SdkViewSectionAlignment; | The text alignment used for Text sections. |
defaultItem?: string; | The option to be displayed as the main one. The default item will be displayed in a more prominent way than the rest of the items in the section. For Social section, represents the social provider to be displayed by default. |
label?: string | The label for the section. This will be displayed above the section or as part of the separator component if it is a Separator section. |
numOfItemsToDisplay?: number; | The default number of items to display in the section. For Wallet section, represents the number of wallet items to be displayed by default. User has to click a button to view more options if there are any. For Social section, represents the number of social providers to be displayed by default. User has to click a button to view more options if there are any. |
type: SdkViewSectionType | An identifier of the kind of view section to be provided, possible values outlined in section below. |
SdkViewSectionType
The possible values are:
SdkViewSectionType.Email
SdkViewSectionType.EmailAndPhone
SdkViewSectionType.Phone
SdkViewSectionType.Social
SdkViewSectionType.Separator
SdkViewSectionType.Text
SdkViewSectionType.Wallet
The EmailAndPhone
section is what you get by default when you enable both
email and phone in our dashboard without using login view overrides. It’s a
section where the user has the option to toggle between email and phone number
input.
SdkViewSectionAlignment
The possible values are:
SdkViewSectionAlignment.Center
SdkViewSectionAlignment.Left
SdkViewSectionAlignment.Right
Example snippets
Here’s an example where you are overriding the login view to show only the email login option:
import { SdkViewSectionType, SdkViewType } from "@dynamic-labs/sdk-api";
<DynamicContextProvider
settings={{
overrides: {
views: [
{
type: SdkViewType.Login,
sections: [
{
type: SdkViewSectionType.Email,
},
],
},
]
}
}}
>
<App />
</DynamicContextProvider>;
Here is an example where you are overriding the login view to show email or social login options:
import { SdkViewSectionType, SdkViewType } from "@dynamic-labs/sdk-api";
<DynamicContextProvider
settings={{
overrides: {
views: [
{
type: SdkViewType.Login,
sections: [
{
type: SdkViewSectionType.Email,
},
{
type: SdkViewSectionType.Separator,
label: "Or",
},
{
type: SdkViewSectionType.Social,
defaultItem: "google",
},
],
},
]
}
}}
>
<App />
</DynamicContextProvider>;
Complete example
There is a more complete example also found here.
Wallet List
The wallet-list
configuration enables you to define tabs with predetermined labels, icons, filters, and recommended wallets, enhancing your application’s wallet selection interface. This feature is particularly useful for grouping wallets.
Available from version 2.0.0+
Configuring Wallet List Tabs
In the DynamicContextProvider
setup, the overrides
field is used to configure each tab in the wallet list. The configuration options available for each tab allow for detailed customization:
-
Label and Icon: Customize the tab’s appearance with a
label
for text and anicon
for visual representation. Theicon
can be one of the following options:- A icon from the dynamic iconic package
- A image URL
- Or you can bring your own React icon
- A icon from the dynamic iconic package
-
Wallets Filter: This option enables to dynamic display of wallets based on the selected tab. Clients have the flexibility to write custom filter functions or utilize predefined ones, for more information read the sort and filter wallets doc
-
Recommended Wallets: Specify recommended wallets for each tab by providing wallet option keys and optional labels. This feature is designed to highlight preferred wallets, steering users towards secure and suitable options for their specific needs.
-
Style: An optional field that determines how the tabs are displayed within the wallet list. Currently, the only supported style is
"grid"
.
Example Configuration
Below is an example showcasing the setup for tabs that categorize wallets by blockchain network, utilizing both custom and predefined filter functions:
import { DynamicContextProvider, FilterChain } from '@dynamic-labs/sdk-react-core'
import {
BitcoinIcon,
EthereumIcon,
FlowIcon,
SolanaIcon,
} from '@dynamic-labs/iconic';
const App = () => {
return (
<DynamicContextProvider
settings={{
environmentId: 'env-id',
// Additional settings...
overrides: {
views: [
{
type: 'wallet-list',
tabs: {
items: [
{
label: { text: 'All chains' },
},
{
label: { icon: <EthereumIcon /> },
walletsFilter: FilterChain('EVM'),
recommendedWallets: [
{
walletKey: 'phantomevm',
},
],
},
{
label: { icon: <SolanaIcon /> },
walletsFilter: FilterChain('SOL'),
},
{
label: { icon: <BitcoinIcon /> },
walletsFilter: FilterChain('BTC'),
},
{
label: { icon: <FlowIcon /> },
walletsFilter: FilterChain('FLOW'),
},
]
}
}
]
}
}}
>
</DynamicContextProvider>
)
}
This is the wallet list view with the tabs
All chains tab selected | Ethereum selected |
---|---|
Was this page helpful?