<html> tag attribute

Hi,

What is the best practice for adding a data attribute to the <html> tag, as shown in the example below from the Bootstrap website?

image

3 Answers

3

You could create a globalJS client extension and add the following in the script file:

document.getElementsByTagName('html').item(0).setAttribute('data-bs-theme', 'dark');

@Aziz_Errafay ‘s answer is probably your best option.

I mean, you could build a theme and embed this value into the portal_normal template, but I’m guessing you’re looking to make it changeable, and storing it in the theme like this would not allow for that.

A theme var would make it changeable, but only by someone with the necessary access, so you couldn’t use “dark” while I use “light”.

Aziz’ answer would allow it to set based upon user preference, changeable by the user at any time, and is probably what you’re going after.

Thank you for the proposed solution.