class sap.ui.commons.Label

Control sample: sap.ui.commons.Label
Visiblity: public
UX Guidelines:
Implements: sap.ui.commons.ToolbarItemsap.ui.core.Label
Available since: N/A
Module: sap/ui/commons/Label
Application Component: CA-UI5-CTR

The control is used for labeling other controls. The API provides formatting options, for example, for bold display or alignment. A label can have an icon.


Constructor

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.ui.commons.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


Properties

Name Type Default Value Description
design sap.ui.commons.LabelDesign Standard

Defines whether the labels are in bold format.

Visibility: public
icon sap.ui.core.URI

Determines the icon to be displayed in the control. This can be a URI to an image or an icon font URI.

Visibility: public
required boolean false

Allows to enforce the required indicator even when the associated control doesn't have a getRequired method (a required property) or when the flag is not set. If the associated control has a required property, the values of both required flags are combined with the OR operator, so a Label can't override a required=true value.

Since: 1.11.0.

Visibility: public
requiredAtBegin boolean

Determines whether the required indicator is at the beginning of the label (if set) or at the end (if not set).

Since: 1.14.0.

Visibility: public
text string empty string

Determines the text to be displayed.

Visibility: public
textAlign sap.ui.core.TextAlign Begin

Determines the alignment of the text. Available options are Begin, Center, End, Left, and Right.

Visibility: public
textDirection sap.ui.core.TextDirection Inherit

Determines the text direction - right-to-left (RTL) and left-to-right (LTR).

Visibility: public
width sap.ui.core.CSSSize empty string

Determines the control width as common CSS-size (for example, px or % as unit).

Visibility: public
wrapping boolean false

Specifies whether a line wrapping width shall be displayed when the text value is longer than the width is.

Visibility: public

Associations

Name Cardinality Type Description
labelFor 0..1 sap.ui.core.Control

Defines the association to the labeled control. By default, the label is set the for the attribute to the ID of the labeled control. This can be changed with the implementation of function getIdForLabel on the labelled control.


Methods Overview

Method Description
sap.ui.commons.Label.extend

Creates a new subclass of class sap.ui.commons.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.

getAccessibilityInfo

References:

  • sap.ui.core.Control#getAccessibilityInfo

getDesign

Gets current value of property design.

Defines whether the labels are in bold format.

Default value is Standard.

getIcon

Gets current value of property icon.

Determines the icon to be displayed in the control. This can be a URI to an image or an icon font URI.

getLabelFor

ID of the element which is the current target of the association labelFor, or null.

sap.ui.commons.Label.getMetadata

Returns a metadata object for class sap.ui.commons.Label.

getRequired

Gets current value of property required.

Allows to enforce the required indicator even when the associated control doesn't have a getRequired method (a required property) or when the flag is not set. If the associated control has a required property, the values of both required flags are combined with the OR operator, so a Label can't override a required=true value.

Default value is false.

getRequiredAtBegin

Gets current value of property requiredAtBegin.

Determines whether the required indicator is at the beginning of the label (if set) or at the end (if not set).

getText

Gets current value of property text.

Determines the text to be displayed.

Default value is empty string.

getTextAlign

Gets current value of property textAlign.

Determines the alignment of the text. Available options are Begin, Center, End, Left, and Right.

Default value is Begin.

getTextDirection

Gets current value of property textDirection.

Determines the text direction - right-to-left (RTL) and left-to-right (LTR).

Default value is Inherit.

getWidth

Gets current value of property width.

Determines the control width as common CSS-size (for example, px or % as unit).

Default value is empty string.

getWrapping

Gets current value of property wrapping.

Specifies whether a line wrapping width shall be displayed when the text value is longer than the width is.

Default value is false.

setDesign

Sets a new value for property design.

Defines whether the labels are in bold format.

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

Default value is Standard.

setIcon

Sets a new value for property icon.

Determines the icon to be displayed in the control. This can be a URI to an image or an icon font URI.

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

setLabelFor

Sets the associated labelFor.

setRequired

Sets a new value for property required.

