Category | Elements |
---|---|
Export Size | 712 B |
Last Changed | 4 months ago |
Reactive document.activeElement
import { useActiveElement } from '@vueuse/core' const activeElement = useActiveElement() watch(activeElement, (el) => { console.log('focus changed to', el) })
This function also provides a renderless component version via the
@vueuse/components
package. Learn more about the usage.
<UseActiveElement v-slot="{ element }"> Active element is {{ element.dataset.id }} </UseActiveElement>
export interface UseActiveElementOptions extends ConfigurableWindow, ConfigurableDocumentOrShadowRoot {} /** * Reactive `document.activeElement` * * @see https://vueuse.org/useActiveElement * @param options */ export declare function useActiveElement<T extends HTMLElement>( options?: UseActiveElementOptions ): ComputedRefWithControl<T | null | undefined>
© 2019-present Anthony Fu
Licensed under the MIT License.
https://vueuse.org/core/useActiveElement/