Skip to content

Text Wrap

Use text-wrap and text-nowrap utilities to control whether text wraps to the next line.


Use text-wrap to allow text to wrap normally and text-nowrap to keep it on a single line:

const _headline = 'Beloved Manhattan soup stand closes';
const _body =
"New Yorkers are facing the winter chill with less warmth this year as "
"the city's most revered soup stand unexpectedly shutters, following a "
"series of events that have left the community puzzled.";
class TextWrapBasicExample extends StatelessWidget {
const TextWrapBasicExample({super.key});
@override
Widget build(BuildContext context) {
return const Style(
'mx-auto grid max-w-xs gap-4 border-x border-x-pink-400/30 py-8 text-gray-700 dark:text-gray-400',
children: [
Style(
'text-xl font-semibold text-gray-900 dark:text-white',
child: Text(_headline),
),
Style('text-sm/6', child: Text(_body)),
],
);
}
}
class TextWrapBasicPage extends StatelessWidget {
const TextWrapBasicPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(body: const TextWrapBasicExample());
}
}
ClassBehavior
text-wrapsoftWrap: true
text-nowrapsoftWrap: false
text-balanceNot yet supported — Flutter’s paragraph engine has no balanced line-breaker. See the Library prerequisites section in PLAYGROUND_PARITY.md.
text-prettyNot yet supported — Flutter has no orphan-prevention line-breaker. See the Library prerequisites section in PLAYGROUND_PARITY.md.