Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

By width

Cut a long name to the width its column gives, with the whole text one hover or focus away.

In a narrow column
In a flex row put min-w-0 on the item that holds the text, or pass width; without a width limit the row grows instead of cutting.
Quarterly statutory compliance filing for the Pune and Bengaluru offices, including the revised provident fund returns and the professional tax reconciliation
Show code
<app-truncate width="240px">@project.Name</app-truncate>

By line count

Show up to three lines of a description, then the ellipsis, so a card keeps an even height.

Three lines
Quarterly statutory compliance filing for the Pune and Bengaluru offices, including the revised provident fund returns and the professional tax reconciliation
Show code
<app-truncate lines="3" width="320px">@project.Description</app-truncate>

Text that fits

Text that fits shows whole with no tooltip and no tab stop, so nothing extra is announced.

Fits, so no tooltip
Short text
Show code
<app-truncate lines="3">Short text</app-truncate>

Every option

Every value of every prop, one cell each.

children

children, the text between the tags
Quarterly statutory compliance filing for the Pune and Bengaluru offices, including the revised provident fund returns and the professional tax reconciliation

lines

lines="1" (default)
Quarterly statutory compliance filing for the Pune and Bengaluru offices, including the revised provident fund returns and the professional tax reconciliation
lines="2"
Quarterly statutory compliance filing for the Pune and Bengaluru offices, including the revised provident fund returns and the professional tax reconciliation
lines="3"
Quarterly statutory compliance filing for the Pune and Bengaluru offices, including the revised provident fund returns and the professional tax reconciliation
lines="6"
Quarterly statutory compliance filing for the Pune and Bengaluru offices, including the revised provident fund returns and the professional tax reconciliation

width

width omitted (default): the width it is given
Quarterly statutory compliance filing for the Pune and Bengaluru offices, including the revised provident fund returns and the professional tax reconciliation
width="12rem"
Quarterly statutory compliance filing for the Pune and Bengaluru offices, including the revised provident fund returns and the professional tax reconciliation

style

style, React only: style={{ fontWeight: 600 }} makes the cut text bold
Quarterly statutory compliance filing for the Pune and Bengaluru offices, including the revised provident fund returns and the professional tax reconciliation

className

class: extra classes on the root, no visible change alone (React: className)
Quarterly statutory compliance filing for the Pune and Bengaluru offices, including the revised provident fund returns and the professional tax reconciliation

Guidance

What to do, and what to avoid.

Use it when

  • Names and descriptions in cards, rows and lists where the layout fixes the width.
  • Any text where the full value still matters on demand.

Reach for something else when

  • Text a reader must see in full to act on. → Let it wrap
  • Long copy that needs a read-more. → Show it in full on its own page

Reference

Try every prop, read the full list, and check keyboard and screen reader behaviour.

Quarterly statutory compliance filing for the Pune and Bengaluru offices, including the revised provident fund returns and the professional tax reconciliation
React, generated from the controls
<AppTruncate width="20rem">
  {description}
</AppTruncate>
Razor, the same props
<app-truncate width="20rem">
    @project.Description
</app-truncate>

2 props. The 2 most used come first.

Used on most screens 2 props

PropTypeDefaultDescription
linesdefault 1 int 1 How many lines show before the cut. 1 is a single line cut by width.
widthdefault - string - A CSS length the text never exceeds, such as 12rem or 240px. Without it the text takes the width it is given.

Screen reader

3 notes
  • Text that is cut gets a tab stop and shows its full text in a tooltip on hover and on keyboard focus.
  • Text that fits takes no tab stop and shows no tooltip.
  • The whole text stays in the page as ordinary text, so assistive technology reads all of it.