useDisclosure
Share boolean open state between controls.
useDisclosure provides open, close, and toggle actions for a boolean ref. It does not render anything or manage focus, dismissal, or accessibility.
Usage
Pass an existing ref to share state with an Akaza component. Without a ref, each call starts closed and owns independent state.
vue
<script setup lang="ts">
import { useTypeahead } from "akaza-ui";
const { query, push, reset } = useTypeahead({ timeout: 500 });
function onKeydown(event: KeyboardEvent) {
if (event.key.length !== 1 || event.ctrlKey || event.metaKey || event.altKey) return;
push(event.key.toLocaleLowerCase());
}
</script>
<template>
<button
type="button"
@keydown="onKeydown"
@blur="reset"
>
Type to build a query
</button>
<output>{{ query }}</output>
</template>
Actions can be passed directly to native event handlers. They write the ref directly; they do not emit or cancel component change events. Use component slot actions when a change must pass through that component's event policy.
API Reference
ts
export default defineNuxtConfig({
modules: ['akaza-ui/nuxt'],
})
| Argument | Description |
|---|---|
model | Optional writable ref, including a writable computed ref. Default: a new ref(false). |
| Return | Type | Description |
|---|---|---|
isOpen | Ref<boolean> | The supplied ref or the internally created ref. |
open | () => void | Set state to true. |
close | () => void | Set state to false. |
toggle | () => void | Invert current state. |
SSR and Scope
No DOM access, timers, providers, or shared module state. The composable can run during SSR or inside an effect scope. Modal focus and keyboard behavior remain the rendered component's responsibility.