OudsLabelText class

OUDS Label Design Guidelines

Reference design version : 1.0.0

Label styles are intended for compact interface elements such as buttons, form fields, badges, and other small components. Unlike other typography categories, they are not responsive and maintain a fixed size across all breakpoints. This ensures visual consistency and predictable behavior within space-constrained UI elements. Labels should be preferred whenever content is displayed within small components.

OudsLabelText(
  text: 'Submit',
  size: OudsLabelTextSize.medium,
  weight: OudsTextWeight.strong,
)

A color override can be provided when the default theme color is not suitable, for example when the text is displayed on a colored surface:

OudsLabelText(
  text: 'Submit',
  size: OudsLabelTextSize.medium,
  color: OudsTheme.of(context).colorScheme(context).contentDefault,
)

Multiple colors can be used simultaneously within the same text.

This widget also accepts lightweight rich text: **bold**, ~~line through~~ and [link](https://example.com) are supported directly in text, and a .rich constructor (OudsLabelText.rich) is exposed to color only part of the text. Build the .rich constructor's text argument with buildOudsAnnotatedText.

The user must ensure that the contrast between the colors used meets current accessibility standards and that the colors align with the brand’s and its entity’s visual identity.

OudsLabelText.rich(
  text: buildOudsAnnotatedText((builder) {
    builder.append('Submit ');
    builder.withColor((context) => color, () => builder.append('now'));
  }),
)

Use onLinkTap to handle taps on markdown-style links ([label](url)) embedded in text:

OudsLabelText(
  text: 'See [terms and conditions](https://example.com/terms)',
  size: OudsLabelTextSize.medium,
  onLinkTap: (url) {
    // Open the URL, e.g. via url_launcher.
  },
)
Inheritance

Constructors

OudsLabelText({Key? key, required String text, Color? color, OudsLabelTextSize size = OudsLabelTextSize.medium, OudsTextWeight weight = OudsTextWeight.defaultWeight, int? maxLines, TextAlign? textAlign, TextOverflow? overflow, bool? softWrap})
Creates an OudsLabelText.
const
OudsLabelText.rich({Key? key, required OudsAnnotatedText text, Color? color, OudsLabelTextSize size = OudsLabelTextSize.medium, OudsTextWeight weight = OudsTextWeight.defaultWeight, void onLinkTap(String url)?, int? maxLines, TextAlign? textAlign, TextOverflow? overflow, bool? softWrap})
Creates an OudsLabelText whose content is composed of multiple spans, some of which can be colored independently of the others. Build text with buildOudsAnnotatedText to color part of the text, e.g. to highlight a word or phrase.
const

Properties

color → Color?
An optional color override. When null, the theme's contentDefault color is used.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxLines → int?
An optional maximum number of lines for the text to span, wrapping if necessary. If the text exceeds the given number of lines, it will be truncated according to overflow and softWrap.
final
onLinkTap → void Function(String url)?
Callback invoked when a [link](url) inside text or the annotated text is tapped.
final
overflow → TextOverflow?
How visual overflow should be handled.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
size → OudsLabelTextSize
The size of the label text, see OudsLabelTextSize. Defaults to OudsLabelTextSize.medium.
final
softWrap → bool?
Whether the text should break at soft line breaks. If false, the glyphs in the text will be positioned as if there was unlimited horizontal space. If softWrap is false, overflow and TextAlign may have unexpected effects.
final
text → String
The text to display. Empty when built via OudsLabelText.rich.
final
textAlign → TextAlign?
Alignment of the text within the lines of the paragraph. See TextAlign.
final
weight → OudsTextWeight
The emphasis level of the label text, see OudsTextWeight. Defaults to OudsTextWeight.defaultWeight.
final

Methods

build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
override
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
textStyle(BuildContext context) → TextStyle
Returns the TextStyle associated with size and weight in the active theme.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited