Package com.vaadin.flow.component
Class Svg
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Svg
- All Implemented Interfaces:
AttachNotifier
,DetachNotifier
,HasElement
,HasStyle
,Serializable
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 Summary
ConstructorDescriptionSvg()
Creates an empty Svg.Svg
(InputStream stream) Creates an instance based on the given SVG input.Creates an instance based on the given SVG string. -
Method Summary
Modifier and TypeMethodDescriptionvoid
setSvg
(InputStream stream) Sets the graphics shown in this component.void
Sets the graphics shown in this component.Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
Svg
Creates an instance based on the given SVG input. The string must have exactly one root element.- Parameters:
stream
- the SVG to display
-
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
Sets the graphics shown in this component.- Parameters:
svg
- the SVG string
-
setSvg
Sets the graphics shown in this component.- Parameters:
stream
- the input stream where SVG is read from
-