Class sap.m.LabelModule: sap/m/Label

extends Control
implements IShrinkable, Label

The Label control is used in a UI5 mobile application to provide label text for other controls. Design such as bold, and text alignment can be specified. As of version 1.50 the default value of the wrapping property is set to false

Labels for required fields are marked with an asterisk.

Overview

Labels are used as titles for single controls or groups of controls.

Usage

When to use

  • It's recommended to use the Label in Form controls.
  • Use title case for labels.

When not to use

  • It is not recommended to use labels in Bold.
Constructor Summary
new sap.m.Label(sId?, mSettings?)Constructor for a new Label.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.m.Label.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.Label with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.Label.getMetadata()Returns a metadata object for class sap.m.Label.
getDesign()Gets current value of property design.
getDisplayOnly()Gets current value of property displayOnly.
getLabelFor()ID of the element which is the current target of the association labelFor, or null.
getRequired()Gets current value of property required.
getText()Gets current value of property text.
getTextAlign()Gets current value of property textAlign.
getTextDirection()Gets current value of property textDirection.
getWidth()Gets current value of property width.
getWrapping()Gets current value of property wrapping.
setDesign(sDesign)Sets a new value for property design.
setDisplayOnly(bDisplayOnly)Sets a new value for property displayOnly.
setLabelFor(oLabelFor)Sets the associated labelFor.
setRequired(bRequired)Sets a new value for property required.
setText(sText)Sets a new value for property text.
setTextAlign(sTextAlign)Sets a new value for property textAlign.
setTextDirection(sTextDirection)Sets a new value for property textDirection.
setWidth(sWidth)Sets a new value for property width.
setWrapping(bWrapping)Sets a new value for property wrapping.
Constructor Detail
new sap.m.Label(sId?, mSettings?)

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 for a general description of the syntax of the settings object.

The supported settings are:

  • Properties

  • Associations

    • labelFor : (sap.ui.core.ID | sap.ui.core.Control)

In addition, all settings applicable to the base type sap.ui.core.Control can be used as well.

Parameters:
stringsId?ID for the new control, generated automatically if no ID is given
objectmSettings?Initial settings for the new control
Method Detail
sap.m.Label.extend(sClassName, oClassInfo?, FNMetaImpl?): function

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.

Parameters:
stringsClassNameName of the class being created
objectoClassInfo?Object literal with information about the class
functionFNMetaImpl?Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
functionCreated class / constructor function
sap.m.Label.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.Label.
Returns:
sap.ui.base.MetadataMetadata object describing this class
getAccessibilityInfo()
See:
sap.ui.core.Control#getAccessibilityInfo Provides the current accessibility state of the control.
getDesign(): sap.m.LabelDesign

Gets current value of property design.

Sets the design of a Label to either Standard or Bold.

Default value is Standard.

Returns:
sap.m.LabelDesignValue of property design
getDisplayOnly(): boolean

Gets current value of property displayOnly.

Determines if the label is in displayOnly mode. Controls in this mode are neither interactive, nor editable, nor focusable, and not in the tab chain.

Note: This property should be used only in Form controls in preview mode.

Default value is false.

Returns:
booleanValue of property displayOnly
Since:
1.50.0
getLabelFor(): sap.ui.core.ID
ID of the element which is the current target of the association labelFor, or null.
Returns:
sap.ui.core.ID
getRequired(): boolean

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.

Returns:
booleanValue of property required
getText(): string

Gets current value of property text.

Determines the Label text to be displayed.

Returns:
stringValue of property text
getTextAlign(): sap.ui.core.TextAlign

Gets current value of property textAlign.

Available alignment settings are "Begin", "Center", "End", "Left", and "Right".

Default value is Begin.

Returns:
sap.ui.core.TextAlignValue of property textAlign
getTextDirection(): sap.ui.core.TextDirection

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.

Returns:
sap.ui.core.TextDirectionValue of property textDirection
getWidth(): sap.ui.core.CSSSize

Gets current value of property width.

Determines the width of the label.

Default value is .

Returns:
sap.ui.core.CSSSizeValue of property width
getWrapping(): boolean

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.

Returns:
booleanValue of property wrapping
Since:
1.50
setDesign(sDesign): sap.m.Label

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.

Parameters:
sap.m.LabelDesignsDesignNew value for property design
Returns:
sap.m.LabelReference to this in order to allow method chaining
setDisplayOnly(bDisplayOnly): sap.m.Label

Sets a new value for property displayOnly.

Determines if the label is in displayOnly mode. Controls in this mode are neither interactive, nor editable, nor focusable, and not in the tab chain.

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.

Parameters:
booleanbDisplayOnlyNew value for property displayOnly
Returns:
sap.m.LabelReference to this in order to allow method chaining
Since:
1.50.0
setLabelFor(oLabelFor): sap.m.Label
Sets the associated labelFor.
Parameters:
sap.ui.core.ID|sap.ui.core.ControloLabelForID of an element which becomes the new target of this labelFor association; alternatively, an element instance may be given
Returns:
sap.m.LabelReference to this in order to allow method chaining
setRequired(bRequired): sap.m.Label

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.

Parameters:
booleanbRequiredNew value for property required
Returns:
sap.m.LabelReference to this in order to allow method chaining
setText(sText): sap.m.Label

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.

Parameters:
stringsTextNew value for property text
Returns:
sap.m.LabelReference to this in order to allow method chaining
setTextAlign(sTextAlign): sap.m.Label

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.

Parameters:
sap.ui.core.TextAlignsTextAlignNew value for property textAlign
Returns:
sap.m.LabelReference to this in order to allow method chaining
setTextDirection(sTextDirection): sap.m.Label

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.

Parameters:
sap.ui.core.TextDirectionsTextDirectionNew value for property textDirection
Returns:
sap.m.LabelReference to this in order to allow method chaining
setWidth(sWidth): sap.m.Label

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 .

Parameters:
sap.ui.core.CSSSizesWidthNew value for property width
Returns:
sap.m.LabelReference to this in order to allow method chaining
setWrapping(bWrapping): sap.m.Label

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.

Parameters:
booleanbWrappingNew value for property wrapping
Returns:
sap.m.LabelReference to this in order to allow method chaining
Since:
1.50