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.
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)

  • 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
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
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 in the input this label labels.

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
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
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 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:
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