Skip to content

@askable-ui/vue

Vue 3 bindings for askable-ui. Requires Vue 3.2+.

Install

bash
npm install @askable-ui/vue @askable-ui/core

<Askable>

Renders a wrapper element with data-askable managed reactively from :meta.

vue
<Askable :meta="{ metric: 'revenue', delta: '-12%' }">
  <RevenueChart />
</Askable>

<Askable :meta="{ metric: 'revenue' }" scope="analytics">
  <RevenueChart />
</Askable>

<Askable meta="main navigation" as="nav">
  <NavLinks />
</Askable>

Props:

PropTypeDefaultDescription
metaRecord<string, unknown> | stringValue for data-askable attribute
scopestringOptional category written to data-askable-scope for scoped prompt/history queries
asstring"div"HTML element to render

useAskable(options?)

Composable that provides reactive access to a shared AskableContext for the requested events configuration. Observation starts in onMounted(); additional consumers with the same events reuse the existing observer instead of re-observing the document. Differing events configurations get isolated shared contexts, each destroyed when its last consumer unmounts. Pass name to scope that shared lifecycle to a specific UI region (for example table vs chart).

ts
import { useAskable } from '@askable-ui/vue';

const { focus, promptContext, ctx } = useAskable();
// focus: Ref<AskableFocus | null>
// promptContext: ComputedRef<string>
// ctx: AskableContext

Options:

OptionTypeDescription
namestringOptional shared context name for region-scoped context reuse
viewportbooleanEnable viewport-aware context tracking for this composable's context
eventsAskableEvent[]Trigger events. Default: ['click', 'hover', 'focus']

Returns:

ValueTypeDescription
focusRef<AskableFocus | null>Reactive current focus
promptContextComputedRef<string>Reactive prompt-ready context string
ctxAskableContextFull context instance

Examples:

ts
// Click-only
const { focus } = useAskable({ events: ['click'] });

// Use in template
// promptContext.value in <script setup>
// {{ promptContext }} in template

Released under the MIT License.