---
title: DataValue
---

Base type for values that can be stored in inputs. Provides
functions for checking the underlying value type.


## Static Functions

### `number`

{/* number: () -> DataValueNumber */}
<div class="signature">
```lua
number() -> DataValueNumber
```
</div>

Creates a [DataValueNumber](/scripting/api-reference/data-value/data-value-number) that stores a number.
```lua
local data = DataValue.number()
data.value = 42

print(data.value) -- 42
```


### `string`

{/* string: () -> DataValueString */}
<div class="signature">
```lua
string() -> DataValueString
```
</div>

Creates a [DataValueString](/scripting/api-reference/data-value/data-value-string) that stores a string.
```lua
local data = DataValue.string()
data.value = 'Rive for life!'

print(data.value) -- Rive for life!
```


### `boolean`

{/* boolean: () -> DataValueBoolean */}
<div class="signature">
```lua
boolean() -> DataValueBoolean
```
</div>

Creates a [DataValueBoolean](/scripting/api-reference/data-value/data-value-boolean) that stores a boolean.
```lua
local data = DataValue.boolean()
data.value = false

print(data.value) -- false
```


### `color`

{/* color: () -> DataValueColor */}
<div class="signature">
```lua
color() -> DataValueColor
```
</div>

Creates a [DataValueColor](/scripting/api-reference/data-value/data-value-color) that stores a [Color](/scripting/api-reference/color/color).
```lua
local data = DataValue.color()
data.value = Color.rgba(128, 55, 12, 128)

print(Color.red(data.value)) -- 255
```


## Methods

### `isNumber`

{/* function isNumber(self): boolean */}
<div class="signature">
```lua
isNumber() -> boolean
```
</div>

Returns true if the value is a number.
```lua
local dv: DataValueNumber = DataValue.number()
print(dv.isNumber) -- true
```


### `isString`

{/* function isString(self): boolean */}
<div class="signature">
```lua
isString() -> boolean
```
</div>

Returns true if the value is a string.
```lua
local dv: DataValueNumber = DataValue.number()
print(dv.isString) -- false
```


### `isBoolean`

{/* function isBoolean(self): boolean */}
<div class="signature">
```lua
isBoolean() -> boolean
```
</div>

Returns true if the value is a boolean.
```lua
local dv: DataValueNumber = DataValue.number()
print(dv.isBoolean) -- false
```


### `isColor`

{/* function isColor(self): boolean */}
<div class="signature">
```lua
isColor() -> boolean
```
</div>

Returns true if the value is a color.
```lua
local dv: DataValueNumber = DataValue.number()
print(dv.isColor) -- false
```


