HWTextStyle

Text styling for HWText — font size, weight, color, decorations, and semantic roles.

HWTextStyle

HWTextStyle describes how an HWText is rendered. Every field is optional; unset fields fall back to the platform default or to baseStyle if provided.

Parameters

NameTypeDefaultDescription
fontSizedouble?nullPoint size on iOS, sp on Android.
fontWeightHWFontWeight?nullOne of w100w900, normal, bold.
colorHWColor?nullForeground color. See HWColor.
italicbool?nullItalicizes the text.
underlinebool?nullAdds an underline decoration.
lineThroughbool?nullAdds a strike-through decoration.
baseStyleHWTextStyle?nullA style to inherit from. See Inheritance.
HWText.fixed(
  'kWh',
  style: HWTextStyle(
    fontSize: 16.0,
    color: HWDefaultColor(HWColorRole.contentSecondary),
  ),
)

HWTextStyle.role / HWRoleTextStyle

Use HWRoleTextStyle when you want to follow the system's typographic hierarchy. The role sets a sensible default font size and weight per platform; you can still override individual fields.

RoleDescription
titleLargest, headline-level text.
headlineSection headline.
bodyDefault body copy.
calloutSlightly smaller than body.
captionSmall caption text.
captionSmallSmallest caption variant.

HWRoleTextStyle exposes a named constructor per role: .title, .headline, .body, .callout, .caption, .captionSmall.

HWText.fixed(
  '46',
  style: HWRoleTextStyle(
    role: HWTextStyleRole.title,
    color: HWDefaultColor(HWColorRole.contentPrimary),
    fontWeight: HWFontWeight.bold,
  ),
)

Inheritance

baseStyle lets you compose styles. The generator walks up the chain and uses the first non-null value it finds for each field — so a child only needs to declare what it overrides.

Platform mapping

  • iOS — emitted as SwiftUI .font, .foregroundColor and decoration modifiers.
  • Android — emitted as Glance TextStyle with FontWeight, FontStyle, and TextDecoration.