963 markdown files reformatted with the repository's pinned prettier so pnpm format:check covers the folded tree like every other repo file. The formatter's embedded-language pass also normalized code fences (TS semicolons, closed HTML tags in examples, lowercased CSS hex colors, one renumbered list that skipped an index). Alphanumeric token deltas vs the fold commit were audited file-by-file; all are formatter-equivalent markup normalizations plus the four sanitized skills.
1.3 KiB
1.3 KiB
category
| category |
|---|
| Elements |
useActiveElement
Reactive document.activeElement
Usage
<script setup lang="ts">
import { useActiveElement } from '@vueuse/core';
import { watch } from 'vue';
const activeElement = useActiveElement();
watch(activeElement, (el) => {
console.log('focus changed to', el);
});
</script>
Component Usage
<template>
<UseActiveElement v-slot="{ element }">
Active element is {{ element?.dataset.id }}
</UseActiveElement>
</template>
Type Declarations
export interface UseActiveElementOptions
extends ConfigurableWindow, ConfigurableDocumentOrShadowRoot {
/**
* Search active element deeply inside shadow dom
*
* @default true
*/
deep?: boolean;
/**
* Track active element when it's removed from the DOM
* Using a MutationObserver under the hood
* @default false
*/
triggerOnRemoval?: boolean;
}
/**
* Reactive `document.activeElement`
*
* @see https://vueuse.org/useActiveElement
* @param options
*
* @__NO_SIDE_EFFECTS__
*/
export declare function useActiveElement<T extends HTMLElement>(
options?: UseActiveElementOptions,
): ShallowRef<T | null | undefined, T | null | undefined>;
export type UseActiveElementReturn = ReturnType<typeof useActiveElement>;