Class Svg

All Implemented Interfaces:
AttachNotifier, DetachNotifier, HasElement, HasStyle, Serializable

public class Svg extends Component
A component that displays a given SVG image.

Note that it is the developer's responsibility to sanitize and remove any dangerous parts of the SVG before sending it to the user through this component. Passing raw input data to the user will possibly lead to cross-site scripting attacks.

Note, because of implementation details, we currently wrap the SVG in a div element. This might change in the future.

Since:
24.0
Author:
Vaadin Ltd
See Also:
  • Constructor Details

    • Svg

      public Svg(InputStream stream)
      Creates an instance based on the given SVG input. The string must have exactly one root element.
      Parameters:
      stream - the SVG to display
    • Svg

      public Svg(String svg)
      Creates an instance based on the given SVG string. The string must have exactly one root element.
      Parameters:
      svg - the SVG to display
    • Svg

      public Svg()
      Creates an empty Svg.
  • Method Details

    • setSvg

      public void setSvg(String svg)
      Sets the graphics shown in this component.
      Parameters:
      svg - the SVG string
    • setSvg

      public void setSvg(InputStream stream)
      Sets the graphics shown in this component.
      Parameters:
      stream - the input stream where SVG is read from