# Getting Started with the Kendo UI for Vue ListBox

This guide provides essential information about using the Kendo UI for Vue ListBox package—you will learn how to install the ListBox package, add a ListBox component to your project, style the component, and activate your license.

<CtaPanelOverview></CtaPanelOverview>

After completing this guide, you will be able to reproduce the following example.

[Demo Source](https://demos.telerik.com/kendo-vue-ui/listbox/get-started/source.txt)

## Setting Up Your Vue Project

Before you install the Kendo UI for Vue ListBox, make sure that you have a running Vue project. The easiest way to set up a Vue project is to use the approach described in the [Set up the Vue project](https://www.telerik.com/kendo-vue-ui/components/getting-started/javascript-composition-api#1-set-up-the-vue-project) section of the [First Steps with JavaScript ](https://www.telerik.com/kendo-vue-ui/components/getting-started/javascript-composition-api) article.

## Installing the ListBox Package

All Kendo UI for Vue packages are distributed through npm and offer a similar installation experience. To use the ListBox component, start with the installation of the ListBox npm package and its [dependencies](https://www.telerik.com/kendo-vue-ui/components/listbox/get-started#dependencies). Use Node.js v5.0.0 or later.

```sh
npm install --save @progress/kendo-vue-listbox @progress/kendo-licensing @progress/kendo-svg-icons
```

## Importing the Component

After installing the package, import the ListBox component in the Vue App. To provide a flawless data transfer between multiple ListBox components, import the `processListBoxData` method.

In the `src/App.vue` file of your Vue project, import the `ListBox` component from the ListBox package.

```jsx
// ES2015 module syntax
import { ListBox } from "@progress/kendo-vue-listbox";
```

```jsx
// CommonJS format
const { ListBox } = require('@progress/kendo-vue-listbox');
```

## Using the Component

1. Import the `data` file in the `src/App.vue` file.

   ```jsx
     import { data } from './data';
   ```

2. Define the variables that will hold the data for the two ListBox components.

   ```jsx
     data() {
       return {
         employees: data,
         developers: [],
       };
     }
   ```

3. Set the [selectedField](https://www.telerik.com/kendo-vue-ui/components/listbox/api/listboxprops#selectedfield) value. That value will determine which items are selected.

   ```jsx
     const SELECTED_FIELD = 'selected';
     .....
     data() {
       return {
         SELECTED_FIELD,
         ......
       };
     }
   ```

4. Add a handler for the [onItemClick](https://www.telerik.com/kendo-vue-ui/components/listbox/api/listboxprops#onitemclick) event of the ListBox. It is needed select or deselect items.

   ```jsx
     handleItemClick(event, data, connectedData) {
       this[data] = this[data].map((item) => {
         if (item.name === event.dataItem.name) {
           item[SELECTED_FIELD] = !item[SELECTED_FIELD];
         } else if (!event.ctrlKey) {
           item[SELECTED_FIELD] = false;
         }
         return item;
       });
       this[connectedData] = this[connectedData].map((item) => {
         item[SELECTED_FIELD] = false;
         return item;
       });
     }
   ```

5. Add a handler for the [onToolClick](https://www.telerik.com/kendo-vue-ui/components/listbox/api/listboxtoolbarprops#ontoolclick) event of the ListBoxToolbar. It is needed to update the lists.

   ```jsx
     handleToolBarClick(e) {
       let toolName = e.toolName || '';
       let result = processListBoxData(
         this.employees,
         this.developers,
         toolName,
         SELECTED_FIELD
       );

       this.employees = result.listBoxOneData;
       this.developers = result.listBoxTwoData;
     }
   ```

6. Add the markup of the two components to the template section of the `src/App.vue` file in your project.

   ```jsx
   <div class="container">
       <div class="row justify-content-center">
       <div class="col">
           <h6>Employees</h6>
           <ListBox
           :style="{ height: '400px', width: '100%' }"
           :dataItems="employees"
           :text-field="'name'"
           :selectedField="SELECTED_FIELD"
           :draggable="false"
           @itemclick="itemClick"
           :toolbar="'toolbar'"
           >
           <template #toolbar>
               <ListBoxToolbar
               :tools="[
                   'moveUp',
                   'moveDown',
                   'transferTo',
                   'transferFrom',
                   'transferAllTo',
                   'transferAllFrom',
                   'remove',
               ]"
               :dataItems="employees"
               :dataConnected="developers"
               @toolclick="handleToolBarClick"
               />
           </template>
           </ListBox>
       </div>
       <div class="col">
           <h6>Developers</h6>
           <ListBox
           :style="{ height: '400px', width: '100%' }"
           :dataItems="developers"
           :textField="'name'"
           :selectedField="SELECTED_FIELD"
           @itemclick="itemClick2"
           />
       </div>
       </div>
   </div>
   ```

7. To style the ListBox, install and import the [Meridian theme](https://www.telerik.com/design-system/docs/themes/kendo-themes/meridian/), which is one of the [five beautiful themes](https://www.telerik.com/kendo-vue-ui/components/styling) for Kendo UI for Vue.

   1. Install the Meridian theme package.

      ```sh
      npm install --save @progress/kendo-theme-meridian
      ```

   2. Import the Theme package in `src/App.vue`..

      ```jsx
      import '@progress/kendo-theme-meridian';
      ```

8. Build, run and test the application by typing the following command in the root folder of your project:

   ```sh
   npm run dev
   ```

## Activating Your License Key

Using any of the UI components in the Kendo UI for Vue library requires either a commercial license key or an active trial license key.

Follow the instructions on the [My License page](https://www.telerik.com/kendo-vue-ui/components/my-license) to activate your trial or commercial license. You can skip this step if your application already contains a Kendo UI for Vue license file.

## Dependencies

The ListBox package requires you to install the following [peer dependencies](https://nodejs.org/en/blog/npm/peer-dependencies/) in your application:

| Package Name                | Description                                                                                |
| --------------------------- | ------------------------------------------------------------------------------------------ |
| vue 3.0.0+                  | Contains the functionality necessary to define Vue components.                             |
| @progress/kendo-licensing   | Contains the internal infrastructure related to licensing.                                 |
| @progress/kendo-svg-icons   | Contains the svg icons for the components.                                                 |
| @progress/kendo-vue-buttons | Contains the definitions of all Button components available in the Kendo UI for Vue suite. |

## Suggested Links

* [Selection](https://www.telerik.com/kendo-vue-ui/components/listbox/selection)
* [Drag and Drop](https://www.telerik.com/kendo-vue-ui/components/listbox/drag-and-drop)
* [Customization](https://www.telerik.com/kendo-vue-ui/components/listbox/customization)
* [Multiple Lists](https://www.telerik.com/kendo-vue-ui/components/listbox/multiple-lists)
* [Globalization](https://www.telerik.com/kendo-vue-ui/components/listbox/globalization)

## Learning Resources

* [Kendo UI for Vue - First Steps with JavaScript](https://www.telerik.com/kendo-vue-ui/components/getting-started/javascript-composition-api)
* [Kendo UI for Vue - First Steps with JavaScript + Options API](https://www.telerik.com/kendo-vue-ui/components/getting-started/javascript-options-api)
* [Kendo UI for Vue - First Steps with TypeScript](https://www.telerik.com/kendo-vue-ui/components/getting-started/typescript-composition-api)
* [Kendo UI for Vue - First Steps with TypeScript + Options API](https://www.telerik.com/kendo-vue-ui/components/getting-started/typescript-options-api)
* [Virtual Classroom - Kendo UI for Vue with TypeScript(Course Available to Trial and Commercial License Holders)](https://learn.telerik.com/learn/course/internal/view/elearning/45/kendo-ui-for-vue-with-typescript)
* [Kendo UI Productivity Tools extension for VS Code](https://www.telerik.com/kendo-vue-ui/components/vscode-extension)
