AvatarOptions Class
Provides options used to generate an avatar SVG.
public class AvatarOptionsConstructors
| Name | Description |
|---|---|
| AvatarOptions() | Initializes a new instance of the AvatarOptions class. |
AvatarOptions()
AvatarOptions.csInitializes a new instance of the AvatarOptions class.
public AvatarOptions()Properties
| Name | Description |
|---|---|
| AccessibleLabel | Gets or sets the text announced by assistive technologies. If null, the bigram is used. |
| Bigram | Gets or sets the explicit bigram to render. If null, the bigram is extracted from the name. |
| IsDecorative | Gets or sets a value indicating whether the avatar is purely decorative and should be hidden from assistive technologies. The default is false. |
| Palette | Gets the mutable list of colors used for rendering. |
| Shape | Gets or sets the shape of the avatar. |
| Size | Gets or sets the size of the generated SVG in pixels. |
AccessibleLabel
AvatarOptions.csGets or sets the text announced by assistive technologies. If null, the bigram is used.
public string? AccessibleLabel { get; set; }Property value
Remarks
Set this to the full name so the avatar announces as "John Doe" rather than "JD". Characters that are invalid in an XML document are removed, so an untrusted display name can be passed directly. Ignored when AvatarOptions.IsDecorative is true.
Bigram
AvatarOptions.csGets or sets the explicit bigram to render. If null, the bigram is extracted from the name.
public string? Bigram { get; set; }Property value
Remarks
The value must contain 1 or 2 grapheme clusters, no whitespace, and no character that is invalid in an XML document. It does not affect the selected color, which always derives from the name.
IsDecorative
AvatarOptions.csGets or sets a value indicating whether the avatar is purely decorative and should be hidden from assistive technologies. The default is false.
public bool IsDecorative { get; set; }Property value
Remarks
Set this when the avatar sits next to the name it represents, so the name is not announced twice. The generated element uses aria-hidden instead of role and aria-label.
Palette
AvatarOptions.csGets the mutable list of colors used for rendering.
public IList<AvatarColorPair> Palette { get; }Property value
Remarks
The color is selected with hash(name) % Palette.Count, so the number of entries and their order are part of the name-to-color mapping: adding or removing one entry re-colors nearly every name. This instance is not thread-safe; do not mutate it while AvatarGenerator.CreateSvg is running.
Shape
AvatarOptions.csSize
AvatarOptions.csConstants
| Name | Description |
|---|---|
| DefaultSize | The default avatar size (64x64). |
DefaultSize
The default avatar size (64x64).
public const int DefaultSize = 64