> ## 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.

# SearchElement (Legacy)

> Referentie voor de legacy SearchElement. Gebruik voor nieuwe integraties de zoekoverlay in @whop/elements.

## Overzicht

Een UI-element waarmee gebruikers kunnen zoeken naar berichten in een kanaal, DM of supportchat.

## Gebruik

### Basisgebruik

```typescript theme={null}
// Create the element
const element = session.createElement("search-element", {
  onClose: (ev) => {
    console.log("Search element closed");
  },
});

// Mount it to a container
element.mount("#search-container");
```

### Gebruiken als modal

```typescript theme={null}
// Show the element in a modal overlay
const modal = session.showSearchModal({
  channelId: "feed_XXXXXXXXXXXXXX",
  onResultClick: (ev) => {
    console.log("Result clicked!", ev.detail.messageId);
    // Element auto-unmounts by default
  },
});
```

```typescript theme={null}
const element = session.createElement("search-element", {
  channelId: "feed_XXXXXXXXXXXXXX",
  onReady: (element) => {
    console.log("Search element is ready");
  },
});
```

## Events

Events die door de SearchElement worden uitgezonden.

Luister naar deze events met de methode `on()` of door callbackfuncties mee te geven in de opties.

### `error`

Wordt uitgezonden wanneer er een fout optreedt tijdens de initialisatie of werking van het element.

**Callback-signatuur:** (error: `unknown`) => void

### `ready`

Wordt uitgezonden wanneer het element klaar is met laden en gereed is voor gebruikersinteractie.

**Callback-signatuur:** (element: `SearchElement`) => void

### `optionsUpdated`

Wordt uitgezonden wanneer de opties van het element worden bijgewerkt via `updateOptions()`.

**Callback-signatuur:** (options: [`SearchElementOptions`](#searchelementoptions)) => void

### `snapshot`

Wordt uitgezonden wanneer de interne status van het element verandert.

**Callback-signatuur:** (snapshot: [`SearchElementSnapshot`](#searchelementsnapshot)) => void

### `close`

Wordt uitgezonden wanneer de gebruiker het zoekelement sluit.
Roep `ev.preventDefault()` aan om te voorkomen dat het element automatisch wordt ontkoppeld.

**Callback-signatuur:** (ev: `CustomEvent`\<`any`>) => void

### `resultClick`

Callback die wordt aangeroepen wanneer de gebruiker op een zoekresultaat klikt.
Roep `ev.preventDefault()` aan om te voorkomen dat het element automatisch wordt ontkoppeld.

**Callback-signatuur:** (ev: `CustomEvent`\<\{ messageId: `string`; channelId: `string`; }>) => void

## Methoden

### `mount(container)`

Koppel het element aan een DOM-container.

De container moet een leeg element zijn. Het element wordt als child toegevoegd.
Als het element al gekoppeld is, logt deze methode een waarschuwing en keert terug.

| Parameter | Type | Beschrijving |
| - | - | - |
| `container` | `HTMLElement` \| `#$\{`string`\}` | Het containerelement of een CSS-selector die begint met '#' |

```typescript theme={null}
// Using a selector
element.mount("#my-container");

// Using an element reference
const container = document.getElementById("my-container");
element.mount(container);
```

### `unmount()`

Verwijder het element uit de DOM en ruim alle event listeners op.

Na het ontkoppelen mag de elementinstantie niet opnieuw worden gebruikt.
Maak een nieuwe elementinstantie aan als je opnieuw wilt koppelen.

```typescript theme={null}
// Unmount when done
element.unmount();

// Commonly used in event handlers
element.on("complete", () => {
  element.unmount();
});
```

### `updateOptions(options)`

Werk de configuratieopties van het element bij na het aanmaken.

Alleen de opgegeven opties worden bijgewerkt; andere opties blijven ongewijzigd.
Het element wordt opnieuw gerenderd met de nieuwe opties.

| Parameter | Type | Beschrijving |
| - | - | - |
| `options` | `Partial`\<[`SearchElementOptions`](#searchelementoptions)> | Gedeeltelijk optie-object met de waarden die moeten worden bijgewerkt |

```typescript theme={null}
// Update a single option
element.updateOptions({
  onComplete: (ev) => {
    console.log("New handler!");
  },
});
```

### `getSnapshot()`

Haal de huidige status-snapshot van het element op.

De snapshot bevat de huidige interne status van het element, zoals
de laadstatus, formulierwaarden of andere elementspecifieke gegevens.

**Retourneert:** [`SearchElementSnapshot`](#searchelementsnapshot)

```typescript theme={null}
const snapshot = element.getSnapshot();
console.log("Current state:", snapshot.state);

// Or listen for changes
element.on("snapshot", (snapshot) => {
  console.log("State changed:", snapshot);
});
```

## Styling

Pas dit element aan met `appearance.classes`. Zie de [stylingreferentie](https://docs.whop.com/nl/sdk/elements/styling-reference.md) voor de volledige lijst met stabiele klassenamen en voorbeeldsnippets.

## Types

### SearchElementOptions

Configuratieopties voor de SearchElement.

| Eigenschap | Type | Verplicht | Standaard | Beschrijving |
| - | - | - | - | - |
| `companyId` | `string \| undefined` | Nee | - | De ID van het account waarin berichten worden doorzocht. |
| `channelId` | `string \| undefined` | Nee | - | De ID van het kanaal, de DM of de supportchat waarin berichten worden doorzocht. |
| `onReady` | `((element: SearchElement) => void) \| undefined` | Nee | - | Callback die wordt aangeroepen wanneer het element klaar is met laden en gereed is voor interactie. Dit is gelijk aan luisteren naar het event 'ready'. |
| `onClose` | `((ev: CustomEvent) => void) \| undefined` | Nee | - | Callback die wordt aangeroepen wanneer de gebruiker het element sluit. Standaard wordt het element ontkoppeld bij sluiten. Roep 'ev.preventDefault()' aan om het gekoppeld te houden. |
| `onResultClick` | `((ev: CustomEvent<{ messageId: string; channelId: string; }>) => void) \| undefined` | Nee | - | Callback die wordt aangeroepen wanneer de gebruiker op een zoekresultaat klikt. Standaard wordt het element ontkoppeld nadat op het resultaat is geklikt. Roep 'ev.preventDefault()' aan om het gekoppeld te houden. |

### SearchElementSnapshot

Vertegenwoordigt de huidige status van de SearchElement.

Gebruik `element.getSnapshot()` om de huidige status op te halen, of luister naar het event `snapshot` voor wijzigingen.

| Eigenschap | Type | Verplicht | Standaard | Beschrijving |
| - | - | - | - | - |
| `state` | `"ready" \| "loading"` | Ja | - | De huidige laadstatus van het element. - '"loading"' - Het element wordt geïnitialiseerd - '"ready"' - Het element is volledig geladen en interactief |
