DeepWorks Studios Blazor Component Library

Demo user Administrator ยท Blazor Server Library 20261206222504-6e8ff32.dirty

DwsTypography

This page demonstrates the usage of the DwsTypography component with various typography types.

For rendering Markdown content, use DwsMarkdownViewer instead - DwsTypography is for styled plain/HTML text.

API Reference

Typography Examples

Every Typography preset, from Heading1 to Overline.

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

This is a paragraph. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

This is a blockquote. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
This is inline code.
This is preformatted text.
Line 1
    Line 2 (indented)
Line 3
This is a caption. This is a subtitle. This is an overline.
Show Code
Typography.razor

<DwsTypography Name='TypographyDemo_Heading1' Typography='DwsTypographyType.Heading1'>Heading 1</DwsTypography>
<DwsTypography Name='TypographyDemo_Heading2' Typography='DwsTypographyType.Heading2'>Heading 2</DwsTypography>
<DwsTypography Name='TypographyDemo_Heading3' Typography='DwsTypographyType.Heading3'>Heading 3</DwsTypography>
<DwsTypography Name='TypographyDemo_Heading4' Typography='DwsTypographyType.Heading4'>Heading 4</DwsTypography>
<DwsTypography Name='TypographyDemo_Heading5' Typography='DwsTypographyType.Heading5'>Heading 5</DwsTypography>
<DwsTypography Name='TypographyDemo_Heading6' Typography='DwsTypographyType.Heading6'>Heading 6</DwsTypography>
<DwsTypography Name='TypographyDemo_Paragraph' Typography='DwsTypographyType.Paragraph'>This is a paragraph. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</DwsTypography>
<DwsTypography Name='TypographyDemo_Blockquote' Typography='DwsTypographyType.Blockquote'>This is a blockquote. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</DwsTypography>
<DwsTypography Name='TypographyDemo_Code' Typography='DwsTypographyType.Code'>This is inline code.</DwsTypography>
@* A string, not inline lines: Razor indentation would become part of the <pre> text. *@
<DwsTypography Name='TypographyDemo_Preformatted' Typography='DwsTypographyType.Preformatted'>@("This is preformatted text.\nLine 1\n    Line 2 (indented)\nLine 3")</DwsTypography>
<DwsTypography Name='TypographyDemo_Caption' Typography='DwsTypographyType.Caption'>This is a caption.</DwsTypography>
<DwsTypography Name='TypographyDemo_Subtitle' Typography='DwsTypographyType.Subtitle'>This is a subtitle.</DwsTypography>
<DwsTypography Name='TypographyDemo_Overline' Typography='DwsTypographyType.Overline'>This is an overline.</DwsTypography>
Typography.razor.cs
// DwsTypography is primarily configured in Razor markup.
// Use parameters like Typography, HtmlTag, HorizontalAlignment,
// VerticalAlignment and Inline for behavior and styling.

HorizontalAlignment Examples

HorizontalAlignment aligns the text left, centered or right.

This paragraph is left-aligned.

This paragraph is center-aligned.

This paragraph is right-aligned.

Show Code
Typography.razor

<DwsTypography Name='TypographyDemo_Align_Left' Typography='DwsTypographyType.Paragraph' HorizontalAlignment='DwsHorizontalAlignment.Left'>This paragraph is left-aligned.</DwsTypography>
<DwsTypography Name='TypographyDemo_Align_Center' Typography='DwsTypographyType.Paragraph' HorizontalAlignment='DwsHorizontalAlignment.Center'>This paragraph is center-aligned.</DwsTypography>
<DwsTypography Name='TypographyDemo_Align_Right' Typography='DwsTypographyType.Paragraph' HorizontalAlignment='DwsHorizontalAlignment.Right'>This paragraph is right-aligned.</DwsTypography>
Typography.razor.cs
// DwsTypography is primarily configured in Razor markup.
// Use parameters like Typography, HtmlTag, HorizontalAlignment,
// VerticalAlignment and Inline for behavior and styling.

VerticalAlignment Examples

VerticalAlignment places the text at the top, middle or bottom of a taller container.

This paragraph is top-aligned.

This paragraph is center-aligned.

This paragraph is bottom-aligned.

Show Code
Typography.razor

<DwsTypography Name='TypographyDemo_VAlign_Top' Typography='DwsTypographyType.Paragraph' VerticalAlignment='DwsVerticalAlignment.Top'>This paragraph is top-aligned.</DwsTypography>
<DwsTypography Name='TypographyDemo_VAlign_Center' Typography='DwsTypographyType.Paragraph' VerticalAlignment='DwsVerticalAlignment.Center'>This paragraph is center-aligned.</DwsTypography>
<DwsTypography Name='TypographyDemo_VAlign_Bottom' Typography='DwsTypographyType.Paragraph' VerticalAlignment='DwsVerticalAlignment.Bottom'>This paragraph is bottom-aligned.</DwsTypography>
Typography.razor.cs
// DwsTypography is primarily configured in Razor markup.
// Use parameters like Typography, HtmlTag, HorizontalAlignment,
// VerticalAlignment and Inline for behavior and styling.

