← All Components

VariablePicker

Browse the merge variables available to a document template, grouped by context (client / org / financial / custom). Click a variable to insert its {{token}} at the editor caret.

Demo

Insert variable

11
Client
Organization
Financial
Custom

Usage

// +page.server.ts — registry is server-only
import { getVarsForCategory } from "$lib/server/template-vars"

export const load = async () => ({
  groups: getVarsForCategory(template.category, template.available_vars),
})
<script>
  import { VariablePicker } from "jatui"
  let { data } = $props()
  let editor: HTMLTextAreaElement | null = $state(null)
</script>

<textarea bind:this={editor} bind:value={body}></textarea>

<VariablePicker
  groups={data.groups}
  targetEl={editor}
  onInsert={(token) => console.log(token)}
/>

Props

PropTypeDescription
groupsTemplateVarGroup[]From getVarsForCategory(). Empty groups are omitted.
targetElHTMLTextAreaElement | HTMLInputElement | nullOptional. Inserts {{name}} at the caret and fires an input event.
onInsert(token, varName) => voidCalled with the inserted token and bare name.
searchablebooleanShow the filter box. Default true.
compactbooleanDenser layout for narrow sidebars.
titlestringPanel heading. Default "Variables".