diff --git a/README.md b/README.md
index d67b907c..d1fd2144 100644
--- a/README.md
+++ b/README.md
@@ -200,6 +200,7 @@ Data for rendering the tree select items. The object requires the following stru
className, // optional: Additional css class for the node. This is helpful to style the nodes your way
tagClassName, // optional: Css class for the corresponding tag. Use this to add custom style the pill corresponding to the node.
actions, // optional: An array of extra action on the node (such as displaying an info icon or any custom icons/elements)
+ dataset, // optional: Allows data-* attributes to be set on the node and tag elements
... // optional: Any extra properties that you'd like to receive during `onChange` event
}
```
diff --git a/src/dataset-utils.js b/src/dataset-utils.js
new file mode 100644
index 00000000..6722e90d
--- /dev/null
+++ b/src/dataset-utils.js
@@ -0,0 +1,8 @@
+const toKebabCase = (str) => str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
+
+const getDataset = (o = {}) => Object.keys(o).reduce((acc, cur) => {
+ acc[`data-${toKebabCase(cur)}`] = o[cur]
+ return acc
+}, {})
+
+export {getDataset}
diff --git a/src/input/index.js b/src/input/index.js
index 3740c672..43dff833 100644
--- a/src/input/index.js
+++ b/src/input/index.js
@@ -4,14 +4,15 @@ import cn from 'classnames/bind'
import debounce from 'lodash.debounce'
import Tag from '../tag'
import styles from './index.css'
+import { getDataset } from '../dataset-utils'
const cx = cn.bind(styles)
const getTags = (tags = [], onDelete) => {
return tags.map((tag, i) => {
- const {_id, label, tagClassName} = tag
+ const {_id, label, tagClassName, dataset} = tag
return (
-