Skip to content

Commit

Permalink
feat: add label prop to ConnectButton (#379)
Browse files Browse the repository at this point in the history
* feat: add label prop to ConnectButton

* fix: remove label from example

* fix: docs language
  • Loading branch information
nicoglennon committed May 16, 2022
1 parent 209aa43 commit b1b09c5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-beds-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rainbow-me/rainbowkit': patch
---

Add the `label` prop to the `ConnectButton` component to easily display a custom label on the button.
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@ export interface ConnectButtonProps {
accountStatus?: ResponsiveValue<AccountStatus>;
showBalance?: ResponsiveValue<boolean>;
chainStatus?: ResponsiveValue<ChainStatus>;
label?: string;
}

const defaultProps = {
accountStatus: 'full',
chainStatus: { largeScreen: 'full', smallScreen: 'icon' },
label: 'Connect Wallet',
showBalance: { largeScreen: true, smallScreen: false },
} as const;

export function ConnectButton({
accountStatus = defaultProps.accountStatus,
chainStatus = defaultProps.chainStatus,
label = defaultProps.label,
showBalance = defaultProps.showBalance,
}: ConnectButtonProps) {
const chains = useRainbowKitChains();
Expand Down Expand Up @@ -262,7 +265,7 @@ export function ConnectButton({
transform={{ active: 'shrink', hover: 'grow' }}
transition="default"
>
Connect Wallet
{label}
</Box>
</Box>
)}
Expand Down
17 changes: 16 additions & 1 deletion site/data/docs/connect-button.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ export const YourApp = () => {
### Props

The `ConnectButton` component exposes several props to customize its appearance by toggling the visibility of different elements.
The `ConnectButton` component exposes several props to customize its appearance, including toggling the visibility of different elements.

<PropsTable
data={[
{
name: 'label',
required: false,
default: 'Connect Wallet',
type: 'string',
description: 'The text label displayed on the Connect button',
},
{
name: 'accountStatus',
required: false,
Expand Down Expand Up @@ -59,6 +66,14 @@ The `ConnectButton` component exposes several props to customize its appearance
### Examples

#### Label

Use the `label` prop to set a custom `ConnectButton` text.

```tsx
<ConnectButton label="__Sign in__" />
```

#### Account status

Here are a few different ways you can use the `accountStatus` prop.
Expand Down

2 comments on commit b1b09c5

@vercel
Copy link

@vercel vercel bot commented on b1b09c5 May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on b1b09c5 May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.