Inheritance: Element -> NavigableElement -> VisualElement -> View Xamarin.Forms documentation: Label API / Guide

For details on how the control actually works, please refer to the Xamarin.Forms documentation.



Label(text: string)

Defines a Label widget with a text



characterSpacing(value: float)

Sets the spacing between each character of the text

font(?size: float, ?namedSize: NamedSize, ?attributes: FontAttributes, ?fontFamily: string)

Sets the font

horizontalTextAlignment(value: textAlignment)

Sets the horizontal alignment of the text

lineBreakMode(value: LineBreakMode)

Sets the line break mode

lineHeight(value: float)

Sets the multiplier to apply to the default line height when displaying text

maxLines(value: int)

Sets the maximum number of lines allowed

padding(value: Thickness)

Sets the amount of padding around the text

padding(value: float)

Sets a uniform amount of padding around the text

padding(left: float, top: float, right: float, bottom: float)

Sets the amount of padding around the text

textColor(light: FabColor, ?dark: FabColor)

Sets the text color depending if light or dark mode

textDecoration(value: TextDecorations)

Sets the text decorations (underline, strike, etc) to apply on the text

textTransform(value: TextTransform)

Sets the text transformation (lowercase, uppercase) to apply on the text

textType(value: TextType)

Sets the text type (plain text, HTML)

verticalTextAlignment(value: TextAlignment)

Sets the vertical alignment of the text

reference(value: ViewRef<Label>)

Sets a ViewRef instance to retrieve the Xamarin.Forms.Label instance associated to this widget

Shorthand properties



Center the text horizontally inside the Label. Same as horizontalTextAlignment(TextAlignment.Center)


Center the text vertically inside the Label. Same as verticalTextAlignment(TextAlignment.Center)




Label("Hello World")
    .font(namedSize = NamedSize.Large, fontFamily = "Arial", attributes = FontAttributes.Bold)
    .textColor(light = Color.Red.ToFabColor(), dark = Color.Blue.ToFabColor())

Use shorthand properties

Label("Hello World")
    .size(500., 500.)

Get access to the underlying Xamarin.Forms.Label

let labelRef = ViewRef<Label>()

Label("Hello World")

Last updated