Benefit usage of toolkit attribute instead of plain html

There are a lot of toolkit ‘helpers’ in the docs, and I like to get a better understanding of their benefit. I’m used to code data-attributes like this

<button type="button" data-toggle="collapse" data-target="#navToggle"
        aria-controls="navToggle" aria-expanded="false" aria-label="Toggle navigation">

but when checking the docs I see there is a toolkit Html::attrs which gives the same output. Following code is from the image.php template:

<figure<?= Html::attr(['data-ratio' => $ratio, 'data-crop' => $crop], null, ' ') ?>>

What is the benefit of using the latter?

I’d say basically a question of taste. Plus you can be sure that your attributes are correctly added, you can use pre- and suffixes, they are automatically sorted alphabetically, they can easily be stored in a variable to not clutter your code…

Thanx @texnixe I’ll refactor my code where I use html attributes and see how that fits me.
And then deep dive in the toolkit part of the docs :slight_smile: