---
url: "https://vueda.dev/v3/reference/api/js/use/useWidget/functions/useWidget.md"
title: "useWidget"
---

# useWidget

## Overview

Generate and provide a widget context for a widget, using the provided props and emit function, including methods to
 update the widget's value, touch state, force modified recalculation, and focus or blur it.

## Signature

`useWidget(props, emit)`

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| <span id="param-props">props</span> | `object` | yes | The widget context's reactive props. |
| <span id="param-emit">emit</span> | `(event: string, args: any[]) => void` | yes | The widget context's component emit function. |

#### props Properties

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| <span id="param-props-contextless">contextless</span> | `boolean` |  |  | If true, the widget ignores surrounding context like field or form. |
| <span id="param-props-disabled">disabled</span> | `boolean` |  |  | Whether the widget is disabled. |
| <span id="param-props-disabledFn">disabledFn</span> | `() => boolean` |  |  | A function that returns a boolean indicating disabled state. |
| <span id="param-props-displayDependencies">displayDependencies</span> | `string[]` |  |  | The widget dependencies to register with the field context, if any. |
| <span id="param-props-fieldToWidget">fieldToWidget</span> | `ValueAdapter` |  |  | The value adapter for turing form  values into values suitable for UI concerns. |
| <span id="param-props-help">help</span> | `string` |  |  | The help text for the widget. |
| <span id="param-props-invalid">invalid</span> | `boolean` |  |  | Whether the widget is invalid, when not in a field context. |
| <span id="param-props-label">label</span> | `string` |  |  | The label to display next to the widget. |
| <span id="param-props-modelValue">modelValue</span> | `any` |  |  | The widget’s bound value (v-model). |
| <span id="param-props-name">name</span> | `string` |  |  | The name of the widget. |
| <span id="param-props-required">required</span> | `boolean` |  |  | Whether the widget is required. Inherits from field context if undefined. |
| <span id="param-props-warning">warning</span> | `boolean` |  |  | Whether the widget is in a warning state, when not in a field context. |
| <span id="param-props-widgetToField">widgetToField</span> | `ValueAdapter` |  |  | The value adapter for the widget values  back into form values, for validation and submission concerns. |

### Returns

[WidgetContext](/v3/reference/api/js/use/useWidget/types/WidgetContext.md)

The widget context object.

## Source

`client/lib/use/useWidget.js:220`
