This documentation site is about the unstable (upcoming) Comentario version.  Switch to the stable version »

Attribute: max-level

The max-level attribute of the <comentario-comments> limits the visual nesting level of comments

The max-level attribute of the comments tag allows to limit the displayed nesting (indentation) of embedded comments.

Comments become nested when they are created as a reply to another comment. Comentario doesn’t limit the actual nesting level: any comment can be replied to.

It is, however, difficult to deal with comments nested too deeply. Since every level gets indented further to the right, thus limiting the available width for the comment text, it will get unusable at some point.

To address the above issue, Comentario will cap the visual nesting level at 10 by default. You can adjust this value by using the max-level attribute.

Changing the value on-the-fly

This attribute is reactive: changing it on an already-embedded tag re-indents the comments right away, without reloading the browser page:

document.querySelector('comentario-comments').setAttribute('max-level', '3');

Only the already-loaded comment tree is re-rendered, so nothing is fetched from the server and the user stays logged in. This makes the attribute a convenient way to adapt the nesting to the available width, for example on a viewport resize.

Re-rendering the tree does close a reply or edit editor opened inside it, discarding its text, just like changing the comment sort order does. The editor for a new top-level comment isn’t affected.

See also