@@ -122,4 +122,70 @@ const [state, setState] = useState([
122122 nextButton: " next month button" ,
123123 }}
124124/ > ;
125- ```
125+ ```
126+
127+ #### Example: Custom Day Cell Content
128+ Show orange dot only for weekend
129+
130+ ``` jsx inside Markdown
131+ import { addDays , format , isWeekend } from ' date-fns' ;
132+ import { useState } from ' react' ;
133+
134+ const [state , setState ] = useState ([
135+ {
136+ startDate: addDays (new Date (), - 6 ),
137+ endDate: new Date (),
138+ key: ' selection1'
139+ },
140+ {
141+ startDate: addDays (new Date (), 1 ),
142+ endDate: addDays (new Date (), 7 ),
143+ key: ' selection2'
144+ }
145+ ]);
146+
147+ function customDayContent (day ) {
148+ extraDot = null ;
149+ if (isWeekend (day)) {
150+ extraDot = (
151+ < div
152+ style= {{
153+ height: " 5px" ,
154+ width: " 5px" ,
155+ borderRadius: " 100%" ,
156+ background: " orange" ,
157+ position: " absolute" ,
158+ top: 2 ,
159+ right: 2 ,
160+ }}
161+ / >
162+ )
163+ }
164+ return (
165+ < div>
166+ {extraDot}
167+ < span> {format (day, " d" )}< / span>
168+ < / div>
169+ )
170+ }
171+
172+ < DateRangePicker
173+ onChange= {item => setState ([item .selection ])}
174+ showSelectionPreview= {true }
175+ moveRangeOnFirstSelection= {false }
176+ months= {2 }
177+ ranges= {state}
178+ direction= " horizontal"
179+ dayContentRenderer= {customDayContent}
180+ ariaLabels= {{
181+ dateInput: {
182+ selection1: { startDate: " start date input of selction 1" , endDate: " end date input of selction 1" },
183+ selection2: { startDate: " start date input of selction 2" , endDate: " end date input of selction 2" }
184+ },
185+ monthPicker: " month picker" ,
186+ yearPicker: " year picker" ,
187+ prevButton: " previous month button" ,
188+ nextButton: " next month button" ,
189+ }}
190+ / > ;
191+ ```
0 commit comments