> For the complete documentation index, see [llms.txt](https://designsystem.dubai.ae/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://designsystem.dubai.ae/developers/input-interactions.md).

# Input Interactions

Our component library supports two way interactions with components.

You can pass value to the components and also receive back any changed/entered value.

The below attributes can be used to interact with any applicable form component.

### **Getting Values/Updates from a component:**

<table><thead><tr><th>Property</th><th>Description</th><th>Type</th></tr></thead><tbody><tr><td><p></p><pre class="language-typescriptreact"><code class="lang-typescriptreact">getValue
</code></pre></td><td>This method returns the selected/entered value.<br>The method returns the selected/entered value.</td><td><strong>Method()</strong></td></tr><tr><td><p></p><pre class="language-typescriptreact"><code class="lang-typescriptreact">onChanged
</code></pre></td><td>This is an event emitted every time there is a change in current value of the component.<br>In the <strong>event.detail</strong> you will find the selected/entered value.</td><td><strong>Event Listener</strong></td></tr><tr><td><p></p><pre class="language-typescriptreact"><code class="lang-typescriptreact">onBlurred
</code></pre></td><td>This is an event emitted every time the component loses focus.<br>In the <strong>event.detail</strong> you will find the selected/entered value.</td><td><strong>Event Listener</strong></td></tr><tr><td><p></p><pre class="language-typescriptreact"><code class="lang-typescriptreact">input
</code></pre></td><td>This is the default event that is fired once the value of the element is changed.<br>You will receive the event as a value.</td><td><strong>Event Listener</strong></td></tr><tr><td><p></p><pre class="language-typescriptreact"><code class="lang-typescriptreact">keydown
</code></pre></td><td>This is the default event that is fired once any key is pressed on the element in focus.<br>You will receive the event as a value.</td><td></td></tr></tbody></table>

### **Setting/Updating Value to a component:**

<table><thead><tr><th>Property</th><th>Description</th><th>Type</th></tr></thead><tbody><tr><td><p></p><pre class="language-typescriptreact"><code class="lang-typescriptreact">setValue
</code></pre></td><td>This method sets the selected/entered value.</td><td><strong>Method()</strong></td></tr><tr><td><p></p><pre class="language-typescriptreact"><code class="lang-typescriptreact">onChanged
</code></pre></td><td>This is an event emitted every time there is a change in current value of the component.<br>In the <strong>event.detail</strong> you will find the selected/entered value.</td><td><strong>Event Listener</strong></td></tr><tr><td><p></p><pre class="language-typescriptreact"><code class="lang-typescriptreact">onBlurred
</code></pre></td><td>This is an event emitted every time the component loses focus.<br>In the <strong>event.detail</strong> you will find the selected/entered value.</td><td><strong>Event Listener</strong></td></tr></tbody></table>

### Example Usage

#### **React JS**

<pre class="language-jsx"><code class="lang-jsx">import { useState } from "react";
// Import the component
import { DdaTextarea } from "@dubai-design-system/components-react";

function App() {
      const [text, setText] = useState("");
      
      return (
<strong>            &#x3C;>
</strong>                  &#x3C;DdaTextarea
                      onInput={(event) => {
                        console.log(event.currentTarget.getValue());
                        setText(event.currentTarget.getValue());
                      }}
                  />
                  &#x3C;p>{text}&#x3C;/p>
            &#x3C;/>
      )
}

</code></pre>

#### Angular JS

app.component.ts

```javascript
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
})
export class AppComponent {
  text = '';

  async handleInput(event: Event) {
    const target = event.target as any;
    const value = await target.getValue();
    console.log(value);
    this.text = value;
  }
}
```

app.component.html

```html
<dda-textarea (input)="handleInput($event)"></dda-textarea>
<p>{{ text }}</p>
```

#### Vanilla JS

```html
<div>
    <dda-textarea id="dda-textarea"></dda-textarea>
    <p id="output"></p>
</div>

<script>
      const textareaEl = document.getElementById('dda-textarea');
      const outputEl = document.getElementById('output');

      textareaEl.addEventListener('input', (event) => {
        const value = textareaEl.getValue();
        console.log(value);
        outputEl.textContent = value;
      });
</script>
```

#### Setting a Value

```jsx
import { useState } from "react";
import { DdaInput } from "@dubai-design-system/components-react";

function App() {
  const [text, setText] = useState("");
  return (
    <>
      <div className="card">
        <DdaInput
          onInput={(event) => {
            console.log(event.currentTarget.getValue());
            setText(event.currentTarget.getValue());
          }}
          id="myInputId"
        />
        <p>{text}</p>

        <button
          onClick={() => {
            document.getElementById("myInputId").setValue("Sample Value");
            setText("Sample Value");
          }}
        >
          Set Sample Value
        </button>
      </div>
    </>
  );
}

export default App;

```
