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

extends Control
implements IShrinkable, Label
known direct subclasses: SmartLabel

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.

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.
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.
setDesign(sDesign)Sets a new value for property design.
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.
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
    • design : sap.m.LabelDesign (default: Standard)
    • text : string
    • textAlign : sap.ui.core.TextAlign (default: Begin)
    • textDirection : sap.ui.core.TextDirection (default: Inherit)
    • width : sap.ui.core.CSSSize (default: )
    • required : boolean (default: false)

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

Parameters:
{string}sId? ID for the new control, generated automatically if no ID is given
{object}mSettings? 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:
{string}sClassName Name of the class being created
{object}oClassInfo? Object literal with information about the class
{function}FNMetaImpl? Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
{function} Created class / constructor function
sap.m.Label.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.Label.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
getAccessibilityInfo()
See:
{sap.ui.core.Control#getAccessibilityInfo}
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.LabelDesign} Value of property design
getLabelFor(): sap.ui.core.Control
ID of the element which is the current target of the association labelFor, or null.
Returns:
{sap.ui.core.Control}
getRequired(): boolean
Gets current value of property required.

Indicates that user input is required in the input this label labels.

Default value is false.

Returns:
{boolean} Value of property required
getText(): string
Gets current value of property text.

Determines the Label text to be displayed.

Returns:
{string} Value 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.TextAlign} Value 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.TextDirection} Value 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.CSSSize} Value of property width
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.LabelDesign}sDesign New value for property design
Returns:
{sap.m.Label} Reference to this in order to allow method chaining
setLabelFor(oLabelFor): sap.m.Label
Sets the associated labelFor.
Parameters:
{sap.ui.core.Control}oLabelFor Id of an element which becomes the new target of this labelFor association; alternatively, an element instance may be given
Returns:
{sap.m.Label} Reference 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 in the input this label labels.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is false.

Parameters:
{boolean}bRequired New value for property required
Returns:
{sap.m.Label} Reference 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:
{string}sText New value for property text
Returns:
{sap.m.Label} Reference 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.TextAlign}sTextAlign New value for property textAlign
Returns:
{sap.m.Label} Reference 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.TextDirection}sTextDirection New value for property textDirection
Returns:
{sap.m.Label} Reference 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.CSSSize}sWidth New value for property width
Returns:
{sap.m.Label} Reference to this in order to allow method chaining