Inline Text Example

Inline renders a typography inside running text.

This is a paragraph with inline code and inline caption.

Show Code
Typography.razor

<DwsTypography Name='TypographyDemo_InlineParent' Typography='DwsTypographyType.Paragraph'>
    This is a paragraph with <DwsTypography Name='TypographyDemo_InlineCode' Typography='DwsTypographyType.Code' Inline='true'>inline code</DwsTypography> and <DwsTypography Name='TypographyDemo_InlineCaption' Typography='DwsTypographyType.Caption' Inline='true'>inline caption</DwsTypography>.
</DwsTypography>
Typography.razor.cs
// DwsTypography is primarily configured in Razor markup.
// Use parameters like Typography, HtmlTag, HorizontalAlignment,
// VerticalAlignment and Inline for behavior and styling.

Custom HTML Tag Example

HtmlTag picks the rendered element independently of the look.

This paragraph is rendered as a div element.

This heading 1 is rendered as an h2 element.

Show Code
Typography.razor

<DwsTypography Name='TypographyDemo_HtmlTag_Div' Typography='DwsTypographyType.Paragraph' HtmlTag='div'>This paragraph is rendered as a div element.</DwsTypography>
<DwsTypography Name='TypographyDemo_HtmlTag_H2' Typography='DwsTypographyType.Heading1' HtmlTag='h2'>This heading 1 is rendered as an h2 element.</DwsTypography>
Typography.razor.cs
// DwsTypography is primarily configured in Razor markup.
// Use parameters like Typography, HtmlTag, HorizontalAlignment,
// VerticalAlignment and Inline for behavior and styling.

Theme Color

Color applies a theme color to the text.

This paragraph uses the Primary theme color.

This paragraph uses the Error theme color.

Show Code
Typography.razor

<DwsTypography Name='TypographyDemo_ColorPrimary' Typography='DwsTypographyType.Paragraph' Color='DwsColor.Primary'>This paragraph uses the Primary theme color.</DwsTypography>
<DwsTypography Name='TypographyDemo_ColorError' Typography='DwsTypographyType.Paragraph' Color='DwsColor.Error'>This paragraph uses the Error theme color.</DwsTypography>
Typography.razor.cs
// DwsTypography is primarily configured in Razor markup.
// Use parameters like Typography, HtmlTag, HorizontalAlignment,
// VerticalAlignment and Inline for behavior and styling.

Font Size

FontSize takes any CSS font-size value: px, em or %.

This paragraph has a custom 28px font size.

This paragraph has a custom 1.5em font size.

This paragraph has a custom 150% font size.

Show Code
Typography.razor

<DwsTypography Name='TypographyDemo_FontSizePx' Typography='DwsTypographyType.Paragraph' FontSize='28px'>This paragraph has a custom 28px font size.</DwsTypography>
<DwsTypography Name='TypographyDemo_FontSizeEm' Typography='DwsTypographyType.Paragraph' FontSize='1.5em'>This paragraph has a custom 1.5em font size.</DwsTypography>
<DwsTypography Name='TypographyDemo_FontSizePercent' Typography='DwsTypographyType.Paragraph' FontSize='150%'>This paragraph has a custom 150% font size.</DwsTypography>
Typography.razor.cs
// DwsTypography is primarily configured in Razor markup.
// Use parameters like Typography, HtmlTag, HorizontalAlignment,
// VerticalAlignment and Inline for behavior and styling.

Text Transform

TextTransform changes the case of the text without changing the text itself.

This paragraph is uppercased.

Show Code
Typography.razor

<DwsTypography Name='TypographyDemo_TextTransformUppercase' Typography='DwsTypographyType.Paragraph' TextTransform='DwsTextTransform.Uppercase'>This paragraph is uppercased.</DwsTypography>
Typography.razor.cs
// DwsTypography is primarily configured in Razor markup.
// Use parameters like Typography, HtmlTag, HorizontalAlignment,
// VerticalAlignment and Inline for behavior and styling.

Line Height and Letter Spacing

LineHeight and LetterSpacing open up the text.

This paragraph has extra line height and letter spacing.

Show Code
Typography.razor

<DwsTypography Name='TypographyDemo_LineHeightLetterSpacing' Typography='DwsTypographyType.Paragraph' LineHeight='2' LetterSpacing='2'>This paragraph has extra line height and letter spacing.</DwsTypography>
Typography.razor.cs
// DwsTypography is primarily configured in Razor markup.
// Use parameters like Typography, HtmlTag, HorizontalAlignment,
// VerticalAlignment and Inline for behavior and styling.

Interface-Description

Name Typ Default Description
Typography DwsTypographyType default Typography style preset. Heading1-4 scale with the viewport like Bootstrap's h1-h4 (full size from 1200px), and every heading breaks a word that is too long for the line instead of widening the page.
HtmlTag string? Typography.GetHtmlTagString() HTML tag used for rendering. Falls back to the tag derived from Typography when unset or invalid. Typography decides the look, this tag the meaning: screen readers and the document outline read headings from the tag alone, so keep h1, h2, ... in order with HtmlTag and choose the look freely.
HorizontalAlignment DwsHorizontalAlignment DwsHorizontalAlignment.None Horizontal text alignment.
VerticalAlignment DwsVerticalAlignment DwsVerticalAlignment.None Vertical text alignment.
Inline bool false Render typography inline.
Color DwsColor DwsColor.Undefined Theme color applied to the text. Undefined keeps the preset's own color.
FontSize string? null Raw CSS font-size value, e.g. "16px", "1.2em", "120%".
LineHeight double? null Unitless CSS line-height multiplier.
LetterSpacing double? null CSS letter-spacing in pixels.
TextTransform DwsTextTransform DwsTextTransform.None Text case transform: Uppercase, Lowercase or Capitalize.
ChildContent RenderFragment default! Typography content.
Name Typ Description
OnClick EventCallback<MouseEventArgs> Raised when the rendered element is clicked.
OnMouseOver EventCallback<MouseEventArgs> Raised when the mouse moves over the rendered element.
Name Typ Default Description
Element ElementReference The associated web component. May be null if accessed before the component is rendered.
ComponentGuid Guid Unique identifier for the component.
TypeString string The name of the component type, obtained from reflection.
Authorized_RegisterEnabled bool false Indicates whether this component is enabled through a permission registry.
Authorized_RegisterSelected bool false Indicates whether this component is selected in permission selection mode.
GetInitializedState bool false Returns whether the component is initialized.
GetRenderModeState DwsRenderMode Returns the current render mode.
GetComponentState DwsComponentStateType Returns the current component state.
GetIsInteractiveState bool false Returns whether the component is interactive.
GetIsPrerenderingState bool false Returns whether the component is prerendering.
GetComponentLoadingState bool false Returns whether the component is loading.
IsFormBusy bool false Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState).
Name Typ Parameters Description
DebugInfo void Logs debug information about the component.
UpdateState void Updates the component's state and triggers StateHasChanged.
UpdateStateAsync Task Asynchronously updates the component's state and triggers StateHasChanged.
Dispose void Disposes the component and releases resources.
FocusAsync ValueTask bool containedInScrollableList Sets focus to the component's element.
Name Typ Default Description
Name string Required unique identifier for the component within its container.
Visible bool true Determines if the component is visible in the UI.
Disabled bool false Disables the form control, ensuring it doesn't participate in form submission.
ComponentNameSpace string The namespace for permission-based access control.
PermissionKey string? null A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins.
Class string Optional CSS class names.
Style string Optional in-line styles.
Tag object An optional user-defined object to store any additional data with the component.
BackReference DwsReference A reference to the enclosing component.
ID string The id of the rendered element (h1-h6, p, span, ...), so a heading can be the target of aria-labelledby or an anchor link.
AdditionalAttributes Dictionary<string, object> Further attributes of the rendered element (aria-*, data-*, lang, dir, ...). They used to be dropped.
IgnorePermissionChecks bool false Bypasses all permission checks for this component.
IgnorePermissionSelection bool false Ignore permission selection mode for this component.
IgnoreFormBusy bool false Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it.
Name Typ Description
OnInitializedCallbackStarted EventCallback Callback when OnInitialized starts.
OnInitializedCallback EventCallback Callback during OnInitialized.
OnInitializedCallbackCompleted EventCallback Callback when OnInitialized completes.
OnInitializedAsyncCallbackStarted EventCallback Callback when OnInitializedAsync starts.
OnInitializedAsyncCallback EventCallback Callback during OnInitializedAsync.
OnInitializedAsyncCallbackCompleted EventCallback Callback when OnInitializedAsync completes.
OnIsComponentLoadingChanged EventCallback<bool> Callback when IsComponentLoading changes.
OnCurrentRenderModeChanged EventCallback<DwsRenderMode> Callback when CurrentRenderMode changes.
OnComponentStateChanged EventCallback<DwsComponentStateType> Callback when ComponentState changes.
An error has occurred. This app may no longer respond until reloaded.