Allows to enforce the required indicator even when the associated control doesn't have a getRequired method (a required property) or when the flag is not set. If the associated control has a required property, the values of both required flags are combined with the OR operator, so a Label can't override a required=true value.

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

Default value is false.

setRequiredAtBegin

Sets a new value for property requiredAtBegin.

Determines whether the required indicator is at the beginning of the label (if set) or at the end (if not set).

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

setText

Sets a new value for property text.

Determines the text to be displayed.

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

Default value is empty string.

setTextAlign

Sets a new value for property textAlign.

Determines the alignment of the text. Available options 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.

setTextDirection

Sets a new value for property textDirection.

Determines the text direction - right-to-left (RTL) and left-to-right (LTR).

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

Default value is Inherit.

setWidth

Sets a new value for property width.

Determines the control width as common CSS-size (for example, px or % as unit).

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

Default value is empty string.

setWrapping

Sets a new value for property wrapping.

Specifies whether a line wrapping width shall be displayed when the text value is longer than the width is.

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

Default value is false.

sap.ui.commons.Label.extend

Creates a new subclass of class sap.ui.commons.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

getAccessibilityInfo

References:

getDesign

Gets current value of property design.

Defines whether the labels are in bold format.

Default value is Standard.

getIcon

Gets current value of property icon.

Determines the icon to be displayed in the control. This can be a URI to an image or an icon font URI.

getLabelFor

ID of the element which is the current target of the association labelFor, or null.

sap.ui.commons.Label.getMetadata

Returns a metadata object for class sap.ui.commons.Label.

getRequired

Gets current value of property required.

Allows to enforce the required indicator even when the associated control doesn't have a getRequired method (a required property) or when the flag is not set. If the associated control has a required property, the values of both required flags are combined with the OR operator, so a Label can't override a required=true value.

Default value is false.

getRequiredAtBegin

Gets current value of property requiredAtBegin.

Determines whether the required indicator is at the beginning of the label (if set) or at the end (if not set).

getText

Gets current value of property text.

Determines the text to be displayed.

Default value is empty string.

getTextAlign

Gets current value of property textAlign.

Determines the alignment of the text. Available options are Begin, Center, End, Left, and Right.

Default value is Begin.

getTextDirection

Gets current value of property textDirection.

Determines the text direction - right-to-left (RTL) and left-to-right (LTR).

Default value is Inherit.

getWidth

Gets current value of property width.

Determines the control width as common CSS-size (for example, px or % as unit).

Default value is empty string.

getWrapping

Gets current value of property wrapping.

Specifies whether a line wrapping width shall be displayed when the text value is longer than the width is.

Default value is false.

setDesign

Sets a new value for property design.

Defines whether the labels are in bold format.

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.ui.commons.LabelDesign Standard

New value for property design

setIcon

Sets a new value for property icon.

Determines the icon to be displayed in the control. This can be a URI to an image or an icon font URI.

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

Param Type DefaultValue Description
sIcon sap.ui.core.URI

New value for property icon

setLabelFor

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

setRequired

Sets a new value for property required.

Allows to enforce the required indicator even when the associated control doesn't have a getRequired method (a required property) or when the flag is not set. If the associated control has a required property, the values of both required flags are combined with the OR operator, so a Label can't override a required=true value.

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 required

setRequiredAtBegin

Sets a new value for property requiredAtBegin.

Determines whether the required indicator is at the beginning of the label (if set) or at the end (if not set).

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

Param Type DefaultValue Description
bRequiredAtBegin boolean

New value for property requiredAtBegin

setText

Sets a new value for property text.

Determines the text to be displayed.

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
sText string ''

New value for property text

setTextAlign

Sets a new value for property textAlign.

Determines the alignment of the text. Available options 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 textAlign

setTextDirection

Sets a new value for property textDirection.

Determines the text direction - right-to-left (RTL) and left-to-right (LTR).

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 textDirection

setWidth

Sets a new value for property width.

Determines the control width as common CSS-size (for example, px or % as unit).

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 width

setWrapping

Sets a new value for property wrapping.

Specifies whether a line wrapping width shall be displayed when the text value is longer than the width is.

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 wrapping