Provides a textual label for other controls.
Labels are used as titles for single controls or groups of controls. Labels for required fields are marked with an asterisk.
Label appearance can be influenced by properties, such as textAlign
, design
, displayOnly
, wrapping
and wrappingType
.
As of version 1.50, the default value of the wrapping
property is set to false
.
As of version 1.60, you can hyphenate the label's text with the use of the wrappingType
property. For more information, see Text Controls Hyphenation.
Label
in Form controls.
Constructor for a new Label.
Accepts an object literal mSettings
that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject#constructor for a general description of the syntax of the settings object.
new sap.m.Label(sId?, mSettings?)
Param | Type | Default Value | Description |
---|---|---|---|
sId? | string | ID for the new control, generated automatically if no ID is given |
|
mSettings? | object | Initial settings for the new control |
Name | Type | Default Value | Description |
---|---|---|---|
design | sap.m.LabelDesign | Standard | Sets the design of a Label to either Standard or Bold. Visibility: public |
displayOnly | boolean | false | Determines if the label is in displayOnly mode. Note: This property should be used only in Form controls in preview mode. |
required | boolean | false | Indicates that user input is required for input control labeled by the sap.m.Label. When the property is set to true and associated input field is empty an asterisk character is added to the label text. Visibility: public |
text | string | Determines the Label text to be displayed. Visibility: public |
|
textAlign | sap.ui.core.TextAlign | Begin | Available alignment settings are "Begin", "Center", "End", "Left", and "Right". Visibility: public |
textDirection | sap.ui.core.TextDirection | Inherit | Options for the text direction are RTL and LTR. Alternatively, the control can inherit the text direction from its parent container. Visibility: public |
vAlign | sap.ui.core.VerticalAlign | Inherit | Specifies the vertical alignment of the |
width | sap.ui.core.CSSSize | empty string | Determines the width of the label. Visibility: public |
wrapping | boolean | false | Determines the wrapping of the text within the |
wrappingType | sap.m.WrappingType | Normal | Defines the type of text wrapping to be used (hyphenated or normal). Note: This property takes effect only when the |
Name | Cardinality | Type | Description |
---|---|---|---|
labelFor | 0..1 | sap.ui.core.Control |
Association to the labeled control. By default the label set the for attribute to the ID of the labeled control. This can be changed by implementing the function getIdForLabel on the labelled control. |
Method | Description |
---|---|
sap.m.Label.extend |
Creates a new subclass of class sap.m.Label with name
|
getAccessibilityInfo |
Provides the current accessibility state of the control. |
getDesign |
Gets current value of property design. Sets the design of a Label to either Standard or Bold. Default value is |
getDisplayOnly |
Gets current value of property displayOnly. Determines if the label is in displayOnly mode. Note: This property should be used only in Form controls in preview mode. Default value is |
getLabelFor |
ID of the element which is the current target of the association labelFor, or |
sap.m.Label.getMetadata |
Returns a metadata object for class sap.m.Label. |
getOverflowToolbarConfig |
Enables the |
getRequired |
Gets current value of property required. Indicates that user input is required for input control labeled by the sap.m.Label. When the property is set to true and associated input field is empty an asterisk character is added to the label text. Default value is |
getText |
Gets current value of property text. Determines the Label text to be displayed. |
getTextAlign |
Gets current value of property textAlign. Available alignment settings are "Begin", "Center", "End", "Left", and "Right". Default value is |
getTextDirection |
Gets current value of property textDirection. Options for the text direction are RTL and LTR. Alternatively, the control can inherit the text direction from its parent container. Default value is |
getVAlign |
Gets current value of property vAlign. Specifies the vertical alignment of the Default value is |
getWidth |
Gets current value of property width. Determines the width of the label. Default value is |
getWrapping |
Gets current value of property wrapping. Determines the wrapping of the text within the Default value is |
getWrappingType |
Gets current value of property wrappingType. Defines the type of text wrapping to be used (hyphenated or normal). Note: This property takes effect only when the Default value is |
setDesign |
Sets a new value for property design. Sets the design of a Label to either Standard or Bold. When called with a value of Default value is |
setDisplayOnly |
Sets a new value for property displayOnly. Determines if the label is in displayOnly mode. Note: This property should be used only in Form controls in preview mode. When called with a value of Default value is |
setLabelFor |
Sets the associated labelFor. |
setRequired |
Sets a new value for property required. Indicates that user input is required for input control labeled by the sap.m.Label. When the property is set to true and associated input field is empty an asterisk character is added to the label text. When called with a value of Default value is |
setText |
Sets a new value for property text. Determines the Label text to be displayed. When called with a value of |
setTextAlign |
Sets a new value for property textAlign. Available alignment settings are "Begin", "Center", "End", "Left", and "Right". When called with a value of Default value is |
setTextDirection |
Sets a new value for property textDirection. Options for the text direction are RTL and LTR. Alternatively, the control can inherit the text direction from its parent container. When called with a value of Default value is |
setVAlign |
Sets a new value for property vAlign. Specifies the vertical alignment of the When called with a value of Default value is |
setWidth |
Sets a new value for property width. Determines the width of the label. When called with a value of Default value is |
setWrapping |
Sets a new value for property wrapping. Determines the wrapping of the text within the When called with a value of Default value is |
setWrappingType |
Sets a new value for property wrappingType. Defines the type of text wrapping to be used (hyphenated or normal). Note: This property takes effect only when the When called with a value of Default value is |
Creates a new subclass of class sap.m.Label with name sClassName
and enriches it with the information contained in oClassInfo
.
oClassInfo
might contain the same kind of information as described in sap.ui.core.Control.extend.
Param | Type | DefaultValue | Description |
---|---|---|---|
sClassName | string |
Name of the class being created |
|
oClassInfo | object |
Object literal with information about the class |
|
FNMetaImpl | function |
Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class |
Gets current value of property design.
Sets the design of a Label to either Standard or Bold.
Default value is Standard
.
Gets current value of property displayOnly.
Determines if the label is in displayOnly mode.
Note: This property should be used only in Form controls in preview mode.
Default value is false
.
Enables the sap.m.Label
to move inside the sap.m.OverflowToolbar. Required by the sap.m.IOverflowToolbarContent interface.
Gets current value of property required.
Indicates that user input is required for input control labeled by the sap.m.Label. When the property is set to true and associated input field is empty an asterisk character is added to the label text.
Default value is false
.
Gets current value of property textAlign.
Available alignment settings are "Begin", "Center", "End", "Left", and "Right".
Default value is Begin
.
Gets current value of property textDirection.
Options for the text direction are RTL and LTR. Alternatively, the control can inherit the text direction from its parent container.
Default value is Inherit
.
Gets current value of property vAlign.
Specifies the vertical alignment of the Label
related to the tallest and lowest element on the line.
Default value is Inherit
.
Gets current value of property width.
Determines the width of the label.
Default value is empty string
.
Gets current value of property wrapping.
Determines the wrapping of the text within the Label
. If set to true the Label
will wrap, when set to false the Label
will be truncated and replaced with ellipsis which is the default behavior.
Default value is false
.
Gets current value of property wrappingType.
Defines the type of text wrapping to be used (hyphenated or normal).
Note: This property takes effect only when the wrapping
property is set to true
.
Default value is Normal
.
Sets a new value for property design.
Sets the design of a Label to either Standard or Bold.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is Standard
.
Param | Type | DefaultValue | Description |
---|---|---|---|
sDesign | sap.m.LabelDesign | Standard |
New value for property |
Sets a new value for property displayOnly.
Determines if the label is in displayOnly mode.
Note: This property should be used only in Form controls in preview mode.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is false
.
Param | Type | DefaultValue | Description |
---|---|---|---|
bDisplayOnly | boolean | false |
New value for property |
Sets the associated labelFor.
Param | Type | DefaultValue | Description |
---|---|---|---|
oLabelFor | sap.ui.core.ID sap.ui.core.Control |
ID of an element which becomes the new target of this labelFor association; alternatively, an element instance may be given |
Sets a new value for property required.
Indicates that user input is required for input control labeled by the sap.m.Label. When the property is set to true and associated input field is empty an asterisk character is added to the label text.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is false
.
Param | Type | DefaultValue | Description |
---|---|---|---|
bRequired | boolean | false |
New value for property |
Sets a new value for property text.
Determines the Label text to be displayed.
When called with a value of null
or undefined
, the default value of the property will be restored.
Param | Type | DefaultValue | Description |
---|---|---|---|
sText | string |
New value for property |
Sets a new value for property textAlign.
Available alignment settings are "Begin", "Center", "End", "Left", and "Right".
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is Begin
.
Param | Type | DefaultValue | Description |
---|---|---|---|
sTextAlign | sap.ui.core.TextAlign | Begin |
New value for property |
Sets a new value for property textDirection.
Options for the text direction are RTL and LTR. Alternatively, the control can inherit the text direction from its parent container.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is Inherit
.
Param | Type | DefaultValue | Description |
---|---|---|---|
sTextDirection | sap.ui.core.TextDirection | Inherit |
New value for property |
Sets a new value for property vAlign.
Specifies the vertical alignment of the Label
related to the tallest and lowest element on the line.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is Inherit
.
Param | Type | DefaultValue | Description |
---|---|---|---|
sVAlign | sap.ui.core.VerticalAlign | Inherit |
New value for property |
Sets a new value for property width.
Determines the width of the label.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is empty string
.
Param | Type | DefaultValue | Description |
---|---|---|---|
sWidth | sap.ui.core.CSSSize | '' |
New value for property |
Sets a new value for property wrapping.
Determines the wrapping of the text within the Label
. If set to true the Label
will wrap, when set to false the Label
will be truncated and replaced with ellipsis which is the default behavior.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is false
.
Param | Type | DefaultValue | Description |
---|---|---|---|
bWrapping | boolean | false |
New value for property |
Sets a new value for property wrappingType.
Defines the type of text wrapping to be used (hyphenated or normal).
Note: This property takes effect only when the wrapping
property is set to true
.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is Normal
.
Param | Type | DefaultValue | Description |
---|---|---|---|
sWrappingType | sap.m.WrappingType | Normal |
New value for property |