Attributes Helper is a plugin for Kirby 3 providing a helper method to build attributes based on conditions, like conditionally adding classes to an element.
<h1
<?=attrs([
'id' => 'static-value',
'class' => [
'headline' => true // will always be added
'is-active' => $page->active()->isTrue() // will only be added when the field value is true
]
])?>
>
This is a headline with conditional class names.
</h1>
Download and copy this repository to /site/plugins/attrs-helper
.
git submodule add https://github.com/hananils/kirby-attrs-helper.git site/plugins/attrs-helper
composer require hananils/kirby-attrs-helper
This plugin is provided freely under the MIT license by hana+nils · Büro für Gestaltung.
We create visual designs for digital and analog media.