# ArrayInput

Class · extends [`Element`](https://api.playcanvas.com/pcui/classes/Element.md) · implements [`IFocusable`](https://api.playcanvas.com/pcui/interfaces/IFocusable.md), [`IBindable`](https://api.playcanvas.com/pcui/interfaces/IBindable.md)`<unknown[]>`

Source: https://github.com/playcanvas/pcui/blob/77ed2b8ba8660c9644049b0d1942652721e7a6c4/src/components/ArrayInput/index.ts#L69

Element that allows editing an array of values.

## Constructors

### constructor

```ts
new ArrayInput(args?: Readonly<ArrayInputArgs>)
```

Creates a new ArrayInput.

**Parameters**

- `args` (`Readonly<`[`ArrayInputArgs`](https://api.playcanvas.com/pcui/interfaces/ArrayInputArgs.md)`>`, optional, default `{}`): The arguments.

## Accessors

### binding

```ts
get binding(): BindingBase
set binding(value: BindingBase)
```

Sets the Binding object for the element.

### renderChanges

```ts
get renderChanges(): boolean
set renderChanges(value: boolean)
```

Gets whether array elements should flash when their values change.

### value

```ts
get value(): unknown[]
set value(value: unknown[])
```

Gets the value of the ArrayInput as an array.

### values

```ts
set values(values: unknown[][])
```

Sets multiple array values on the ArrayInput.

## Methods

### blur

```ts
blur(): void
```

Unfocus the element

### destroy

```ts
destroy(): void
```

Destroys the Element and its events.

### focus

```ts
focus(): void
```

Focus on the element. If the input contains text and select is provided, the text will be selected on focus.

### forEachArrayElement

```ts
forEachArrayElement(fn: (element: Element, index: number) => false | void): void
```

Executes the specified function for each array element.

**Parameters**

- `fn` (`(element: Element, index: number) => false | void`): The function with signature (element, index) => bool to execute. If the function
  returns `false` then the iteration will early out.

### link

```ts
link(observers: Observer | Observer[], paths: string | string[]): void
```

Links the specified observers and paths to the Element's data binding.

**Parameters**

- `observers` (`Observer | Observer[]`): An array of observers or a single observer.
- `paths` (`string | string[]`): A path for the observer(s) or an array of paths that maps to each separate observer.

### unlink

```ts
unlink(): void
```

Unlinks the Element from its observers.

## Events

### EVENT_LINK_ELEMENT

```ts
static readonly EVENT_LINK_ELEMENT: "linkElement" = 'linkElement'
```

Fired when an array element is linked to observers.

**Example**

```ts
arrayInput.on('linkElement', (element: Element, index: number, path: string) => {
    console.log(`Element ${index} is now linked to ${path}`);
});
```

### EVENT_UNLINK_ELEMENT

```ts
static readonly EVENT_UNLINK_ELEMENT: "unlinkElement" = 'unlinkElement'
```

Fired when an array element is unlinked from observers.

**Example**

```ts
arrayInput.on('unlinkElement', (element: Element, index: number) => {
    console.log(`Element ${index} is now unlinked`);
});
```

## Inherited from [Element](https://api.playcanvas.com/pcui/classes/Element.md)

- `get alignItems(): string` · `set alignItems(value: string)`
- `get alignSelf(): string` · `set alignSelf(value: string)`
- `get class(): DOMTokenList`
- `get dom(): HTMLElement`
- `get enabled(): boolean` · `set enabled(value: boolean)`
- `get flexBasis(): string` · `set flexBasis(value: string | number)`
- `get flexDirection(): string` · `set flexDirection(value: string)`
- `get flexGrow(): string` · `set flexGrow(value: string | number)`
- `get flexShrink(): string` · `set flexShrink(value: string | number)`
- `get flexWrap(): string` · `set flexWrap(value: string)`
- `get height(): number` · `set height(value: string | number)`
- `get hidden(): boolean` · `set hidden(value: boolean)`
- `get hiddenToRoot(): boolean`
- `get ignoreParent(): boolean` · `set ignoreParent(value: boolean)`
- `get justifyContent(): string` · `set justifyContent(value: string)`
- `get justifySelf(): string` · `set justifySelf(value: string)`
- `get parent(): Element` · `set parent(value: Element)`
- `get readOnly(): boolean` · `set readOnly(value: boolean)`
- `get style(): CSSStyleDeclaration`
- `get tabIndex(): number` · `set tabIndex(value: number)`
- `get width(): number` · `set width(value: string | number)`
- `flash(): void`
- `static create<Type extends Element>(type: string, args: ElementArgs): Type`
- `static register<Type extends Element>(type: string, cls: Object, defaultArguments?: object): void`
- `static unregister(type: string): void`
- `static readonly EVENT_CLICK: "click" = 'click'`
- `static readonly EVENT_DESTROY: "destroy" = 'destroy'`
- `static readonly EVENT_DISABLE: "disable" = 'disable'`
- `static readonly EVENT_ENABLE: "enable" = 'enable'`
- `static readonly EVENT_HIDE: "hide" = 'hide'`
- `static readonly EVENT_HIDE_TO_ROOT: "hideToRoot" = 'hideToRoot'`
- `static readonly EVENT_HOVER: "hover" = 'hover'`
- `static readonly EVENT_HOVER_END: "hoverend" = 'hoverend'`
- `static readonly EVENT_PARENT: "parent" = 'parent'`
- `static readonly EVENT_READ_ONLY: "readOnly" = 'readOnly'`
- `static readonly EVENT_SHOW: "show" = 'show'`
- `static readonly EVENT_SHOW_TO_ROOT: "showToRoot" = 'showToRoot'`

## Inherited from [VectorInput](https://api.playcanvas.com/pcui/classes/VectorInput.md)

- `get error(): boolean` · `set error(value: boolean)`
