Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

Capped list

Cap a region's height so its content scrolls inside it, and the page around it stays put.

A capped list
  • Row 1
  • Row 2
  • Row 3
  • Row 4
  • Row 5
  • Row 6
  • Row 7
  • Row 8
  • Row 9
  • Row 10
  • Row 11
  • Row 12
  • Row 13
  • Row 14
  • Row 15
  • Row 16
  • Row 17
  • Row 18
  • Row 19
  • Row 20
  • Row 21
  • Row 22
  • Row 23
  • Row 24
Show code
<app-scrollbar max-height="220">
  <ul>
    <li>Row 1</li>
    <!-- one li per row, twenty-four in all -->
  </ul>
</app-scrollbar>

Overflow directions

Scroll vertically for long lists, horizontally for wide rows, or on both axes when content is wide and tall.

Horizontal row of badges
Column 1 Column 2 Column 3 Column 4 Column 5 Column 6 Column 7 Column 8 Column 9 Column 10 Column 11 Column 12
Show code
<app-scrollbar>
  <div class="d-flex gap-2">
    <span class="badge text-bg-secondary">Column 1</span>
    <!-- one badge per column, twelve in all -->
  </div>
</app-scrollbar>
Wide list on both axes
  • Row 1: a long line of text to force horizontal overflow too
  • Row 2: a long line of text to force horizontal overflow too
  • Row 3: a long line of text to force horizontal overflow too
  • Row 4: a long line of text to force horizontal overflow too
  • Row 5: a long line of text to force horizontal overflow too
  • Row 6: a long line of text to force horizontal overflow too
  • Row 7: a long line of text to force horizontal overflow too
  • Row 8: a long line of text to force horizontal overflow too
  • Row 9: a long line of text to force horizontal overflow too
  • Row 10: a long line of text to force horizontal overflow too
  • Row 11: a long line of text to force horizontal overflow too
  • Row 12: a long line of text to force horizontal overflow too
  • Row 13: a long line of text to force horizontal overflow too
  • Row 14: a long line of text to force horizontal overflow too
  • Row 15: a long line of text to force horizontal overflow too
  • Row 16: a long line of text to force horizontal overflow too
  • Row 17: a long line of text to force horizontal overflow too
  • Row 18: a long line of text to force horizontal overflow too
  • Row 19: a long line of text to force horizontal overflow too
  • Row 20: a long line of text to force horizontal overflow too
  • Row 21: a long line of text to force horizontal overflow too
  • Row 22: a long line of text to force horizontal overflow too
  • Row 23: a long line of text to force horizontal overflow too
  • Row 24: a long line of text to force horizontal overflow too
Show code
<app-scrollbar max-height="140">
  <ul class="text-nowrap">
    <li>Row 1: a long line of text to force horizontal overflow too</li>
    <!-- one li per row, twenty-four in all -->
  </ul>
</app-scrollbar>

Viewport height

Give maxHeight a pixel number or a viewport share such as 30vh, so the region fits the screen on any device.

Capped at 30vh
  • Row 1
  • Row 2
  • Row 3
  • Row 4
  • Row 5
  • Row 6
  • Row 7
  • Row 8
  • Row 9
  • Row 10
  • Row 11
  • Row 12
  • Row 13
  • Row 14
  • Row 15
  • Row 16
  • Row 17
  • Row 18
  • Row 19
  • Row 20
  • Row 21
  • Row 22
  • Row 23
  • Row 24
Show code
<app-scrollbar max-height="30vh">
  <ul>
    <li>Row 1</li>
    <!-- one li per row, twenty-four in all -->
  </ul>
</app-scrollbar>

Every option

Every value of every prop, one cell each.

children

children, vertical only: tall content, fixed width
  • Row 1
  • Row 2
  • Row 3
  • Row 4
  • Row 5
  • Row 6
  • Row 7
  • Row 8
  • Row 9
  • Row 10
  • Row 11
  • Row 12
  • Row 13
  • Row 14
  • Row 15
  • Row 16
  • Row 17
  • Row 18
  • Row 19
  • Row 20
  • Row 21
  • Row 22
  • Row 23
  • Row 24
children, horizontal only: wide row, no max-height
Column 1 Column 2 Column 3 Column 4 Column 5 Column 6 Column 7 Column 8 Column 9 Column 10 Column 11 Column 12
children, both axes: tall and wide content together
  • Row 1: a long line of text to force horizontal overflow too
  • Row 2: a long line of text to force horizontal overflow too
  • Row 3: a long line of text to force horizontal overflow too
  • Row 4: a long line of text to force horizontal overflow too
  • Row 5: a long line of text to force horizontal overflow too
  • Row 6: a long line of text to force horizontal overflow too
  • Row 7: a long line of text to force horizontal overflow too
  • Row 8: a long line of text to force horizontal overflow too
  • Row 9: a long line of text to force horizontal overflow too
  • Row 10: a long line of text to force horizontal overflow too
  • Row 11: a long line of text to force horizontal overflow too
  • Row 12: a long line of text to force horizontal overflow too
  • Row 13: a long line of text to force horizontal overflow too
  • Row 14: a long line of text to force horizontal overflow too
  • Row 15: a long line of text to force horizontal overflow too
  • Row 16: a long line of text to force horizontal overflow too
  • Row 17: a long line of text to force horizontal overflow too
  • Row 18: a long line of text to force horizontal overflow too
  • Row 19: a long line of text to force horizontal overflow too
  • Row 20: a long line of text to force horizontal overflow too
  • Row 21: a long line of text to force horizontal overflow too
  • Row 22: a long line of text to force horizontal overflow too
  • Row 23: a long line of text to force horizontal overflow too
  • Row 24: a long line of text to force horizontal overflow too
children, no overflow: content fits, scrollbar absent
  • Row 1
  • Row 2
  • Row 3

maxHeight

max-height="160": a number, read as pixels
  • Row 1
  • Row 2
  • Row 3
  • Row 4
  • Row 5
  • Row 6
  • Row 7
  • Row 8
  • Row 9
  • Row 10
  • Row 11
  • Row 12
  • Row 13
  • Row 14
  • Row 15
  • Row 16
  • Row 17
  • Row 18
  • Row 19
  • Row 20
  • Row 21
  • Row 22
  • Row 23
  • Row 24
max-height="30vh": viewport unit
  • Row 1
  • Row 2
  • Row 3
  • Row 4
  • Row 5
  • Row 6
  • Row 7
  • Row 8
  • Row 9
  • Row 10
  • Row 11
  • Row 12
  • Row 13
  • Row 14
  • Row 15
  • Row 16
  • Row 17
  • Row 18
  • Row 19
  • Row 20
  • Row 21
  • Row 22
  • Row 23
  • Row 24
max-height="100%": parent must constrain height
  • Row 1
  • Row 2
  • Row 3
  • Row 4
  • Row 5
  • Row 6
  • Row 7
  • Row 8
  • Row 9
  • Row 10
  • Row 11
  • Row 12
  • Row 13
  • Row 14
  • Row 15
  • Row 16
  • Row 17
  • Row 18
  • Row 19
  • Row 20
  • Row 21
  • Row 22
  • Row 23
  • Row 24
(default) no max-height: grows to fit content, no scrollbar
  • Row 1
  • Row 2
  • Row 3
  • Row 4

className

(default) class="": no extra classes
  • Row 1
  • Row 2
  • Row 3
  • Row 4
  • Row 5
  • Row 6
  • Row 7
  • Row 8
  • Row 9
  • Row 10
  • Row 11
  • Row 12
  • Row 13
  • Row 14
  • Row 15
  • Row 16
  • Row 17
  • Row 18
  • Row 19
  • Row 20
  • Row 21
  • Row 22
  • Row 23
  • Row 24
class="my-scroll": added to the scroll container
  • Row 1
  • Row 2
  • Row 3
  • Row 4
  • Row 5
  • Row 6
  • Row 7
  • Row 8
  • Row 9
  • Row 10
  • Row 11
  • Row 12
  • Row 13
  • Row 14
  • Row 15
  • Row 16
  • Row 17
  • Row 18
  • Row 19
  • Row 20
  • Row 21
  • Row 22
  • Row 23
  • Row 24

style

style="background: var(--color-bg-muted)": merged with max-height
  • Row 1
  • Row 2
  • Row 3
  • Row 4
  • Row 5
  • Row 6
  • Row 7
  • Row 8
  • Row 9
  • Row 10
  • Row 11
  • Row 12
  • Row 13
  • Row 14
  • Row 15
  • Row 16
  • Row 17
  • Row 18
  • Row 19
  • Row 20
  • Row 21
  • Row 22
  • Row 23
  • Row 24

Guidance

What to do, and what to avoid.

Use it when

  • A fixed-height region (dropdown, side panel, card body) can overflow and you want a thin, unobtrusive scrollbar instead of the browser default.
  • The native scrollbar visually clutters a dense UI (a chunky gutter next to narrow content).

Reach for something else when

  • Scrolling the whole page. → the native page scrollbar
  • A region that should paginate instead of scroll. → AppTablePagination

Reference

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

vertical horizontal both none
  • Row 1
  • Row 2
  • Row 3
  • Row 4
  • Row 5
  • Row 6
  • Row 7
  • Row 8
  • Row 9
  • Row 10
  • Row 11
  • Row 12
  • Row 13
  • Row 14
  • Row 15
  • Row 16
  • Row 17
  • Row 18
  • Row 19
  • Row 20
  • Row 21
  • Row 22
  • Row 23
  • Row 24
React, generated from the controls
<AppScrollbar maxHeight={220} style={{ width: "min(280px, 100%)" }}>
  {/* vertical overflow content */}
</AppScrollbar>
Razor, the same props
<app-scrollbar max-height="220" data-wui-style="width:min(280px,100%);">
  <!-- vertical overflow content -->
</app-scrollbar>

1 props. The 1 most used come first.

Used on most screens 1 props

PropTypeDefaultDescription
max-heightdefault - string - Caps the container height so content overflows and scrolls. A number is treated as pixels.

Screen reader

2 notes
  • Only the scrollbar is restyled: native scrolling, keyboard navigation and in-page anchors work as in any scrollable element.
  • The container adds no role or aria attribute of its own, so the content inside keeps its own semantics.