What problem does this address?
The @wordpress/ui Text component doesn't provide any built-in support for truncation behavior, requiring developers to implement this themselves (e.g. #77012, #77372). From a design system perspective, we should seek to ensure consistency and provide baseline support for how content is truncated.
What is your proposed solution?
Add props for:
- Enabling truncation (e.g.
truncate, a boolean)
- Controlling number of lines (e.g.
numberOfLines or lineClamp, a number)
In adding support, we should also remove existing workarounds, like those in the pull requests referenced above (#77012, #77372).
We should be careful to consider scope creep and what's minimally necessary to provide baseline functionality and consistency for such a low-level component.
For background, the @wordpress/components Text component composes options from the Truncate component, which provides a lot of control over specific truncation behavior (ellipsis string, trimming behavior, character limit, line limit). Many of these are rarely (or never, in the case of ellipsis) used, and arguably could be counter-productive to the design system's intent of providing consistency.
truncate and numberOfLines are the most regularly used options today. Other component libraries like Chakra UI's Text component provide exactly this amount of customization as well.
Open question: Is this a good enough combination of (a) being commonly used, (b) being difficult to implement without, and (c) prone to being implemented inconsistency, in order to warrant the maintenance cost and scope inflation to implement baseline support?
What problem does this address?
The
@wordpress/uiTextcomponent doesn't provide any built-in support for truncation behavior, requiring developers to implement this themselves (e.g. #77012, #77372). From a design system perspective, we should seek to ensure consistency and provide baseline support for how content is truncated.What is your proposed solution?
Add props for:
truncate, aboolean)numberOfLinesorlineClamp, a number)In adding support, we should also remove existing workarounds, like those in the pull requests referenced above (#77012, #77372).
We should be careful to consider scope creep and what's minimally necessary to provide baseline functionality and consistency for such a low-level component.
For background, the
@wordpress/componentsTextcomponent composes options from theTruncatecomponent, which provides a lot of control over specific truncation behavior (ellipsis string, trimming behavior, character limit, line limit). Many of these are rarely (or never, in the case ofellipsis) used, and arguably could be counter-productive to the design system's intent of providing consistency.truncateandnumberOfLinesare the most regularly used options today. Other component libraries like Chakra UI'sTextcomponent provide exactly this amount of customization as well.Open question: Is this a good enough combination of (a) being commonly used, (b) being difficult to implement without, and (c) prone to being implemented inconsistency, in order to warrant the maintenance cost and scope inflation to implement baseline support?