Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit af8d47f

Browse files
authored
Merge pull request #29 from devcollinss/update/balance-component-docs
docs: update Balance component documentation
2 parents 481872a + 58bb21a commit af8d47f

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

docs/components/Balance.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ sidebar_position: 2
44

55
# Balance
66

7-
Displays the balance of a given address in both ether (ETH) and US dollars (USD).
7+
The `Balance` component displays the balance of a given Ethereum (ETH) or Starknet (STRK) address in both its native currency and US dollars (USD). It allows toggling between these two modes and also handles potential errors or loading states.
8+
9+
## Features
10+
11+
- **ETH & STRK Balances:** Shows both Ethereum and Starknet balances for a given address.
12+
- **USD Conversion:** Option to toggle and display balance in USD, provided the exchange rates are available.
13+
- **Error & Loading States:** Handles network issues, loading delays, and empty address scenarios gracefully.
814

915
![Balance Example](/img/Balance.gif)
1016

@@ -26,3 +32,25 @@ import { Balance } from "~~/components/scaffold-stark";
2632
| ------------------------ | -------- | ------------- | ------------------------------------------------------------------------------------------------------------------------- |
2733
| **address** | `string` | `undefined` | Address in `0x___` format, it will resolve its Starknet Domain if it has one associated(coming soon). |
2834
| **className** (optional) | `string` | `""` | Prop to pass additional CSS styling to the component. You can use Tailwind / daisyUI classes like `text-3xl` for styling. |
35+
| **usdMode** (optional) | `boolean` | `false` | If true, the balance is displayed in USD. Otherwise, it defaults to ETH/STRK. |
36+
37+
38+
## Example
39+
40+
The `Balance` component can be easily customized using Tailwind or daisyUI classes. Here’s a more detailed example of its usage:
41+
42+
```tsx
43+
<Balance
44+
address="0x34aA3F359A9D614239015126635CE7732c18fDF3"
45+
className="text-lg text-gray-700 mt-4"
46+
usdMode={true}
47+
/>
48+
```
49+
50+
This example showcases how to apply additional styling to the component and enables the USD display mode.
51+
52+
53+
:::info
54+
- The component automatically handles loading states, showing a skeleton loader when the balance is being fetched.
55+
- If the address is invalid or no balance is found, it will show an error message.
56+
:::

static/img/Balance.gif

-23.1 KB
Loading

0 commit comments

Comments
 (0)