# Vue 2, how to use a prop as the class name

> Learn how to use a Vue 2 prop value as a class name, binding it with a class binding, and how to combine it with a fixed class using array syntax.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2018-06-23 | Topics: [Vue.js](https://flaviocopes.com/tags/vue/) | Canonical: https://flaviocopes.com/vue-prop-as-class-name/

Say you have a Car component.

You want to add a class to its output based on a prop.

So maybe the prop is called `color`, and you use it like this in other parts of the app:

```html
<Car color="red">
<Car color="blue">
```

In your Car component you first need to declare the color prop:

```html
<script>
export default {
  name: 'Car',
  props: {
    color: String
  }
}
</script>
```

then you can use it in the template part:

```html
<template>
  <div :class="color"></div>
</template>
```

If you want to add a `car` class, plus the class determined by the color prop, you can use this syntax:

```html
<template>
  <div :class="['car', color]"></div>
</template>
```

Happy coding!
