dataAttrs

fun Modifier.dataAttrs(vararg nameValues: Pair<String, String>): Modifier(source)

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")

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"

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"