API Documentation

Documentation for developing SailfishOS applications

Label QML Type

A text label More...

Import Statement: import Sailfish.Silica 1.0
Inherited By:

MenuItem and SectionHeader

Properties

Detailed Description

The Label type provides a Sailfish-styled text label. The default color, font family and font size are set according to the current ambience.

The label text is simply set with the text property:

 import Sailfish.Silica 1.0

 Label {
     text: "Hello, world!"
 }

When choosing different colors or font properties it is recommended that the values exposed by the Theme object are used. For example:

 import Sailfish.Silica 1.0

 Label {
     text: "Hello, world!"
     color: Theme.highlightColor
     font.family: Theme.fontFamilyHeading
 }

See the Theme documentation for guidelines on styling text colors and sizes in Sailfish OS.

Label inherits the QtQuick Text type, so any properties, signals and methods of Text (such as the color and font.family properties in the example above) are also available to Label objects. See the Text documentation for its full list of available properties, signals and methods.

In most cases Label should be used in preference to the Text type.

Default Text property values

Labels use the following Text property values by default:

  • color: Theme.primaryColor
  • font.pixelSize: Theme.fontSizeMedium
  • textFormat: Text.PlainText
  • elide: if the text is truncated with TruncationMode.Elide, this elides automatically according to the current horizontalAlignment, otherwise this is Text.ElideNone

Property Documentation

truncationMode : enumeration

Specifies the effect to apply to the end of the text string if it does not fit within the bounds of this item. This is one of:

  • TruncationMode.None (default)
  • TruncationMode.Elide
  • TruncationMode.Fade

TruncationMode.Fade is the preferred truncation mode in Sailfish OS. Note it will only be applied to single line text; multiline text will fall back to TruncationMode.Elide.

Note that setting Text::elide will override truncationMode.


We use cookies to improve your user experience and to help us to develop our services. By continuing to browse the site, you approve of our use of cookies.