documentationfor yFiles for HTML 2.6

MarkupLabelStyle

A label style that interprets the label's text as markup and renders the label using rich text features.

Inheritance Hierarchy
DefaultLabelStyle
MarkupLabelStyle
Implemented Interfaces

Remarks

This style supports a certain subset of HTML, CSS styling, and additionally some color tags. The supported markup elements are:

  • <span> – A stylable element.
  • <p> – A paragraph element.
  • <pre> – A container for pre-formatted text.
  • <br> – Adds a line break
  • <em> – Italic text
  • <strong> – Bold text
  • <del> – Strikethrough text
  • <u> – Underline text
  • <h1>–<h6> – Heading 1—6
  • <code> – Monospace text
  • <small> – Small font-size
  • <large> – Large font-size
  • <sub> – Subscript text
  • <sup> – Superscript text

Please note that <sub> and <sup> may not be supported by all browsers.

To add line breaks, use the <br> tag. Newline characters in the label text are ignored.

Additionally, HTML color names are supported as tag names, e.g. <red> produces red text:

<red>Red text</red>

Tags can be nested. For example, a span can contain an <em> tag.

<span>Text with <em>italic</em> part.</span>

Tags can be styled with CSS. Please note that this style transforms all elements in the label text into styled SVG <tspan> elements. Therefore, your CSS style has to apply to SVG text. This example shows how to create semi-transparent text using CSS styling.

<span style="opacity: 0.5;">Semi-transparent text</span>

Also, tags can be given CSS classes. All tags already expose classes that can be used to style all occurrences of these elements.

  • <span> – yfiles-label-span
  • <p> – yfiles-label-p
  • <pre> – yfiles-label-pre
  • <em> – yfiles-label-em
  • <strong> – yfiles-label-strong
  • <del> – yfiles-label-del
  • <u> – yfiles-label-u
  • <h1>-<h6> – yfiles-label-h[1-6]
  • <code> – yfiles-label-code
  • <small> – yfiles-label-small
  • <large> – yfiles-label-large
  • <sub> – yfiles-label-sub
  • <sup> – yfiles-label-sup
  • <[colorname]> – yfiles-label-[colorname]

Type Details

yfiles module
view-component
yfiles-umd modules
All view modules
Legacy UMD name
yfiles.styles.MarkupLabelStyle

See Also

This style does not support right-to-left direction.
Please make sure that your CSS or inline styles do not change the font size in any way, since text size changes by external CSS are not considered in the text measuring. To change the overall font size, use the font property.

Constructors

Properties

Methods