Components for Standard HTML Elements
Vaadin Flow comes with a set of components for standard HTML elements. Standard HTML components have an API that allows you to set most typical properties and attributes. You can also use the Element API to set any property or attribute, if the component API doesn’t have an appropriate method.
Components that can contain other components thereby implement the HtmlContainer
interface to create a hierarchical structure. The Element API allows you to create any standard HTML element using the Element
constructor. The ElementFactory
class contains factory methods for many standard HTML elements.
The module flow-html-components
contains the following components:
Component | HTML Element | Comments |
---|---|---|
|
| The anchor element defines a hyperlink to a resource. It can link to many kinds of targets, such as web pages, files, email addresses, or specific locations in the same page. |
|
| The article element is independent, self-contained content, such as a forum post, a blog entry, or a comment. For creating hyperlinks that navigate to a different route in your application, see RouterLink component. |
|
| The aside element represents content that is indirectly related to the document’s main content, such as a sidebar. |
|
| The description list element represents a description list, commonly used to implement a glossary or to display metadata (a list of key-value pairs). |
|
| The div element is a generic container for content. |
|
| The emphasis element is for words that have a stressed emphasis compared to surrounding text. |
|
| The field set element is used to organize and group related inputs and their labels in a form. |
|
| The footer element represents a footer for a document or a section, often containing content such as copyright notices, contact information, or links to related documents. |
|
| The h1 to h6 elements represent six levels of section headings, with |
|
| The header element represents a container for introductory content, usually containing a logo, a search form, and a heading element. |
|
| The horizontal rule element represents a thematic break between paragraph-level content, typically rendered as a horizontal rule separating sections of text. |
| any | Wrapper for raw HTML content. See the HTML Component section for more information. |
|
| The object element defines a container for an external resource, such as a web page, a picture, a media player or a resource to be handled by a plugin. |
|
| The iframe element represents a nested browsing context, used for embedding another HTML page into the current one. |
|
| The image element is used to display an image within the web page. |
|
| The input element defines a field where the user can enter data. For most use cases, there is a dedicated Vaadin component that provides more advanced functionality. |
|
| The list item element represents an item within a list. It is typically used inside an |
|
| The main element represents the dominant content of a document’s |
|
| The button element defines a clickable button. For most use cases, prefer the more advanced Vaadin Button component. |
|
| The details element is often used to create an interactive widget that the user can open and close. For most use cases, prefer the more advanced Vaadin Details component. |
|
| The label element represents a caption for a form control, typically an |
|
| The table element represents data presented in a two-dimensional table comprised of rows and columns of cells containing data. For most use cases, prefer the more advanced Vaadin Grid, Grid Pro or Tree Grid. |
|
| The table body element encapsulates a set of table rows ( |
|
| The caption element specifies the caption (or title) of a table, providing the table an accessible description. |
|
| The table data cell element defines a cell of a table that contains data and may be used as a child of the |
|
| The table footer element encapsulates a set of table rows ( |
|
| The table head element encapsulates a set of table rows ( |
|
| The table header element defines a header cell, which can be used inside a |
|
| The table row element defines a row of cells in a table. The row can contain either |
|
| The navigation element defines a set of navigation links, typically used for menus, tables of contents, or indexes. Navigation is also supported by the more advanced Vaadin Side Nav component. For menu implementations, see the Vaadin Menu Bar component. |
|
| The ordered list element represents an ordered list of items ( |
|
| The paragraph element represents a block of text, commonly known as a paragraph. |
|
| The object parameter element defines parameters for an <object> element. Usage is not recommended, as it has been deprecated in HTML. |
|
| The pre-formatted text element represents pre-formatted text which is to be presented exactly as written in the HTML file, thus preserving both spaces and line breaks. |
|
| The range input element is an input element with its |
|
| The section element represents a generic standalone section of a document. A section should typically include a heading ( |
|
| The span element is a generic inline container for phrasing content, which does not inherently represent anything. It is typically used to style a specific portion of text or as a placeholder for dynamic content. |
|
| The unordered list element represents an unordered list of items ( |
HTML Component
The Html
class in Vaadin Flow allows developers to encapsulate and manage raw HTML fragments in server-side Java applications. This component is particularly useful when you have an HTML snippet — either as a string or loaded from a file — that you want to insert directly into your application’s layout or routes.
The Html
class ensures that the HTML fragment is treated as a single unit with exactly one root element, which can be accessed and managed through the server-side code.
Important Considerations
Regarding the Html
Component, there are a few things to consider. First, remember that developers are responsible for sanitizing the HTML content before passing it to the Html
component. Failure to do so may lead to cross-site scripting (XSS) vulnerabilities, as the raw HTML is sent directly to the client.
Once an Html
object is created, the encapsulated HTML fragment cannot be modified. To change the content, a new Html
instance must be created.
You also need to know that the Html
component doesn’t expand the HTML into a server-side DOM tree. This means that while the root element can be accessed via getElement()
, and the inner content via getInnerHtml()
, you can’t traverse or manipulate the DOM structure on the server side.
Also, the HTML fragment must have exactly one root element. If the fragment contains multiple root elements, an IllegalArgumentException
is thrown.
Last thing to consider is that the Html
component doesn’t support SVG elements as a root node. For SVG content, the Svg
component should be used instead.
6774751B-921E-4B79-941E-830D9C3532B4