---
category: '@Integrations'
---
# useFocusTrap
Reactive wrapper for [`focus-trap`](https://github.com/focus-trap/focus-trap).
For more information on what options can be passed, see [`createOptions`](https://github.com/focus-trap/focus-trap#createoptions) in the `focus-trap` documentation.
## Install
```bash
npm i focus-trap@^7
```
## Usage
**Basic Usage**
```vue
Has Focus: {{ hasFocus }}
```
**Multiple Refs**
```vue
Has Focus: {{ hasFocus }}
...
Another target here
```
**Dynamic Focus Target**
```vue
...
...
```
**Automatically Focus**
```vue
...
```
**Conditional Rendering**
This function can't properly activate focus on elements with conditional rendering using `v-if`. This is because they do not exist in the DOM at the time of the focus activation. To solve this you need to activate on the next tick.
```vue
...
```
## Using Component
With the `UseFocusTrap` component, Focus Trap will be activated automatically on mounting this component and deactivated on unmount.
```vue
...
```
## Type Declarations
```ts
export interface UseFocusTrapOptions extends Options {
/**
* Immediately activate the trap
*/
immediate?: boolean
}
export interface UseFocusTrapReturn {
/**
* Indicates if the focus trap is currently active
*/
hasFocus: ShallowRef
/**
* Indicates if the focus trap is currently paused
*/
isPaused: ShallowRef
/**
* Activate the focus trap
*
* @see https://github.com/focus-trap/focus-trap#trapactivateactivateoptions
* @param opts Activate focus trap options
*/
activate: (opts?: ActivateOptions) => void
/**
* Deactivate the focus trap
*
* @see https://github.com/focus-trap/focus-trap#trapdeactivatedeactivateoptions
* @param opts Deactivate focus trap options
*/
deactivate: (opts?: DeactivateOptions) => void
/**
* Pause the focus trap
*
* @see https://github.com/focus-trap/focus-trap#trappause
*/
pause: Fn
/**
* Unpauses the focus trap
*
* @see https://github.com/focus-trap/focus-trap#trapunpause
*/
unpause: Fn
}
/**
* Reactive focus-trap
*
* @see https://vueuse.org/useFocusTrap
*/
export declare function useFocusTrap(
target: MaybeRefOrGetter<
Arrayable | MaybeComputedElementRef>
>,
options?: UseFocusTrapOptions,
): UseFocusTrapReturn
```