IsFocusWithin

Determine if focus is within a specific element.

Demo

Focus is within form: false

Usage

	<script lang="ts">
  import { IsFocusWithin } from "runed";
 
  let formElement = $state<HTMLFormElement>();
  const focusWithinForm = new IsFocusWithin(() => formElement);
</script>
 
<p>Focus within form: {focusWithinForm.current}</p>
<form bind:this={formElement}>
  <input type="text" />
  <button type="submit">Submit</button>
</form>	
MIT

© 2024 Svecosystem Team