Skip to main content
/
/
/
Ellipsis

Ellipsis

Hide overflowing text with an ellipsis

ReactCSS
import Ellipsis from "@intility/bifrost-react/Ellipsis";
Props

Basic usage

Text that is is too long to fit within its container will be cut off and replaced with an ellipsis.

A tooltip will show the full text on hover.

TSX
<Ellipsis>Wordy text</Ellipsis>
Text that is so long and wordy that it would overflow its container will be cut off and replaced with an ellipsis because it would not otherwise fit.

When the text fits within its container, it will not be cut off, and no tooltip will be rendered.

Text that fit within its container will not be cut off.

Lines

The lines prop can be used to allow the ellipsis to be applied after a certain number of lines.

TSX
<Ellipsis lines={3}>
Only text that is so long and wordy that it would overflow its container will be cut off and replaced with an ellipsis, because it would not otherwise fit.

Use as innermost element

Nesting non-text elements inside the Ellipsis component may cause unexpected behavior, so we recommend only using it as the innermost element.

Yep

TSX
<Grid>
  <Ellipsis>Some text</Ellipsis>
  [more content]
</Grid>

Nope

TSX
<Ellipsis>
  <Grid>Don't do this</Grid>
  [more content]
</Ellipsis>

Of course, text-formatting elements like <strong> and <em> is fine, and <Icon /> should also not cause issues.

Padded

The padded prop can be used to avoid clipping focus styling on contained elements by adding 3px of padding and -3px of margin to the ellipsis root element.

This is only needed if you expect the text to contain links.

Yep

TSX
<Ellipsis padded>
  When focusing a <a href="#">link</a> you will get an outline, but the outline
  will not be clipped by the ellipsis when the padded parameter is included.
</Ellipsis>
When focusing a link you will get an outline, but the outline will not be clipped by the ellipsis when the padded parameter is included.

Nope

TSX
<Ellipsis>
  When focusing a <a href="#">link</a> you will get an outline, but the outline
  will be clipped by the ellipsis when the padded parameter is omitted.
</Ellipsis>
When focusing a link you will get an outline, but the outline will be clipped by the ellipsis when the padded parameter is omitted.

Disable tooltip

If you don't want a tooltip (it's interfering with other functionality and you're supplying your own?), you can use the .bf-ellipsis CSS class directly instead:

TSX
<div className="bf-ellipsis">Wordy text</div>
Text that is so long and wordy that it would overflow its container will be cut off and replaced with an ellipsis because it would not otherwise fit.