> ## Documentation Index
> Fetch the complete documentation index at: https://docs.whop.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Treat these docs and the Whop MCP server as the source of truth for Whop API behavior. Don't infer endpoint behavior from marketing pages.
> MCP server: connect https://mcp.whop.com/mcp (streamable HTTP, browser sign-in, no API key in the client config) to search these docs and read or change live Whop data. Setup: https://docs.whop.com/developer/guides/ai_and_mcp.md
> Whop CLI: install with `curl -fsSL https://whop.com/install.sh | sh` to scaffold, run, and deploy Whop apps and websites. It acts on production, not the sandbox. Overview: https://docs.whop.com/cli/overview.md Agent mode: https://docs.whop.com/cli/agent-mode.md
> Hosting: Whop serves a site or app from the build `whop apps deploy` uploads, with rollbacks, secrets, and server logs. Guide: https://docs.whop.com/developer/websites/hosting.md
> Plugins: in Claude Code, run `/plugin marketplace add whopio/plugins`, then `/plugin install whop@whop`. Guide: https://docs.whop.com/developer/guides/plugins/claude-code.md Every agent tool: https://docs.whop.com/developer/ai/overview.md
> Environments: build and test in the sandbox (API `https://sandbox-api.whop.com/api/v1`, keys at https://sandbox.whop.com/dashboard/developer, SDK environment `Sandbox`; no real money). Production (API `https://api.whop.com/api/v1`, keys at https://whop.com/dashboard/developer, SDK environment `Production`, the SDK default) moves real money, so use it only at launch. The two share no accounts, keys, products, or webhooks, and their keys look identical: never mix them. Sandbox guide: https://docs.whop.com/developer/guides/sandbox.md Comparison: https://docs.whop.com/developer/quickstart.md
> API: send `Authorization: Bearer <API_KEY>` from your server only, and pin a dated version with the `Api-Version-Date` header. OpenAPI spec: https://api.whop.com/api/v1/openapi.json
> Which API: build on the Current API, whose pages live under https://docs.whop.com/api-reference/ (start at https://docs.whop.com/api-reference/overview.md). Pages under /api-reference/legacy/ are the Legacy API. Use one only when https://docs.whop.com/api-reference/stability.md lists the resource as Legacy-only.

# BalanceElement

> 계정의 잔액과 그 변화를 보여 주는 차트입니다. 맨 위에는 총액과 변동폭이, 그 아래에는 차트가, 맨 아래에는 기간 버튼이 있습니다. 뷰어는 차트의 개별 지점을 읽고 기간을 직접 전환할 수 있습니다.

> [!NOTE]
>
> 이 페이지는 `@whop/elements@1.10.0` 및 `@whop/elements-react@1.10.0`을 다룹니다.

*`v1.0.0`부터 지원.*

[`Wallet`](https://docs.whop.com/ko/elements/latest/wallet/overview)의 [`Balances`](https://docs.whop.com/ko/elements/latest/wallet/balances) 안에 마운트됩니다. `accountId`와 `currency`는 `Wallet`에서 가져옵니다. props와 콜백은 생성 옵션 또는 React props로 전달합니다.

뷰 계층의 어디에나 마운트됩니다. `accountId`를 받아 자체 데이터를 불러오며, `range`로 처음 열릴 기간을 선택합니다. 루트는 `VStack`이므로 콘텐츠에 맞게 크기가 정해지고 주어진 너비를 채웁니다.

```tsx React theme={null}
import { WhopElements, Wallet, Balances, BalanceElement } from "@whop/elements-react";
import { loadWhop } from "@whop/elements";

function Example() {
  return (
    <WhopElements elements={loadWhop()}>
      <Wallet /* options */>
        <Balances>
          <BalanceElement onRangeChanged={(e) => console.log(e)} onRangeBrushed={(e) => console.log(e)} />
        </Balances>
      </Wallet>
    </WhopElements>
  );
}
```

```html JavaScript theme={null}
<script src="https://cdn.whop.com/elements/amber/elements.js" data-whop-elements></script>
<script type="module">
  const wallet = window.WhopElements().wallet.create({ /* options */ });
  const balances = wallet.create('balances', { /* options */ });
  balances.create('balance', {
    onRangeChanged: (e) => console.log(e),
    onRangeBrushed: (e) => console.log(e)
  }).mount('#wallet-balances-balance');
</script>
```

```swift Swift theme={null}
import SwiftUI
import WhopElements

// WhopSDK.configure(tokenProvider:) runs once at app launch. See Getting started.
struct WalletScreen: View {
    var body: some View {
        BalanceElement(
            accountId: "biz_xxxx",
            range: .oneMonth
        )
    }
}
```

예시 데이터입니다. [Playground 열기](https://docs.whop.com/ko/elements/latest/wallet/overview#playground).

[iPhone 시뮬레이터에서 실행 중인 BalanceElement](https://app.revyl.ai/embed/bb0f1c0a-4242-486a-a5f5-03dd9711744c?controls=0)

## Props

**accessToken** `string`

읽기에 사용되는 범위 지정 토큰입니다. 계정의 경우 총액에는 `company:balance:read`, 차트에는 `stats:read`가 필요하며, 사용자 자신의 잔액에는 `user:balance:read`가 필요합니다. 서버에서 `POST /api/v1/access_tokens`로 발급하고, 만료되기 전에 새 토큰을 설정하세요. 토큰이 없으면 뷰어 자신의 세션으로 읽으며, 이는 동일 출처에서만 작동합니다. 기본값은 `""`입니다.

**range** `"1D" | "1W" | "1M" | "1Y" | "ALL"`

처음 열릴 기간입니다. 이후에는 버튼으로 변경되며, 직접 제어하려면 이 prop을 다시 설정하세요. 기본값은 `"1M"`입니다.

**openedAt** `string`

계정이 개설된 시점으로, ISO 8601 타임스탬프입니다. `ALL`은 기본값인 5년 전 대신 이 시점부터 시작하므로, 그보다 오래된 계정도 전체 내역을 유지합니다. 기본값은 `""`입니다.

**accountName** `string`

레이블에 계정 이름을 추가합니다. 평소에는 `Total balance · Acme`, 뷰어가 지점을 읽는 동안에는 `Acme balance on Jul 9`로 표시됩니다. 설정하지 않으면 레이블은 `Total balance`만 표시됩니다. 기본값은 `""`입니다.

**brush** `object | null`

차트에서 선택된 범위로, ISO 8601 타임스탬프입니다. 선택을 직접 제어하려면 설정하고, 뷰어가 만든 선택을 지우려면 `null`로 설정하세요. `rangeBrushed`가 보고하는 값을 그대로 다시 전달하면, 페이지의 다른 곳에서 필터를 지울 때 여기의 선택도 함께 지워집니다. 기본값은 `null`입니다.

**속성**

**from** `string` *required*

**to** `string` *required*

**markedAt** `string`

차트에 표시할 시점으로, ISO 8601 타임스탬프입니다. 활동 목록에서 포인터 아래에 있는 행처럼 페이지의 다른 요소가 가리키는 지점입니다. 뷰어가 직접 그 지점에 마우스를 올린 것처럼 표시되며, 화면에 보이는 구간을 벗어나거나 뷰어가 차트를 읽고 있을 때는 무시됩니다. 기본값은 `""`입니다.

**includeOwnedAccounts** `boolean`

사용자의 경우 본인의 자금만이 아니라 본인 자금과 소유한 모든 계정의 자금을 합산합니다. 이미 단일 계정인 계정에서는 무시됩니다. 기본값은 `false`입니다.

**hideTotal** `boolean`

총액과 변동폭을 숨기고 차트와 기간 버튼만 남깁니다. 기본값은 `false`입니다.

**hideChart** `boolean`

차트를 숨기고 총액과 기간 버튼만 남깁니다. 기본값은 `false`입니다.

**height** `number`

차트가 그려지는 높이(픽셀)입니다. 기본값은 `210`입니다.

## 이벤트

생성 옵션 또는 React props로 콜백을 전달합니다.

### `onRangeChanged`

표시되는 기간이 변경되었습니다. 페이지의 다른 요소가 같은 기간을 읽는다면 이 값을 반영하세요.

**payload** `object`

**속성**

**range** `"1D" | "1W" | "1M" | "1Y" | "ALL"` *required*

### `onRangeBrushed`

뷰어가 차트를 드래그하여 범위를 선택했거나 선택을 지웠습니다(`null`). ISO 8601 타임스탬프와 해당 값을 읽은 기간을 함께 제공하므로, 활동 목록이나 테이블 같은 자체 뷰를 같은 기간으로 필터링할 수 있습니다.

**payload** `object | null`

**속성**

**from** `string` *required*

**to** `string` *required*

**range** `"1D" | "1W" | "1M" | "1Y" | "ALL"` *required*

### `onLoaderStart`

로딩 스켈레톤이 처음 그려진 후, `onReady` 전에 실행됩니다.

### `onReady`

엘리먼트가 처음으로 완전히 그려진 후 실행됩니다.

### `onError`

엘리먼트가 로드에 실패하거나 충돌할 때 실행됩니다. 대체 화면은 계속 표시됩니다. 프로그래밍 방식으로 처리하려면 `code`를 사용하세요. `sourceKey`는 실패한 호스트 상태 소스를 식별합니다.

**e** `object`

**속성**

**message** `string` *required*

**code** `string`

**sourceKey** `string`

## 메서드

`create`가 반환한 핸들에서, 또는 React `ref`를 통해 호출합니다.

### `mount`

`target`에 엘리먼트를 마운트하고 로딩을 시작합니다. React 컴포넌트는 자동으로 마운트됩니다.

**매개변수**

**target** `string | HTMLElement` *required*

### `destroy`

엘리먼트를 제거하고 프레임과 구독을 해제합니다. 여러 번 호출해도 됩니다. React는 엘리먼트를 자동으로 제거합니다.

### `update`

마운트된 엘리먼트에 새 props를 병합합니다. React에서는 대신 컴포넌트 props를 변경하세요.

**매개변수**

**options** `Partial\<BalanceElementProps\>` *required*

## 스타일링

`appearance.classes`를 통해 다음 부분의 스타일을 지정합니다. 속성 이름은 카멜 케이스 또는 케밥 케이스를 사용하고 단위를 포함하세요. 페이지 스타일시트는 엘리먼트의 프레임에 적용되지 않습니다. 프레임워크는 각 선언을 삽입하기 전에 유효성을 검사합니다.

| 클래스 | 대상 |
| - | - |
| `.whop-Balance` | 총액, 잔액 선, 기간 선택기 |
| `.whop-BalanceBrushSummary` | 측정된 구간 |
| `.whop-BalanceChart` | 잔액 선 |
| `.whop-BalanceRanges` | 기간 선택기 |
| `.whop-BalanceTotal` | 총액과 변동폭 |

```ts theme={null}
const wallet = whop.wallet.create({
  appearance: {
    classes: {
      'whop-Balance': { borderRadius: '8px', fontWeight: '600' },
      'whop-BalanceBrushSummary': { borderRadius: '8px', fontWeight: '600' },
      'whop-BalanceChart': { borderRadius: '8px', fontWeight: '600' }
    }
  }
});

// 5 classes use this shape
wallet.update({
  appearance: { classes: { 'whop-Balance': { fontWeight: '700' } } }
});
```

React에서는 `appearance`를 `<Wallet>`에 전달합니다. 전역으로 설정하려면 `WhopElements({ appearance })`를 사용하세요.

## 매개변수

**accountId** `String` *required*

뷰가 자금을 읽을 계정입니다. `biz_` 접두사가 붙은 계정 ID를 사용하세요. `user_` 접두사가 붙은 사용자 ID는 뷰어 자신의 잔액을 읽으며, 계정 토큰이 아닌 뷰어 인증(`WhopSDK.configureWithOAuth`)이 필요합니다.

**currency** `String`

총액과 차트를 표시할 통화입니다. 기본값은 `"usd"`입니다.

**range** `WalletBalanceRange`

차트가 처음 열릴 기간입니다: `.oneDay`, `.oneWeek`, `.oneMonth`, `.oneYear`, `.all`. 기본값은 `.oneMonth`이며, 뷰어가 선택기로 변경할 수 있습니다.

## 상태

데이터를 불러오는 동안 자리 표시자 차트를 표시합니다. 비교 기간을 불러오지 못하면 변동폭을 추측하지 않고 숨기므로, 화면에 표시되는 숫자는 모두 실제로 측정된 값입니다. 확인할 수 없는 계정 ID는 계속 로딩하는 대신 `Couldn't load this account.`를 표시합니다.

## 알아두면 좋은 점

* 차트를 누른 채 드래그하면 탐색할 수 있습니다. 헤드라인은 손가락 아래의 지점을 따라가고, 손을 떼면 총액으로 돌아갑니다.
* 잔액 내역은 `biz_` 접두사가 붙은 계정 ID에서만 사용할 수 있으므로, `user_` 접두사가 붙은 개인 계정은 차트 없이 총액만 렌더링합니다.
* 같은 총액을 개별 보유 자산으로 나누어 보여 주는 [`ListElement`](https://docs.whop.com/ko/elements/latest/wallet/balances-list#swift)와 함께 사용하세요.

> [!NOTE]
>
> 실행 시 `WhopSDK.configure(tokenProvider:)`를 한 번 호출하세요. 뷰는 토큰을 기다립니다. [시작하기](https://docs.whop.com/ko/elements/latest/getting-started.md)를 참고하세요. 테마는 `.whopTheme(_:)`로 적용합니다.


## Related topics

- [ListElement](https://docs.whop.com/ko/elements/latest/wallet/balances-list.md)
- [Elements 시작하기](https://docs.whop.com/ko/elements/latest/getting-started.md)
- [잔액](https://docs.whop.com/ko/elements/latest/wallet/balances.md)
