Skip to content

When displaying content, I (sometimes) want to set it as HTML instead of plain text so that (properly XSS-sanitized) formatting is displayed #2281

Done

Description

@Legioth

Built-in components such as Label could have a setHtml method in addition to the existing setText method. It could be implemented as this.getElement().setProperty("innerHTML", html).

I'm not sure if this should be included in the HasText mixin or if there should be a separate mixin for this purpose.

Activity

  1. Legioth commented on Jan 3, 2018

    @Legioth
    MemberAuthor

    There are some additional considerations in vaadin/vaadin-notification-flow#2.

    Of particular interest is the special case of components such as Notification that use a <template> for its contents.

  2. added this to the After 1.0 candidates milestone on Jun 27, 2018
  3. samie commented on Mar 5, 2020

    @samie
    Member

    Still valid, but is this something to solve by documenting Html element: https://vaadin.com/forum/thread/17423429/setting-element-html-content-directly

    People are also trying to use innerHTML now:
    https://vaadin.com/forum/thread/17247162

  4. totally-not-ai commented on Dec 5, 2026

    @totally-not-ai
    Contributor

    Closing: the Html component supports setting HTML content through setHtmlContent, with sanitization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions