@@ -11,11 +11,13 @@ The `LoadMore` component provides a "Show More" button that allows users to load
1111## Features
1212
1313- "Show More" button to load additional items when clicked
14+ - Optional "Show All" button to load all remaining items at once
1415- Optional count indicator showing current items and total (e.g., "1-5 of 15")
1516- "Show Less" button appears when all items are loaded (if onLoadLess prop is provided)
1617- Supports a loading state to disable the button during data fetching
1718- Automatically hides the "Show More" button when all items are loaded
1819- Option to hide the count indicator with centered button layout
20+ - Fully customizable buttons (labels, styles, and other props)
1921
2022## Basic Usage
2123
@@ -36,6 +38,13 @@ const MyList = () => {
3638 setIsLoading (false );
3739 };
3840
41+ const handleShowAll = () => {
42+ setIsLoading (true );
43+ // Fetch all remaining items, then:
44+ setItems ([... items, ... remainingItems]);
45+ setIsLoading (false );
46+ };
47+
3948 const handleLoadLess = () => {
4049 // Reduce items to initial batch size
4150 setItems (items .slice (0 , batchSize));
@@ -53,8 +62,11 @@ const MyList = () => {
5362 currentCount= {items .length }
5463 total= {totalItems}
5564 onLoadMore= {handleLoadMore}
65+ onShowAll= {handleShowAll}
5666 onLoadLess= {handleLoadLess}
5767 isLoading= {isLoading}
68+ showMoreLabel= " Load Next Page"
69+ showAllButtonProps= {{ status: " accent" }}
5870 / >
5971 < / div>
6072 );
@@ -79,6 +91,14 @@ Shows both the count indicator and "Show More" button:
7991 <Story id = " components-loadmore--with-count" />
8092</Canvas >
8193
94+ ### With Show All
95+
96+ Shows the "Show All" button next to the "Show More" button.
97+
98+ <Canvas >
99+ <Story id = " components-loadmore--with-show-all" />
100+ </Canvas >
101+
82102### Mid-List Example
83103
84104Shows the state when some items are loaded:
@@ -113,12 +133,22 @@ A complete example showing the component in use with a list:
113133
114134### With Show Less
115135
116- Shows how the "Show Less" button appears when all items are loaded and onLoadLess is provided:
136+ Shows how the "Show Less" button appears when all items are loaded and
137+ onLoadLess is provided:
117138
118139<Canvas >
119140 <Story id = " components-loadmore--with-show-less" />
120141</Canvas >
121142
143+ ### With List and Show All
144+
145+ A complete example showing the component in use with a list and the "Show All"
146+ button.
147+
148+ <Canvas >
149+ <Story id = " components-loadmore--with-list-and-show-all" />
150+ </Canvas >
151+
122152## Props
123153
124154<ArgsTable of = { LoadMore } />
@@ -127,7 +157,8 @@ Shows how the "Show Less" button appears when all items are loaded and onLoadLes
127157
128158The component follows accessibility best practices:
129159
130- - The "Show More" button is properly labeled for screen readers
160+ - The "Show More" and "Show All" buttons are properly labeled for screen
161+ readers
131162- The button is disabled during loading states to prevent multiple clicks
132163- The count indicator (when shown) provides context about the loaded items
133164
@@ -145,21 +176,46 @@ The component follows accessibility best practices:
145176 < LoadMore currentCount= {5 } total= {15 } onLoadMore= {handleLoadMore} / >
146177 ```
147178
148- 3 . ** With Show Less**
179+ 3 . ** With Show All**
180+
181+ ``` jsx
182+ < LoadMore currentCount= {5 } total= {15 } onLoadMore= {handleLoadMore} onShowAll= {handleShowAll} / >
183+ ```
184+
185+ 4 . ** With Custom Buttons and Labels**
186+
187+ ``` jsx
188+ < LoadMore
189+ currentCount= {5 }
190+ total= {15 }
191+ onLoadMore= {handleLoadMore}
192+ onShowAll= {handleShowAll}
193+ showMoreLabel= " Gimme more"
194+ showMoreButtonProps= {{ severity: " low" }}
195+ showAllButtonProps= {{ disabled: true }}
196+ / >
197+ ```
198+
199+ 5 . ** With Show Less**
149200
150201 ``` jsx
151202 < LoadMore currentCount= {15 } total= {15 } onLoadMore= {handleLoadMore} onLoadLess= {handleLoadLess} / >
152203 ```
153204
154- 4 . ** With Loading State**
205+ 6 . ** With Loading State**
155206 ``` jsx
156207 < LoadMore currentCount= {5 } total= {15 } onLoadMore= {handleLoadMore} isLoading= {true } / >
157208 ```
158209
159210## Design Considerations
160211
161- - The count indicator uses the same styling as other pagination components for consistency
212+ - The count indicator uses the same styling as other pagination components for
213+ consistency
162214- When ` hideCount ` is true, the button is automatically centered
163- - The button uses the link color and underline hover effect for a lightweight appearance
215+ - The button uses the link color and underline hover effect for a lightweight
216+ appearance
164217- Loading state is visually indicated while maintaining the button's position
165- - "Show Less" button appears in place of "Show More" when all items are loaded and onLoadLess is provided
218+ - "Show Less" button appears in place of "Show More" when all items are loaded
219+ and onLoadLess is provided
220+ - The "Show All" button appears next to the "Show More" button when the
221+ ` onShowAll ` prop is provided.
0 commit comments