menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class TextStyle - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class TextStyle

    Represents the appearance of the text in a diagram, providing various styling options such as boldness, color, font, and more.

    Inheritance
    System.Object
    DiagramObject
    ShapeStyle
    TextStyle
    Implements
    IDiagramObject
    System.ICloneable
    Inherited Members
    DiagramObject.GetParent()
    DiagramObject.OnPropertyChanged(String, Object, Object, IDiagramObject)
    ShapeStyle.Fill
    ShapeStyle.Gradient
    ShapeStyle.Opacity
    ShapeStyle.StrokeColor
    ShapeStyle.StrokeDashArray
    ShapeStyle.StrokeWidth
    Namespace: Syncfusion.Blazor.Diagram
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class TextStyle : ShapeStyle, IDiagramObject, ICloneable
    Remarks

    Use TextStyle to customize the appearance of the text for diagram nodes or connectors.

    This class inherits from ShapeStyle, adding text-specific styling properties.

    Constructors

    TextStyle()

    Initializes a new instance of the TextStyle.

    Declaration
    public TextStyle()

    TextStyle(TextStyle)

    Creates a new instance of the TextStyle from the given TextStyle.

    Declaration
    public TextStyle(TextStyle src)
    Parameters
    Type Name Description
    TextStyle src

    The source TextStyle to clone properties from.

    Properties

    Bold

    Enables or disables the bold style of a text. By default, it is false.

    Declaration
    public bool Bold { get; set; }
    Property Value
    Type Description
    System.Boolean

    A System.Boolean indicating if the text is bold. The default value is false.

    Examples
    Node node = new Node()
    {
        Annotations = new DiagramObjectCollection<ShapeAnnotation>()
        {
            new ShapeAnnotation
            {
                Content = "Node",
                ID = "Annotation",
                Style = new TextStyle()
                {
                    Bold = true,
                }
            }
        },
    };

    Color

    Gets or sets the font color of a text.

    Declaration
    public string Color { get; set; }
    Property Value
    Type Description
    System.String

    A System.String representing the font color. The default font color is "black".

    Examples
    Node node = new Node()
    {
        Annotations = new DiagramObjectCollection<ShapeAnnotation>()
        {
            new ShapeAnnotation
            {
                Content = "Node",
                ID = "Annotation",
                Style = new TextStyle()
                {
                    Color = "red",
                }
            }
        },
    };

    FontFamily

    Gets or sets the font type of a text.

    Declaration
    public string FontFamily { get; set; }
    Property Value
    Type Description
    System.String

    A System.String representing the font family of the text. The default value is "Arial".

    Remarks

    Use this property to specify the font family for text annotations in the diagram.

    Examples
    Node node = new Node()
    {
        Annotations = new DiagramObjectCollection<ShapeAnnotation>()
        {
            new ShapeAnnotation
            {
                Content = "Node",
                ID = "Annotation",
                Style = new TextStyle()
                {
                    FontFamily = "Calibri",
                }
            }
        },
    };

    FontSize

    Gets or sets the font size of the text within the node annotations.

    Declaration
    public double FontSize { get; set; }
    Property Value
    Type Description
    System.Double

    A System.Double representing the font size in pixels. The default value is 12.0 pixels.

    Remarks

    If not specified, or set to System.Double.NaN, it defaults to 12.0 pixels.

    Changing the font size will affect the appearance of text and might require layout adjustments.

    Examples
    Node node = new Node()
    {
        Annotations = new DiagramObjectCollection<ShapeAnnotation>() 
        { 
            new ShapeAnnotation 
            { 
                Content = "Node",
                ID = "Annotation",
                Style = new TextStyle()
                {
                   FontSize = 20,
                }
            }
        },
    };

    Italic

    Gets or sets a value indicating whether the text is displayed in an italic style.

    Declaration
    public bool Italic { get; set; }
    Property Value
    Type Description
    System.Boolean

    A System.Boolean indicating italic style. The default value is false.

    Remarks

    Change this property to true to apply an italic style to the text.

    Examples

    Demonstrates how to apply italic style to a node annotation.

    Node node = new Node()
    {
        Annotations = new DiagramObjectCollection<ShapeAnnotation>() 
        { 
            new ShapeAnnotation 
            { 
                Content = "Node",
                ID = "Annotation",
                Style= new TextStyle()
                {
                    Italic = true,
                }
            }
        },
    };

    TextAlign

    Gets or sets the alignment of the text inside the node bounds. By default, it is aligned at Center.

    Declaration
    public TextAlign TextAlign { get; set; }
    Property Value
    Type Description
    TextAlign

    A TextAlign specifying how the text is aligned within the node bounds. The default value is Center.

    Remarks

    The following options can be used to define the TextAlign of the annotation:

    • Left - Aligns the text to the left within the text block.
    • Right - Aligns the text to the right within the text block.
    • Center - Centers the text within the text block.
    • Justify - Justifies the text within the text block.
    Examples
    Node node = new Node()
    {
        Annotations = new DiagramObjectCollection<ShapeAnnotation>() 
        { 
            new ShapeAnnotation 
            { 
                Content = "Node",
                ID = "Annotation",
                Style = new TextStyle()
                {
                    TextAlign = TextAlign.Center,
                }
            }
        },
    };

    TextDecoration

    Gets or sets the TextDecoration which contains the effects that should be applied to the text of a TextBlock.

    Declaration
    public TextDecoration TextDecoration { get; set; }
    Property Value
    Type Description
    TextDecoration

    A TextDecoration representing the decoration options for text. The default value is None.

    Remarks

    The following options are available for the TextDecoration:

    • None - Represents the default appearance of a text.
    • Overline - Draws a horizontal line above the text.
    • Underline - Draws a horizontal line under the text.
    • LineThrough - Draws a horizontal line through the text of a node or a connector.
    Examples
    Node node = new Node()
    {
        Annotations = new DiagramObjectCollection<ShapeAnnotation>() 
        { 
            new ShapeAnnotation 
            { 
                Content = "Node",
                ID = "Annotation",
                Style= new TextStyle()
                {
                    TextDecoration = TextDecoration.None,
                }
            }
        },
    };

    TextOverflow

    Gets or sets the value that specifies how text overflow is handled for the annotations. The text can be wrapped, displayed as an ellipsis, or clipped.

    Declaration
    public TextOverflow TextOverflow { get; set; }
    Property Value
    Type Description
    TextOverflow

    A TextOverflow enum value that indicates the text overflow behavior. The default value is Wrap.

    Remarks

    The following options are used to specify the text overflow of the annotation:

    • Wrap - Wraps the text to the next line when it exceeds its bounds.
    • Ellipsis - Displays an ellipsis if the text size exceeds the boundary.
    • Clip - Restricts the text within the node or connector boundary, preventing overflow.
    Examples

    The following example shows how to set the text overflow style for an annotation in a diagram node.

    Node node = new Node()
    {
        Annotations = new DiagramObjectCollection<ShapeAnnotation>() 
        { 
            new ShapeAnnotation 
            { 
                Content = "Node",
                ID = "Annotation",
                Style = new TextStyle()
                {
                    TextOverflow = TextOverflow.Wrap,
                }
            }
        },
    };

    TextWrapping

    Gets or sets the TextWrap option to wrap the text. By default, it is WrapWithOverflow.

    Declaration
    public TextWrap TextWrapping { get; set; }
    Property Value
    Type Description
    TextWrap

    A TextWrap value representing the text-wrapping behavior. The default value is WrapWithOverflow.

    Remarks

    The following options are available for TextWrap:

    • WrapWithOverflow - Text-wrapping occurs when the text overflows beyond the available node width.
    • Wrap - The text will be wrapped within the boundary.
    • NoWrap - The text will not be wrapped. If a lengthy text exists, the boundary will not be a limit.
    Examples

    Below is an example showing how to set the TextWrapping property:

    Node node = new Node()
    {
        Annotations = new DiagramObjectCollection<ShapeAnnotation>() 
        { 
            new ShapeAnnotation 
            { 
                Content = "Node",
                ID = "Annotation",
                Style = new TextStyle()
                {
                    TextWrapping = TextWrap.NoWrap,
                }
            }
        },
    };

    Methods

    Clone()

    Creates a new instance of the TextStyle class that is a copy of the current style.

    Declaration
    public override object Clone()
    Returns
    Type Description
    System.Object

    A new TextStyle object that is a clone of this instance.

    Overrides
    ShapeStyle.Clone()

    Implements

    IDiagramObject
    System.ICloneable
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved