TextBlock
A static page with IzzyBlazor's script. No circuit.
Body text. (Named TextBlock because Razor reserves <text> inside code blocks.) Renders a p by default; set As to span, small, strong, label and so on.
Usage
<TextBlock Size="TextSize.Lg" Color="Color.Muted" Wrap="TextWrap.Pretty">...</TextBlock>
<TextBlock As="span" Size="TextSize.Xs" Weight="FontWeight.Semibold" Transform="TextTransform.Uppercase" LetterSpacing="LetterSpacing.Wider">New</TextBlock>Size scale
Use Size to pick a step on the type scale, from Xs to Xl6.
Preview
Code
<Stack Gap="2" Grow>
foreach (var size in Enum.GetValues<TextSize>())
{
<Row Gap="4" Align="Align.Baseline">
<TextBlock As="span" Size="TextSize.Xs" Color="Color.Muted" Width="3.Rem" TabularNums>size</TextBlock>
<TextBlock As="span" Size="size" Truncate>Invoice paid</TextBlock>
</Row>
}
</Stack>Weight, family and decoration
Use Weight, Family, Italic and Decoration to style text without CSS.
Preview
Code
<Stack Gap="4" Grow>
<Row Gap="6" Wrap>
foreach (var weight in Enum.GetValues<FontWeight>())
{
<TextBlock As="span" Weight="weight">weight</TextBlock>
}
</Row>
<Row Gap="6" Wrap>
<TextBlock As="span" Family="FontFamily.Body">Body</TextBlock>
<TextBlock As="span" Family="FontFamily.Heading">Heading</TextBlock>
<TextBlock As="span" Family="FontFamily.Mono">Mono</TextBlock>
<TextBlock As="span" Italic>Italic</TextBlock>
<TextBlock As="span" Decoration="TextDecoration.Underline">Underline</TextBlock>
<TextBlock As="span" Decoration="TextDecoration.LineThrough" Color="Color.Muted">$49 a month</TextBlock>
</Row>
</Stack>Text colors
Use Color with Muted, Subtle and Disabled for less emphasis, and the *Text accents for status text that stays readable.
Preview
Deploy finished in 42 seconds
main · 3f9a2c7 by Ada Lovelace
Started 2 minutes ago
Rollback unavailable
Code
@* Four levels of emphasis, and accent text tuned for 4.5:1 contrast on any surface. *@
<Stack Gap="4" Grow>
<Stack Gap="1">
<TextBlock>Deploy finished in 42 seconds</TextBlock>
<TextBlock Color="Color.Muted">main · 3f9a2c7 by Ada Lovelace</TextBlock>
<TextBlock Color="Color.Subtle">Started 2 minutes ago</TextBlock>
<TextBlock Color="Color.Disabled">Rollback unavailable</TextBlock>
</Stack>
<Row Gap="6" Wrap>
<TextBlock As="span" Color="Color.PrimaryText" Weight="FontWeight.Medium">Beta</TextBlock>
<TextBlock As="span" Color="Color.SuccessText" Weight="FontWeight.Medium">Healthy</TextBlock>
<TextBlock As="span" Color="Color.WarningText" Weight="FontWeight.Medium">Degraded</TextBlock>
<TextBlock As="span" Color="Color.DangerText" Weight="FontWeight.Medium">Payment failed</TextBlock>
<TextBlock As="span" Color="Color.InfoText" Weight="FontWeight.Medium">Scheduled</TextBlock>
</Row>
</Stack>Truncate and line clamp
Use Truncate to keep text on one line, or LineClamp to stop it after a number of lines, ending with an ellipsis.
Preview
Migrate the billing service to the new payments API before the March release
The current integration uses an API version that will be retired at the end of the quarter. Move webhooks first, then charges and refunds, and keep the old endpoint running until every region has switched over.
Code
<Stack Gap="4" MaxWidth="24.Rem" Grow>
<TextBlock Weight="FontWeight.Medium" Truncate>Migrate the billing service to the new payments API before the March release</TextBlock>
<TextBlock LineClamp="2" Color="Color.Muted">
The current integration uses an API version that will be retired at the end of the quarter. Move
webhooks first, then charges and refunds, and keep the old endpoint running until every region
has switched over.
</TextBlock>
</Stack>Tabular numbers
Use TabularNums to give digits equal widths, so numbers line up in columns.
Preview
Default
$1,111.11
$8,808.80
$420.17
TabularNums
$1,111.11
$8,808.80
$420.17
Code
<Row Gap="8">
<Stack Align="Align.End">
<TextBlock Size="TextSize.Sm" Color="Color.Muted">Default</TextBlock>
<TextBlock>$1,111.11</TextBlock>
<TextBlock>$8,808.80</TextBlock>
<TextBlock>$420.17</TextBlock>
</Stack>
<Stack Align="Align.End">
<TextBlock Size="TextSize.Sm" Color="Color.Muted">TabularNums</TextBlock>
<TextBlock TabularNums>$1,111.11</TextBlock>
<TextBlock TabularNums>$8,808.80</TextBlock>
<TextBlock TabularNums>$420.17</TextBlock>
</Stack>
</Row>Mode support
| Feature | Off | Static | Live |
|---|---|---|---|
| Everything | Yes | Yes | Yes |
Off: JavaScript disabled. Static: a static SSR page with IzzyBlazor's script. Live: an interactive page (Server, WebAssembly or Auto).
Accessibility
- It renders a
p, so text styled to look like a heading is still a paragraph to screen readers; useHeadingfor a real one. - Weight and size are only visual: for emphasis screen readers can hear, set
Astostrongorem.
Parameters
| Prop | Type | Default |
|---|---|---|
SizeFont size. | Responsive<TextSize> | |
WeightFont weight. | FontWeight? | |
FamilyFont family. | FontFamily? | |
AlignHorizontal alignment. | Responsive<TextAlign> | |
LineHeightLine height. | LineHeight? | |
LetterSpacingLetter spacing. | LetterSpacing? | |
TransformLetter case. | TextTransform? | |
DecorationUnderline or strike-through. | TextDecoration? | |
ItalicItalic. | bool | false |
WrapHow lines break: normal, never, balanced or pretty. | TextWrap? | |
TruncateKeep to one line and end with an ellipsis when it does not fit. | bool | false |
LineClampShow at most this many lines, ending with an ellipsis. | int? | |
TabularNumsEqual-width digits, so numbers line up in columns and do not jitter when they change. | bool | false |
MinSizeMakes the size fluid: the text is MinSize on a 360px screen and grows smoothly to Size at 1280px and up, as for a hero heading: <Heading Size="TextSize.Xl5" MinSize="TextSize.Xl3">. | TextSize? | |
AsThe element to render: div on a Box; components built on it set their own (List a ul, Section a section). | string | "p" |
ChildContentThe content. | RenderFragment? |
Plus 25 surface props, 16 item props and 4 common props.
Full API