Skip to Content
Mix 2.0 is in development! You can access the Mix 1.0 docs here.

StyledText

StyledText is equivalent to Flutter’s Text widget, but provides styling capabilities through the Mix framework. It allows you to create visually styled text with typography, colors, decorations, text transformations, and responsive variants.

You can use TextStyler to create styles with a fluent API. Example:

final style = TextStyler() .fontSize(24) .fontWeight(FontWeight.bold) .color(Colors.blue); StyledText( 'Hello Mix', style: style, )

Constructor

PropTypeRequired / Default Value
textStringRequired
styleStyleconst TextStyler.create()
styleSpecStyleSpec?Optional

Style API Reference

StyledText Methods

MethodDescription
textDirectiveSets a text directive. It will be applied to the text before it is displayed.
overflowSets text overflow behavior
strutStyleSets strut style
textAlignSets text alignment
textScalerSets text scaler
maxLinesSets maximum number of lines
textWidthBasisSets text width basis
textHeightBehaviorSets text height behavior
textDirectionSets text direction
softWrapSets soft wrap behavior
directiveAdds a text directive
selectionColorSets selection color
semanticsLabelSets semantics label
localeSets locale
uppercaseApplies uppercase directive
lowercaseApplies lowercase directive
capitalizeApplies capitalize directive
titleCaseApplies title case directive
sentenceCaseApplies sentence case directive
modifierSets the widget modifier.
styleMixin implementation for text styling
animateConvenience method for animating the TextSpec
variantsSets the variants list.
wrapSets the widget modifier.

Animation

MethodDescription
keyframeAnimationCreates a keyframe animation. It will animate through the given timeline.
phaseAnimationCreates a phase animation. It will animate through the given phases.

Text

MethodDescription
colorSets text color
backgroundColorSets background color
fontSizeSets font size
fontWeightSets font weight
fontStyleSets font style
letterSpacingSets letter spacing
wordSpacingSets word spacing
heightSets line height
textBaselineSets text baseline
decorationSets text decoration
decorationColorSets decoration color
decorationStyleSets decoration style
decorationThicknessSets decoration thickness
fontFamilySets font family
fontFamilyFallbackSets font family fallback
shadowsSets text shadows
fontFeaturesSets font features
fontVariationsSets font variations
foregroundSets foreground paint
backgroundSets background paint
debugLabelSets debug label
inheritSets inherit property

Variant

MethodDescription
variantAdds a single variant to this style.
onDarkCreates a variant for dark mode.
onNotCreates a variant for when the context does NOT match the provided variant.
onLightCreates a variant for light mode.
onBuilderCreates a variant using a builder function that receives the build context.
builderDeprecated: Use [onBuilder] instead.
onBreakpointCreates a variant based on the specified breakpoint.
onPortraitCreates a variant for portrait device orientation.
onLandscapeCreates a variant for landscape device orientation.
onMobileCreates a variant for mobile breakpoint.
onTabletCreates a variant for tablet breakpoint.
onDesktopCreates a variant for desktop breakpoint.
onLtrCreates a variant for left-to-right text direction.
onRtlCreates a variant for right-to-left text direction.
onIosCreates a variant for iOS platform.
onAndroidCreates a variant for Android platform.
onMacosCreates a variant for macOS platform.
onWindowsCreates a variant for Windows platform.
onLinuxCreates a variant for Linux platform.
onFuchsiaCreates a variant for Fuchsia platform.
onWebCreates a variant for web platform.

Widget State Variant

MethodDescription
onHoveredCreates a variant for hover state
onPressedCreates a variant for pressed state
onFocusedCreates a variant for focused state
onDisabledCreates a variant for disabled state
onEnabledCreates a variant for enabled state (opposite of disabled)