Examples
Analytics period filter
Built with the mantine-calendar skill
Period type
Oct 23, 2026 – Nov 21, 2026 · 30 days
Selected period
{
"mode": "custom",
"start": "2026-10-23",
"end": "2026-11-21",
"days": 30,
"comparison": null
}Build the period filter of an analytics dashboard: a control in the dashboard header that picks the reporting period.
Data:
- the company's fiscal year starts on April 1 and is named by the year it ends in (April 2026 – March 2027 is FY2027); fiscal quarters are Q1 April–June through Q4 January–March
- data exists from January 1 two years ago up to yesterday
Filter:
- three modes: a custom range, a calendar month, a fiscal quarter
- custom range: an input with a dropdown of two months side by side and presets next to them (Last 7 days, Last 30 days, This month, Last month, Year to date); at most 366 days, nothing before the data starts or after yesterday; while the first day is picked, days that would make the range too long look unavailable
- calendar month: a month picker limited to the months that have data
- fiscal quarter: fiscal years with their four quarters, labelled "FY2027 Q1"; quarters that have not started are unavailable, the current one is marked as incomplete
- a "Compare to" option: the previous period of the same length, or the same period one year earlier; the comparison period is shown as text under the filter
- the filter fits on a phone screen
Value:
- every change displays the selected period, its length in days and the comparison period as JSON under the filter
The component is shown on a demo page that already has a title: do not add a page title or intro text.
Write tests for the component.