UNPKG

1.83 kBMarkdownView Raw
1@# Collapsible list
2
3The `CollapsibleList` component accepts a list of menu items and a count of
4visible items. It shows precisely that many items and collapses the rest into a
5dropdown menu. The required `visibleItemRenderer` callback prop allows for
6customizing the appearance of visible items, using the props from the `MenuItem`
7children.
8
9<div class="@ns-callout @ns-intent-danger @ns-icon-error">
10 <h4 class="@ns-heading">
11
12Deprecated: use [Overflow list](#core/components/overflow-list)
13</h4>
14
15This component is **deprecated since 3.0.0** with the introduction of
16[`OverflowList`](#core/components/overflow-list) which provides a similar
17experience with two distinct advantages:
18
19<ol>
20 <li>Items collapse automatically based on available space in the container.</li>
21 <li>
22
23`OverflowList` accepts a generic array of items (instead of explicit
24`<MenuItem>` children) with custom renderers for both visible and overflowed
25items, allowing for _any_ UI, not just a dropdown menu.
26
27</li>
28</ol>
29
30</div>
31
32@reactExample CollapsibleListExample
33
34@## Separators
35
36Often a list of items calls for separators between each item.
37Adding separators to a `CollapsibleList` is easily achieved via CSS using `::after` pseudo-elements.
38
39```css.scss
40// pass `visibleItemClassName="my-list-item"` to component, then...
41
42.my-list-item::after {
43 display: inline-block;
44 content: "";
45 // custom separator styles...
46}
47
48// remove separator after the last item
49.my-list-item:last-child::after {
50 display: none;
51}
52```
53
54@## Props
55
56Children of the `CollapsibleList` component _must_ be `MenuItem`s so they can be easily rendered
57in the dropdown. Define a `visibleItemRenderer` callback to customize the appearance of visible
58items using their [`IMenuItemProps`](#core/components/menu.menu-item).
59
60@interface ICollapsibleListProps