Common Attributes
allowedCharPattern
Sets a regular expression for the user input to check to the client-side. The allowed char pattern must be a valid JavaScript Regular Expression that matches a single character, not the sequence of characters.
For example, to allow entering only numbers and slash character, use "[0-9/]"
pattern.
alignItems
Defines how items are aligned on the cross axis. Possible values:
-
START – items are placed at the start of the cross axis.
-
END – items are placed at the end of the cross axis.
-
CENTER – items are centered in the cross axis.
-
STRETCH – items with undefined size along the cross axis are stretched to fit the container.
-
BASELINE – items are positioned at the baseline of the container. Works for
flex-direction: row
only -
AUTO – the item inherits its parent container’s alignItems value, or "stretch" if it has no parent container.
For usage examples visit the Layout Rules section.
alignSelf
Aligns individual items inside the container overriding alignItems attribute. Possible values:
-
START – item is placed at the start of the cross axis.
-
END – item is placed at the end of the cross axis.
-
CENTER – item is centered on the cross axis.
-
STRETCH – item with undefined size along the cross axis is stretched to fit the container.
-
BASELINE – item is positioned at the baseline of the container. Works for
flex-direction: row
only. -
AUTO – item inherits its parent container’s alignItems value, or "stretch" if it has no parent container.
For usage examples visit the Layout Rules section.
ariaLabel
Sets a separate, visually hidden label for accessibility technologies, such as screen readers.
autocapitalize
Sets the autocapitalize
HTML attribute. It is used to define whether the text entered by the user should be automatically capitalized or not.
autocomplete
Sets the autocomplete
HTML attribute for indicating whether the value of this component can be automatically completed by the browser.
autofocus
Specifies that the component should have input focus when the page loads.
Possible values are true
, false
. By default, all components are not focused.
clickShortcut
Defines the keyboard shortcut to fire a click event associated with the component. The component must have an appropriate handler to process the click event, otherwise the key combination will not have any effect.
colspan
Sets the number of columns that the component should occupy if it is placed in a formLayout.
Default is 1
.
css
Provides a declarative way to set CSS properties for UI components.
In this example, the css
attribute is used to apply inline styles to the textField component, including setting the background color, border, padding, and font size:
<textField datatype="int"
css="background-color: #f0f0f0;
border: 1px solid #ccc;
padding: 5px;
font-size: 16px;"/>
In the example below, the css
attribute is used to provide inline CSS for the button component.
<button id="stepperUpBtn"
icon="vaadin:chevron-up"
css="background-color: #4CAF50;
color: #fff;
border: none;
padding: 10px 20px;
font-size: 16px;
cursor: pointer"/>
dataContainer
Sets a data container defined in the data
section of the view XML descriptor.
If you set an InstanceContainer in the dataContainer
attribute, you should also set the property attribute.
datatype
Sets a data type of the component’s content. Possible values:
-
boolean
-
byteArray
-
char
-
date
-
dateTime
-
decimal
-
double
-
fileRef
-
int
-
localDate
-
localDateTime
-
localTime
-
long
-
offsetDateTime
-
offsetTime
-
string
-
time
-
uri
-
uuid
Set this attribute if the component is not linked to an entity attribute. Otherwise, the data type is defined by the entity attribute type.
dateFormat
Sets a preferred format for date values in the component. By default, the current locale date format is used.
height
Sets the height of the component.
The height should be in a format understood by the browser, for example, "100px"
or "2.5em"
.
helperText
Defines a text adjacent to the component. It can be used, for example, to inform users which values the component expects.
id
An identifier of the component.
It is recommended to create identifiers according to the rules for Java identifiers and use camelСase, for example: userGrid
, filterPanel
. The id
attribute can be specified for any component and should be unique within a view.
invalid
Sets an invalid state to the field considering the result of the field validation.
-
If
invalid=false
, the field is valid regardless of the validation result. -
If
invalid=true
, the field is valid only if the validation is passed successfully.
label
Specifies the label of the component.
The attribute value can either be the text itself or a key in the message bundle. In case of a key, the value should begin with the msg://
prefix.
metaClass
Defines an entity class for components displaying entities, like dataGrid or entityComboBox.
Set this attribute if the component is not linked to a data container. Otherwise, the entity type is defined by the data container.
property
Sets the name of an entity attribute, which value will be displayed and edited by this visual component.
property
is always used together with the dataContainer attribute.
requiredMessage
Used together with the required attribute. Sets a message that will be displayed to a user when the component has no value.
The attribute can contain a message or a key from message bundle, for example: requiredMessage="msg://infoTextField.requiredMessage"
step
Sets a custom time interval, in minutes, between values available for selection in the timePicker and dateTimePicker components. The default value is 60
.
tabIndex
Sets the tabindex
HTML attribute in the component. The attribute indicates if its element can be focused, and if/where it participates in sequential keyboard navigation:
-
A negative value (usually
tabindex = -1
means that the component should be focusable, but should not be reachable via sequential keyboard navigation. -
tabindex = 0
means that the component should be focusable in sequential keyboard navigation, but its order is defined by the document’s source order. -
A positive value means the component should be focusable in sequential keyboard navigation, with its order defined by the value of the number. That is,
tabindex = 4
would be focused beforetabindex = 5
, but aftertabindex = 3
. If multiple components share the same positivetabindex
value, their order relative to each other follows their position in the document source.
text
Sets a text content of the component.
The attribute value can either be the text itself or a key in the message bundle. In case of a key, the value should begin with the msg://
prefix.
There are two ways of setting a key:
-
A short key - in this case the message will be searched in the message group of the current view. For example:
msg://infoField.caption
-
Full key including message group, for example:
msg://com.company.sample.view.user/infoField.caption
title
The value of the attribute is set to the title and aria-label HTML attributes. Most components interpret it as a tooltip.
value
Sets the value of the component. If the new value is not equal to getValue()
, fires a value change event. May throw IllegalArgumentException
if the value is not acceptable.
valueChangeTimeout
Applies the value change timeout of the given valueChangeMode.
weekNumbersVisible
Specifies whether week numbers are visible in the calendar overlay. This works only when the first day of week is set to Monday.
width
Sets the width of the component. The width should be in a format understood by the browser, for example, "100px"
or "2.5em"
.