OneScript

lineLimit

Limit how many lines text can use.

lineLimit(value) limits the number of lines for the current view or descendant Text and vertical TextFields.

  • A number sets the maximum. Text that does not fit is truncated.
  • { min, max } sets a range. A vertical TextField always reserves min lines and scrolls once it reaches max. Either bound can be omitted.

Line counts must be positive integers, and min must not be greater than max.

import { Modifier, Text } from "onescript/views"

<Text modifier={Modifier.lineLimit(2)}>
  {article.summary}
</Text>
import { Modifier, TextField } from "onescript/views"

<TextField
  value={comment}
  onChange={setComment}
  axis="vertical"
  modifier={Modifier.lineLimit({ min: 3, max: 6 })}
/>

How is this guide?

Last updated on