Skip to main content

Interface: LabelProps

Defined in: react/src/generated/jsx.ts:3501

Props for the Label widget.

Extends

Properties

attributes?

optional attributes: number

Defined in: react/src/generated/jsx.ts:3503

A list of style attributes to apply to the text of the label.


canFocus?

optional canFocus: boolean

Defined in: react/src/generated/jsx.ts:412

Whether the widget or any of its descendents can accept the input focus.

This property is meant to be set by widget implementations, typically in their instance init function.

Inherited from

WidgetProps.canFocus


canTarget?

optional canTarget: boolean

Defined in: react/src/generated/jsx.ts:414

Whether the widget can receive pointer events.

Inherited from

WidgetProps.canTarget


children?

optional children: ReactNode

Defined in: react/src/generated/jsx.ts:688

Inherited from

WidgetProps.children


cssClasses?

optional cssClasses: string[]

Defined in: react/src/generated/jsx.ts:416

A list of css classes applied to this widget.

Inherited from

WidgetProps.cssClasses


cssName?

optional cssName: string

Defined in: react/src/generated/jsx.ts:423

The name of this widget in the CSS tree.

This property is meant to be set by widget implementations, typically in their instance init function.

Inherited from

WidgetProps.cssName


cursor?

optional cursor: number

Defined in: react/src/generated/jsx.ts:425

The cursor used by @widget.

Inherited from

WidgetProps.cursor


ellipsize?

optional ellipsize: number

Defined in: react/src/generated/jsx.ts:3517

The preferred place to ellipsize the string, if the label does not have enough room to display the entire string.

Note that setting this property to a value other than [enum.Pango.EllipsizeMode.none] has the side-effect that the label requests only enough space to display the ellipsis "...". In particular, this means that ellipsizing labels do not work well in notebook tabs, unless the [property@Gtk.NotebookPage:tab-expand] child property is set to true.

Other ways to set a label's width are [method@Gtk.Widget.set_size_request] and [method@Gtk.Label.set_width_chars].


extraMenu?

optional extraMenu: number

Defined in: react/src/generated/jsx.ts:3519

A menu model whose contents will be appended to the context menu.


focusable?

optional focusable: boolean

Defined in: react/src/generated/jsx.ts:433

Whether this widget itself will accept the input focus.

Inherited from

WidgetProps.focusable


focusOnClick?

optional focusOnClick: boolean

Defined in: react/src/generated/jsx.ts:431

Whether the widget should grab focus when it is clicked with the mouse.

This property is only relevant for widgets that can take focus.

Inherited from

WidgetProps.focusOnClick


halign?

optional halign: Align

Defined in: react/src/generated/jsx.ts:435

How to distribute horizontal space if widget gets extra space.

Inherited from

WidgetProps.halign


hasDefault?

optional hasDefault: boolean

Defined in: react/src/generated/jsx.ts:437

Whether the widget is the default widget.

Inherited from

WidgetProps.hasDefault


hasFocus?

optional hasFocus: boolean

Defined in: react/src/generated/jsx.ts:439

Whether the widget has the input focus.

Inherited from

WidgetProps.hasFocus


hasTooltip?

optional hasTooltip: boolean

Defined in: react/src/generated/jsx.ts:448

Enables or disables the emission of the [signal@Gtk.Widget::query-tooltip] signal on @widget.

A true value indicates that widget can have a tooltip, in this case the widget will be queried using [signal@Gtk.Widget::query-tooltip] to determine whether it will provide a tooltip or not.

Inherited from

WidgetProps.hasTooltip


heightRequest?

optional heightRequest: number

Defined in: react/src/generated/jsx.ts:454

Overrides for height request of the widget.

If this is -1, the natural request will be used.

Inherited from

WidgetProps.heightRequest


hexpand?

optional hexpand: boolean

Defined in: react/src/generated/jsx.ts:456

Whether to expand horizontally.

Inherited from

WidgetProps.hexpand


hexpandSet?

optional hexpandSet: boolean

Defined in: react/src/generated/jsx.ts:458

Whether to use the hexpand property.

Inherited from

WidgetProps.hexpandSet


justify?

optional justify: Justification

Defined in: react/src/generated/jsx.ts:3526

The alignment of the lines in the text of the label, relative to each other.

This does not affect the alignment of the label within its allocation. See [property@Gtk.Label:xalign] for that.


