dataAttrs
Declare one or more HTML data attributes
For example, migrating the example at https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes#html_syntax
Modifier
.dataAttrs("columns" to "3", "index-number" to "12314", "parent" to "cars")
Content copied to clipboard
To query a data value later through code, use the HTMLElement.dataset property (and note that names passed in using kebab case need to be queried using camel case).
element.dataset["columns"] // "3"
element.dataset["indexNumber"] // "12314"
element.dataset["parent"] // "cars"
Content copied to clipboard
Because data attributes can be queried this way, this method also supports taking in camel case names, which it converts to kebab case under the hood:
Modifier.dataAttrs("indexNumber" to "12314") // same as registering "index-number"
Content copied to clipboard