Class TextStyle
Represents the appearance of the text.
Inherited Members
Namespace: Syncfusion.Blazor.Diagram
Assembly: Syncfusion.Blazor.dll
Syntax
public class TextStyle : ShapeStyle, IDiagramObject, ICloneable
Constructors
TextStyle()
Initializes a new instance of the TextStyle.
Declaration
public TextStyle()
TextStyle(TextStyle)
Declaration
public TextStyle(TextStyle src)
Parameters
Type | Name | Description |
---|---|---|
TextStyle | src | TextShapeStyle. |
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 | true, bold style applied for text; Oterwise false. |
Examples
Node node = new Node()
{
// Initialize annotation collection
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 | 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 | The default font family is Arial. |
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 a text.
Declaration
public double FontSize { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The default font size is 12px |
Examples
Node node = new Node()
{
Annotations = new DiagramObjectCollection<ShapeAnnotation>()
{
new ShapeAnnotation
{
Content = "Node",
ID = "Annotation",
Style= new TextStyle()
{
FontSize = 20,
}
}
},
};
Italic
Enables or disables the italic style of a text. By default, it is false.
Declaration
public bool Italic { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true, italic style applied for text; Oterwise false. |
Examples
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 the center.
Declaration
public TextAlign TextAlign { get; set; }
Property Value
Type | Description |
---|---|
TextAlign | The default value will be Center |
Remarks
The following options are used to define the TextAlign of the annotation. |
1. Left - Sets the alignment of the text to the left in the text block.. |
2. Right - Sets the alignment of the text to the right in the text block. |
3. Right - Aligns the diagram element at the right of the node. |
4. Center - Sets the alignment of the text at the center of the text block. |
5. Justify - Sets the alignment of the text in respective to left and right margins. |
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. The default value is none.
Declaration
public TextDecoration TextDecoration { get; set; }
Property Value
Type | Description |
---|---|
TextDecoration | The default value will be None |
Remarks
The following options are used to define the TextAlign of the annotation. |
1. None - Represents the default appearance of a text. |
2. Overline - Draws a horizontal line above the text. |
3. Underline - Draws a horizontal line under the text. |
4. 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
Specifies a value that indicates whether to render ellipses (...) to indicate text overflow. By default, it is wrapped.
Declaration
public TextOverflow TextOverflow { get; set; }
Property Value
Type | Description |
---|---|
TextOverflow | The default value will be Wrap |
Remarks
The following options are used to define the TextOverflow of the annotation. |
1. Wrap - Wraps the text to the next line, when it exceeds its bounds. |
2. Ellipsis - Ellipsis hides the text if the text size exceeds the boundary. |
3. Clip - The text is restricted to the node/connector boundary and the text will not be overflown. |
Examples
Node node = new Node()
{
Annotations = new DiagramObjectCollection<ShapeAnnotation>()
{
new ShapeAnnotation
{
Content = "Node",
ID = "Annotation",
Style= new TextStyle()
{
TextOverflow = TextOverflow.Wrap,
}
}
},
};
TextWrapping
Gets or sets a TextWrap to wrap the text. By default, it is WrapWithOverflow.
Declaration
public TextWrap TextWrapping { get; set; }
Property Value
Type | Description |
---|---|
TextWrap | The default value will be WrapWithOverflow |
Remarks
The following options are used to define the TextWrap of the annotation. |
1. WrapWithOverflow - Text-wrapping occurs when the text overflows beyond the available node width. However, the text may overflow beyond the node width in case of a very long word. |
2. Wrap - The text will be wrapped within the boundary. |
3. NoWrap - The text will not be wrapped. If a lengthy text exists, the boundary will not be a limit. |
Examples
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 TextStyle that is a copy of the current style.
Declaration
public override object Clone()
Returns
Type | Description |
---|---|
System.Object | TextShapeStyle |