label?

optional label: string

Defined in: react/src/generated/jsx.ts:3541

The contents of the label.

If the string contains Pango markup (see [func@Pango.parse_markup]), you will have to set the [property@Gtk.Label:use-markup] property to true in order for the label to display the markup attributes. See also [method@Gtk.Label.set_markup] for a convenience function that sets both this property and the [property@Gtk.Label:use-markup] property at the same time.

If the string contains underlines acting as mnemonics, you will have to set the [property@Gtk.Label:use-underline] property to true in order for the label to display them.


layoutManager?

optional layoutManager: LayoutManager

Defined in: react/src/generated/jsx.ts:466

The [class@Gtk.LayoutManager] instance to use to compute the preferred size of the widget, and allocate its children.

This property is meant to be set by widget implementations, typically in their instance init function.

Inherited from

WidgetProps.layoutManager


limitEvents?

optional limitEvents: boolean

Defined in: react/src/generated/jsx.ts:475

Makes this widget act like a modal dialog, with respect to event delivery.

Global event controllers will not handle events with targets inside the widget, unless they are set up to ignore propagation limits. See [method@Gtk.EventController.set_propagation_limit].

Inherited from

WidgetProps.limitEvents


lines?

optional lines: number

Defined in: react/src/generated/jsx.ts:3559

The number of lines to which an ellipsized, wrapping label should display before it gets ellipsized. This both prevents the label from ellipsizing before this many lines are displayed, and limits the height request of the label to this many lines.

::: warning Setting this property has unintuitive and unfortunate consequences for the minimum width of the label. Specifically, if the height of the label is such that it fits a smaller number of lines than the value of this property, the label can not be ellipsized at all, which means it must be wide enough to fit all the text fully.

This property has no effect if the label is not wrapping or ellipsized.

Set this property to -1 if you don't want to limit the number of lines.


marginBottom?

optional marginBottom: number

Defined in: react/src/generated/jsx.ts:483

Margin on bottom side of widget.

This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from [method@Gtk.Widget.set_size_request] for example.

Inherited from

WidgetProps.marginBottom


marginEnd?

optional marginEnd: number

Defined in: react/src/generated/jsx.ts:494

Margin on end of widget, horizontally.

This property supports left-to-right and right-to-left text directions.

This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from [method@Gtk.Widget.set_size_request] for example.

Inherited from

WidgetProps.marginEnd


marginStart?

optional marginStart: number

Defined in: react/src/generated/jsx.ts:505

Margin on start of widget, horizontally.

This property supports left-to-right and right-to-left text directions.

This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from [method@Gtk.Widget.set_size_request] for example.

Inherited from

WidgetProps.marginStart


marginTop?

optional marginTop: number

Defined in: react/src/generated/jsx.ts:513

Margin on top side of widget.

This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from [method@Gtk.Widget.set_size_request] for example.

Inherited from

WidgetProps.marginTop


maxWidthChars?

optional maxWidthChars: number

Defined in: react/src/generated/jsx.ts:3569

The desired maximum width of the label, in characters.

If this property is set to -1, the width will be calculated automatically.

See the section on text layout for details of how [property@Gtk.Label:width-chars] and [property@Gtk.Label:max-width-chars] determine the width of ellipsized and wrapped labels.


mnemonicKeyval?

optional mnemonicKeyval: number

Defined in: react/src/generated/jsx.ts:3571

The mnemonic accelerator key for the label.


name?

optional name: string

Defined in: react/src/generated/jsx.ts:515

The name of the widget.

Inherited from

WidgetProps.name


naturalWrapMode?

optional naturalWrapMode: NaturalWrapMode

Defined in: react/src/generated/jsx.ts:3581

Select the line wrapping for the natural size request.

This only affects the natural size requested. For the actual wrapping used, see the [property@Gtk.Label:wrap-mode] property.

The default is [enum@Gtk.NaturalWrapMode.inherit], which inherits the behavior of the [property@Gtk.Label:wrap-mode] property.


optional onActivateCurrentLink: (self) => void

Defined in: react/src/generated/jsx.ts:3654

Gets emitted when the user activates a link in the label.

The ::activate-current-link is a keybinding signal.

Applications may also emit the signal with g_signal_emit_by_name() if they need to control activation of URIs programmatically.

The default bindings for this signal are all forms of the Enter key.

Parameters

ParameterType
selfLabel

Returns

void


optional onActivateLink: (self, uri) => boolean

Defined in: react/src/generated/jsx.ts:3661

Gets emitted to activate a URI.

Applications may connect to it to override the default behaviour, which is to call [method@Gtk.FileLauncher.launch].

Parameters

ParameterType
selfLabel
uristring

Returns

boolean


onCopyClipboard()?

optional onCopyClipboard: (self) => void

Defined in: react/src/generated/jsx.ts:3669

Gets emitted to copy the selection to the clipboard.

The ::copy-clipboard signal is a keybinding signal.

The default binding for this signal is Ctrl+c.

Parameters

ParameterType
selfLabel

Returns

void


onDestroy()?

optional onDestroy: (self) => void

Defined in: react/src/generated/jsx.ts:593

Signals that all holders of a reference to the widget should release the reference that they hold.

May result in finalization of the widget if all references are released.

This signal is not suitable for saving widget state.

Parameters

ParameterType
selfWidget

Returns

void

Inherited from

WidgetProps.onDestroy


onDirectionChanged()?

optional onDirectionChanged: (self, previousDirection) => void

Defined in: react/src/generated/jsx.ts:595

Emitted when the text direction of a widget changes.

Parameters

ParameterType
selfWidget
previousDirectionTextDirection

Returns

void

Inherited from

WidgetProps.onDirectionChanged


onHide()?

optional onHide: (self) => void

Defined in: react/src/generated/jsx.ts:600

Emitted when widget is hidden.

Parameters

ParameterType
selfWidget

Returns

void

Inherited from

WidgetProps.onHide


onKeynavFailed()?

optional onKeynavFailed: (self, direction) => boolean

Defined in: react/src/generated/jsx.ts:606

Emitted if keyboard navigation fails.

See [method@Gtk.Widget.keynav_failed] for details.

Parameters

ParameterType
selfWidget
directionDirectionType

Returns

boolean

Inherited from

WidgetProps.onKeynavFailed


onMap()?

optional onMap: (self) => void

Defined in: react/src/generated/jsx.ts:618

Emitted when widget is going to be mapped.

A widget is mapped when the widget is visible (which is controlled with [property@Gtk.Widget:visible]) and all its parents up to the toplevel widget are also visible.

The ::map signal can be used to determine whether a widget will be drawn, for instance it can resume an animation that was stopped during the emission of [signal@Gtk.Widget::unmap].

Parameters

ParameterType
selfWidget

Returns

void

Inherited from

WidgetProps.onMap


onMnemonicActivate()?

optional onMnemonicActivate: (self, groupCycling) => boolean

Defined in: react/src/generated/jsx.ts:624

Emitted when a widget is activated via a mnemonic.

The default handler for this signal activates widget if group_cycling is false, or just makes widget grab focus if group_cycling is true.

Parameters

ParameterType
selfWidget
groupCyclingboolean

Returns

boolean

Inherited from

WidgetProps.onMnemonicActivate


onMoveCursor()?

optional onMoveCursor: (self, step, count, extendSelection) => void

Defined in: react/src/generated/jsx.ts:3691

Gets emitted when the user initiates a cursor movement.

The ::move-cursor signal is a keybinding signal. If the cursor is not visible in @entry, this signal causes the viewport to be moved instead.

Applications should not connect to it, but may emit it with [func@GObject.signal_emit_by_name] if they need to control the cursor programmatically.

The default bindings for this signal come in two variants, the variant with the Shift modifier extends the selection, the variant without the Shift modifier does not. There are too many key combinations to list them all here.

  • , , , move by individual characters/lines
  • Ctrl+, etc. move by words/paragraphs
  • Home and End move to the ends of the buffer

Parameters

ParameterType
selfLabel
stepMovementStep
countnumber
extendSelectionboolean

Returns

void


onMoveFocus()?

optional onMoveFocus: (self, direction) => void

Defined in: react/src/generated/jsx.ts:633

Emitted when the focus is moved.

The ::move-focus signal is a keybinding signal.

The default bindings for this signal are Tab to move forward, and Shift+Tab to move backward.

Parameters

ParameterType
selfWidget
directionDirectionType

Returns

void

Inherited from

WidgetProps.onMoveFocus


onQueryTooltip()?

optional onQueryTooltip: (self, x, y, keyboardMode, tooltip) => boolean

Defined in: react/src/generated/jsx.ts:648

Emitted when the widget’s tooltip is about to be shown.

This happens when the [property@Gtk.Widget:has-tooltip] property is true and the hover timeout has expired with the cursor hovering above @widget; or emitted when widget got focus in keyboard mode.

Using the given coordinates, the signal handler should determine whether a tooltip should be shown for @widget. If this is the case true should be returned, false otherwise. Note that if keyboard_mode is true, the values of x and y are undefined and should not be used.

The signal handler is free to manipulate tooltip with the therefore destined function calls.

Parameters

ParameterType
selfWidget
xnumber
ynumber
keyboardModeboolean
tooltipTooltip

Returns

boolean

Inherited from

WidgetProps.onQueryTooltip


onRealize()?

optional onRealize: (self) => void

Defined in: react/src/generated/jsx.ts:661

Emitted when widget is associated with a GdkSurface.

This means that [method@Gtk.Widget.realize] has been called or the widget has been mapped (that is, it is going to be drawn).

Parameters

ParameterType
selfWidget

Returns

void

Inherited from

WidgetProps.onRealize


onShow()?

optional onShow: (self) => void

Defined in: react/src/generated/jsx.ts:663

Emitted when widget is shown.

Parameters

ParameterType
selfWidget

Returns

void

Inherited from

WidgetProps.onShow


onStateFlagsChanged()?

optional onStateFlagsChanged: (self, flags) => void

Defined in: react/src/generated/jsx.ts:669

Emitted when the widget state changes.

See [method@Gtk.Widget.get_state_flags].

Parameters

ParameterType
selfWidget
flagsStateFlags

Returns

void

Inherited from

WidgetProps.onStateFlagsChanged


onUnmap()?

optional onUnmap: (self) => void

Defined in: react/src/generated/jsx.ts:679

Emitted when widget is going to be unmapped.

A widget is unmapped when either it or any of its parents up to the toplevel widget have been set as hidden.

As ::unmap indicates that a widget will not be shown any longer, it can be used to, for example, stop an animation on the widget.

Parameters

ParameterType
selfWidget

Returns

void

Inherited from

WidgetProps.onUnmap


onUnrealize()?

optional onUnrealize: (self) => void

Defined in: react/src/generated/jsx.ts:686

Emitted when the GdkSurface associated with widget is destroyed.

This means that [method@Gtk.Widget.unrealize] has been called or the widget has been unmapped (that is, it is going to be hidden).

Parameters

ParameterType
selfWidget

Returns

void

Inherited from

WidgetProps.onUnrealize


opacity?

optional opacity: number

Defined in: react/src/generated/jsx.ts:517

The requested opacity of the widget.

Inherited from

WidgetProps.opacity


overflow?

optional overflow: Overflow

Defined in: react/src/generated/jsx.ts:524

How content outside the widget's content area is treated.

This property is meant to be set by widget implementations, typically in their instance init function.

Inherited from

WidgetProps.overflow


parent?

optional parent: Widget

Defined in: react/src/generated/jsx.ts:526

The parent widget of this widget.

Inherited from

WidgetProps.parent


receivesDefault?

optional receivesDefault: boolean

Defined in: react/src/generated/jsx.ts:528

Whether the widget will receive the default action when it is focused.

Inherited from

WidgetProps.receivesDefault


ref?

optional ref: Ref<Label>

Defined in: react/src/generated/jsx.ts:3698


root?

optional root: Root

Defined in: react/src/generated/jsx.ts:534

The GtkRoot widget of the widget tree containing this widget.

This will be NULL if the widget is not contained in a root widget.

Inherited from

WidgetProps.root


scaleFactor?

optional scaleFactor: number

Defined in: react/src/generated/jsx.ts:536

The scale factor of the widget.

Inherited from

WidgetProps.scaleFactor


selectable?

optional selectable: boolean

Defined in: react/src/generated/jsx.ts:3583

Whether the label text can be selected with the mouse.


sensitive?

optional sensitive: boolean

Defined in: react/src/generated/jsx.ts:538

Whether the widget responds to input.

Inherited from

WidgetProps.sensitive


singleLineMode?

optional singleLineMode: boolean

Defined in: react/src/generated/jsx.ts:3592

Whether the label is in single line mode.

In single line mode, the height of the label does not depend on the actual text, it is always set to ascent + descent of the font. This can be an advantage in situations where resizing the label because of text changes would be distracting, e.g. in a statusbar.


tabs?

optional tabs: number

Defined in: react/src/generated/jsx.ts:3594

Custom tabs for this label.


tooltipMarkup?

optional tooltipMarkup: string

Defined in: react/src/generated/jsx.ts:554

Sets the text of tooltip to be the given string, which is marked up with Pango markup.

Also see [method@Gtk.Tooltip.set_markup].

This is a convenience property which will take care of getting the tooltip shown if the given string is not NULL: [property@Gtk.Widget:has-tooltip] will automatically be set to true and there will be taken care of [signal@Gtk.Widget::query-tooltip] in the default signal handler.

Note that if both [property@Gtk.Widget:tooltip-text] and [property@Gtk.Widget:tooltip-markup] are set, the last one wins.

Inherited from

WidgetProps.tooltipMarkup


tooltipText?

optional tooltipText: string

Defined in: react/src/generated/jsx.ts:569

Sets the text of tooltip to be the given string.

Also see [method@Gtk.Tooltip.set_text].

This is a convenience property which will take care of getting the tooltip shown if the given string is not NULL: [property@Gtk.Widget:has-tooltip] will automatically be set to true and there will be taken care of [signal@Gtk.Widget::query-tooltip] in the default signal handler.

Note that if both [property@Gtk.Widget:tooltip-text] and [property@Gtk.Widget:tooltip-markup] are set, the last one wins.

Inherited from

WidgetProps.tooltipText


useMarkup?

optional useMarkup: boolean

Defined in: react/src/generated/jsx.ts:3600

True if the text of the label includes Pango markup.

See [func@Pango.parse_markup].


useUnderline?

optional useUnderline: boolean

Defined in: react/src/generated/jsx.ts:3605

True if the text of the label indicates a mnemonic with an _ before the mnemonic character.


valign?

optional valign: Align

Defined in: react/src/generated/jsx.ts:571

How to distribute vertical space if widget gets extra space.

Inherited from

WidgetProps.valign


vexpand?

optional vexpand: boolean

Defined in: react/src/generated/jsx.ts:573

Whether to expand vertically.

Inherited from

WidgetProps.vexpand


vexpandSet?

optional vexpandSet: boolean

Defined in: react/src/generated/jsx.ts:575

Whether to use the vexpand property.

Inherited from

WidgetProps.vexpandSet


visible?

optional visible: boolean

Defined in: react/src/generated/jsx.ts:577

Whether the widget is visible.

Inherited from

WidgetProps.visible


widthChars?

optional widthChars: number

Defined in: react/src/generated/jsx.ts:3615

The desired width of the label, in characters.

If this property is set to -1, the width will be calculated automatically.

See the section on text layout for details of how [property@Gtk.Label:width-chars] and [property@Gtk.Label:max-width-chars] determine the width of ellipsized and wrapped labels.


widthRequest?

optional widthRequest: number

Defined in: react/src/generated/jsx.ts:583

Overrides for width request of the widget.

If this is -1, the natural request will be used.

Inherited from

WidgetProps.widthRequest


wrap?

optional wrap: boolean

Defined in: react/src/generated/jsx.ts:3617

True if the label text will wrap if it gets too wide.


wrapMode?

optional wrapMode: number

Defined in: react/src/generated/jsx.ts:3628

Controls how the line wrapping is done.

This only affects the formatting if line wrapping is on (see the [property@Gtk.Label:wrap] property). The default is [enum@Pango.WrapMode.word], which means wrap on word boundaries.

For sizing behavior, also consider the [property@Gtk.Label:natural-wrap-mode] property.


xalign?

optional xalign: number

Defined in: react/src/generated/jsx.ts:3635

The horizontal alignment of the label text inside its size allocation.

Compare this to [property@Gtk.Widget:halign], which determines how the labels size allocation is positioned in the space available for the label.


yalign?

optional yalign: number

Defined in: react/src/generated/jsx.ts:3642

The vertical alignment of the label text inside its size allocation.

Compare this to [property@Gtk.Widget:valign], which determines how the labels size allocation is positioned in the space available for the label.