Text
Display reading, units or descriptive text. The font, font size, alignment, line wrapping and truncation can be set; the content is uniformly converted to a string, and empty values are displayed as empty.
Example
function main() {
return (
<Text fontSize={32} font="rounded" lineLimit={2} truncationMode="tail">
Hello, CapDrive
</Text>
);
}
Usage
- Content is converted with toString(); null/undefined render empty. Text cannot contain a Symbol or another View; combine icons and text in HStack. Constrain width to observe lineLimit and truncationMode. minimumScaleFactor=1 disables shrinking.
- Numeric sizes use points. auto measures content; fill uses the space allocated by the parent. Size the container before tuning children. fill creates no extra space, and long text cannot enlarge a fixed parent.
Properties
children?TextContent | TextContent[]Child drawing content.
fontSize?numberFont size in points.
14fontWeight?"ultraLight" | "thin" | "light" | "regular" | "medium" | "semibold" | "bold" | "heavy" | "black"Font weight from ultraLight to black; regular is normal weight.
"regular"font?"default" | "rounded" | "monospaced" | "serif"Font design: default, rounded, monospaced or serif.
"default"color?PaintDrawing color, including HDR colors.
HDR($env.foreground)alignment?"leading" | "center" | "trailing"Text alignment within its available width: leading, center or trailing.
"leading"lineLimit?number | nullMaximum number of text lines. null or omission allows wrapping without a line-count limit.
1truncationMode?"head" | "middle" | "tail"Where to remove text when it does not fit: head, middle or tail.
"tail"minimumScaleFactor?numberMinimum text scale when space is limited: 0.01–1; 1 disables shrinking.
0.5monospacedDigits?booleanUse equal-width digits so changing numbers do not shift horizontally.
trueletterSpacing?numberExtra spacing between characters, in points.
0contentAnimation?ContentAnimationTransition when content changes. Choose the type supported by this View; duration/delay use seconds.
{type: "numericText"}Common properties
width?number | "auto" | "fill"Width in points, auto sizing or parent fill.
100height?number | "auto" | "fill"Height in points, auto sizing or parent fill.
80padding?numberContent padding in points.
0x?numberVisual offset in points: x moves right, y moves down. Does not change layout space.
0y?numberVisual offset in points: x moves right, y moves down. Does not change layout space.
0transform?ViewTransformTransform the whole View without changing layout. Translation uses points; rotation/skew use degrees; scale 1 is unchanged; anchors use 0–1.
{rotation: 0}background?PaintBackground paint; accepts a color or gradient. Use clear for transparency.
"clear"opacity?numberOpacity of the whole View: 0 is transparent, 1 is opaque.
1cornerRadius?numberCorner radius in points.
0clipped?booleanClip drawing that extends beyond the View bounds.
falseclip?"rectangle" | "ellipse"Clipping shape: rectangle or ellipse. Material also accepts false to disable clipping.
"rectangle"mask?View | nullAlpha mask View. Centered without affecting layout; null disables masking.
<Circle width="fill" height="fill" background="white"/>zIndex?numberDrawing order among siblings; larger values appear in front.
0blur?numberBlur radius in points; 0 disables blur.
4innerShadow?DrawingEffectEffect color, opacity, blur radius and x/y offset. Distances are in points.
{color: HDR("black"), opacity: 0.5, radius: 4, x: 0, y: 2}glow?DrawingEffectEffect color, opacity, blur radius and x/y offset. Distances are in points.
{color: HDR("cyan"), radius: 8, opacity: 0.8}shadowColor?ColorColor of the outer shadow.
HDR("black")shadowOpacity?numberOuter shadow opacity from 0 to 1; 0 hides it.
0shadowRadius?numberOuter shadow blur radius in points.
4shadowX?numberOuter shadow offset in points: x right, y down.
0shadowY?numberOuter shadow offset in points: x right, y down.
2animations?Animation[]Animate a supported property when it changes. duration/delay use seconds; from/to set endpoints; repeat and autoreverse control repetition; wrap sets a periodic range.
[{property: "opacity", duration: 0.25, curve: "easeInOut"}]key?string | numberStable identity among siblings.
Practical example
function main() {
return (
<VStack width={180} spacing={12}>
<Text width="fill" fontSize={20} lineLimit={2} truncationMode="tail">
CapDrive — a longer instrument title
</Text>
<HStack alignment="firstTextBaseline" spacing={4}>
<Text fontSize={48} monospacedDigits={true}>
78
</Text>
<Text fontSize={14}>km/h</Text>
</HStack>
</VStack>
);
}
Animation
widthheightpaddingxyopacitybackgroundcornerRadiusblurshadowColorshadowOpacityshadowRadiusshadowXshadowYfontSizeletterSpacingminimumScaleFactorcolortransform.translateXtransform.translateYtransform.scaleXtransform.scaleYtransform.rotationtransform.skewXtransform.skewYtransform.anchorXtransform.anchorYWhen omitted
The table lists omission behavior verified against implementation. Property examples are copyable syntax, not defaults. Pass explicit values for a fixed result; contextual dimensions and theme colors are not fixed constants.
| Properties | When omitted |
|---|---|
fontSize | 14 |
fontWeight | "regular" |
font | "default" |
monospacedDigits | true |
minimumScaleFactor | 1 |
lineLimit | null |
alignment | "center" |
truncationMode | "tail" |
color | HDR($env.foreground) |