> ## 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. Agent mode: https://docs.whop.com/cli/agent-mode.md
> Plugins: in Claude Code, run `/plugin marketplace add whopio/plugins`, then `/plugin install whop@whop`. 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. 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.

# WhopCardElement

> Renders one issued Whop Card. The element prefetches authorized secrets immediately after it mounts with a card ID, but keeps them masked until the viewer clicks it or selects `View details`. The API remains the permission authority. Includes lock and unlock controls by default.

> [!NOTE]
>
> This page documents `@whop/elements@1.9.0` and `@whop/elements-react@1.9.0`.

*Since `v1.0.0`.*

Mounts inside [`Cards`](https://docs.whop.com/elements/latest/wallet/cards), in [`Wallet`](https://docs.whop.com/elements/latest/wallet/overview). `accountId` and `accessToken` come from `Wallet`. Pass props and callbacks through the create options or React props.

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

function Example() {
  return (
    <WhopElements elements={loadWhop()}>
      <Wallet /* options */>
        <Cards>
          <WhopCardElement onDetailsChanged={(e) => console.log(e)} onLockRequested={(e) => console.log(e)} onLockChanged={(e) => console.log(e)} onAppleWalletRequested={(e) => console.log(e)} />
        </Cards>
      </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 cards = wallet.create('cards', { /* options */ });
  cards.create('whopCard', {
    onDetailsChanged: (e) => console.log(e),
    onLockRequested: (e) => console.log(e),
    onLockChanged: (e) => console.log(e),
    onAppleWalletRequested: (e) => console.log(e)
  }).mount('#wallet-cards-whopCard');
</script>
```

Example data. [Open the Playground](https://docs.whop.com/elements/latest/wallet/overview#playground).

## Props

**accessToken** `string`

A scoped token for card access. Omitted calls carry the viewer session when same-origin. Secrets are returned only when the API authorizes the viewer.

**cardId** `string`

Issued card ID, prefixed `icrd_`. Defaults to `""`.

**hideControls** `boolean`

Hide the View details and Lock card buttons. The card itself remains clickable to reveal details. Defaults to `false`.

**disableLock** `boolean`

Disable the lock control while keeping it visible. Useful when a host has temporarily frozen card actions. Defaults to `false`.

**hideAppleWalletButton** `boolean`

Hide the Add to Apple Wallet button. It is shown for active and locked cards by default. Defaults to `false`.

**deferLockToHost** `boolean`

Direct-mode integration option. Emits `lockRequested` without updating the card so a first-party host can retain its confirmation flow. Defaults to `false`.

## Events

Pass callbacks in the create options or React props.

### `onDetailsChanged`

Fires after details are revealed or hidden.

**payload** `object`

**properties**

**cardId** `string` *required*

**revealed** `boolean` *required*

### `onLockRequested`

Fires instead of updating when `deferLockToHost` is true.

**payload** `object`

**properties**

**cardId** `string` *required*

**locked** `boolean` *required*

### `onLockChanged`

Fires after the Cards REST API successfully locks or unlocks the card.

**payload** `object`

**properties**

**cardId** `string` *required*

**locked** `boolean` *required*

### `onAppleWalletRequested`

Fires when the viewer presses Add to Apple Wallet. The host owns the resulting Apple Wallet flow.

**payload** `object`

**properties**

**cardId** `string` *required*

### `onLoaderStart`

Runs after the loading skeleton first paints and before `onReady`.

### `onReady`

Runs after the element's first complete paint.

### `onError`

Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.

**e** `object`

**properties**

**message** `string` *required*

**code** `string`

**sourceKey** `string`

## Methods

Call these on the handle returned by `create`, or through a React `ref`.

### `mount`

Mounts the element in `target` and starts loading. React components mount themselves.

**Parameters**

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

### `destroy`

Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.

### `update`

Merges new props into the mounted element. In React, change the component props instead.

**Parameters**

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

## Styling

Style these parts through `appearance.classes`. Use camel case or kebab case for property names and include units. Page stylesheets can't reach the element's frame. The framework validates each declaration before injecting it.

| Class | Targets |
| - | - |
| `.whop-CardSurface` | The card, controls, and revealed details |

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

wallet.update({
  appearance: { classes: { 'whop-CardSurface': { fontWeight: '700' } } }
});
```

In React, pass `appearance` to `<Wallet>`. Set it globally with `WhopElements({ appearance })`.


## Related topics

- [Getting Started with Elements](https://docs.whop.com/elements/latest/getting-started.md)
- [CardFields](https://docs.whop.com/elements/latest/payments/cardFields.md)
- [CardElement](https://docs.whop.com/elements/latest/payments/card.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.