Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apps/mantine.dev/src/pages/dates/mini-calendar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ The default value is `7`.

<Demo data={MiniCalendarDemos.numberOfDays} />

## withWeekday

Use `withWeekday` prop to display weekday label (Mon, Tue). The default value is `false`.

<Demo data={MiniCalendarDemos.withWeekday} />

## weekdayFormat

Use `weekdayFormat` prop to change [dayjs format](https://day.js.org/docs/en/display/format) of week day label. The default value is `ddd`.

<Demo data={MiniCalendarDemos.weekdayFormat} />

## getDayProps

Use `getDayProps` to add custom props to days, for example, assign styles to weekends:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useState } from 'react';
import { MiniCalendar } from '@mantine/dates';
import { MantineDemo } from '@mantinex/demo';

const code = `
import { useState } from 'react';
import { MiniCalendar } from '@mantine/dates';

function Demo() {
const [value, onChange] = useState<string | null>('2025-12-29');
return <MiniCalendar value={value} onChange={onChange} withWeekday weekdayFormat="dddd" />;
}
`;

function Demo() {
const [value, onChange] = useState<string | null>('2025-12-29');
return <MiniCalendar value={value} onChange={onChange} withWeekday weekdayFormat="dddd" />;
}

export const weekdayFormat: MantineDemo = {
type: 'code',
component: Demo,
code,
centered: true,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useState } from 'react';
import { MiniCalendar } from '@mantine/dates';
import { MantineDemo } from '@mantinex/demo';

const code = `
import { useState } from 'react';
import { MiniCalendar } from '@mantine/dates';

function Demo() {
const [value, onChange] = useState<string | null>('2025-12-29');
return <MiniCalendar value={value} onChange={onChange} withWeekday />;
}
`;

function Demo() {
const [value, onChange] = useState<string | null>('2025-12-29');
return <MiniCalendar value={value} onChange={onChange} withWeekday />;
}

export const withWeekday: MantineDemo = {
type: 'code',
component: Demo,
code,
centered: true,
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@ export const Demo_minMax = {
name: '⭐ Demo: minMax',
render: renderDemo(demos.minMax),
};

export const Demo_withWeekday = {
name: '⭐ Demo: withWeekday',
render: renderDemo(demos.withWeekday),
};

export const Demo_weekdayFormat = {
name: '⭐ Demo: weekdayFormat',
render: renderDemo(demos.weekdayFormat),
};
2 changes: 2 additions & 0 deletions packages/@docs/demos/src/demos/dates/MiniCalendar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export { locale } from './MiniCalendar.demo.locale';
export { numberOfDays } from './MiniCalendar.demo.numberOfDays';
export { getDayProps } from './MiniCalendar.demo.getDayProps';
export { minMax } from './MiniCalendar.demo.minMax';
export { withWeekday } from './MiniCalendar.demo.withWeekday';
export { weekdayFormat } from './MiniCalendar.demo.weekdayFormat';
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const MiniCalendarStylesApi: StylesApiData<MiniCalendarFactory> = {
control: 'Button in the dropdown which is used to select hours/minutes/seconds/am-pm',
days: 'Days container',
day: 'Single day element',
dayWeekday: 'Weekday label (e.g., Mon, Tue)',
dayMonth: 'Day element in month view',
dayNumber: 'Day number element',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@
opacity: 0.65;
}

.dayWeekday {
font-size: 0.7em;
font-weight: 400;
opacity: 0.5;
}

.dayNumber {
font-size: 0.9em;
font-weight: 500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,19 @@ export function DisabledDay() {
</div>
);
}

export function WithDayOfWeek() {
return (
<div style={{ padding: 40 }}>
<MiniCalendar size="xl" withWeekday />
</div>
);
}

export function WithFullDayName() {
return (
<div style={{ padding: 40 }}>
<MiniCalendar size="xl" withWeekday weekdayFormat="dddd" />
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { MiniCalendar, MiniCalendarProps, MiniCalendarStylesNames } from './Mini
const defaultProps: MiniCalendarProps = {
nextControlProps: { 'aria-label': 'next' },
previousControlProps: { 'aria-label': 'previous' },
withWeekday: true,
};

describe('@mantine/dates/MiniCalendar', () => {
Expand All @@ -19,7 +20,7 @@ describe('@mantine/dates/MiniCalendar', () => {
classes: true,
refType: HTMLDivElement,
displayName: '@mantine/dates/MiniCalendar',
stylesApiSelectors: ['root', 'control', 'days', 'day', 'dayMonth', 'dayNumber'],
stylesApiSelectors: ['root', 'control', 'days', 'day', 'dayWeekday', 'dayMonth', 'dayNumber'],
});

it('displays given date range', () => {
Expand Down Expand Up @@ -146,4 +147,29 @@ describe('@mantine/dates/MiniCalendar', () => {
expect(container.querySelector('[data-test-previous]')).toBeInTheDocument();
expect(container.querySelector('[data-test-next]')).toBeInTheDocument();
});

it('supports withWeekday', () => {
const { rerender } = render(
<MiniCalendar {...defaultProps} date="2025-01-01" numberOfDays={1} withWeekday={false} />
);

expect(screen.queryByText('Wed')).not.toBeInTheDocument();

rerender(<MiniCalendar {...defaultProps} date="2025-01-01" numberOfDays={1} withWeekday />);
expect(screen.getByText('Wed')).toBeInTheDocument();
});

it('supports weekdayFormat', () => {
render(
<MiniCalendar
{...defaultProps}
date="2025-01-01"
numberOfDays={1}
withWeekday
weekdayFormat="dddd"
/>
);

expect(screen.getByText('Wednesday')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type MiniCalendarStylesNames =
| 'control'
| 'days'
| 'day'
| 'dayWeekday'
| 'dayMonth'
| 'dayNumber';

Expand Down Expand Up @@ -63,6 +64,12 @@ export interface MiniCalendarProps
/** Dayjs format string for month label @default `MMM` */
monthLabelFormat?: string;

/** Display day of week in date cells @default false */
withWeekday?: boolean;

/** dayjs format string for weekday label @default 'ddd' */
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent capitalization of 'dayjs' in JSDoc comments. Line 64 uses 'Dayjs' (capitalized) for monthLabelFormat, while line 70 uses 'dayjs' (lowercase) for weekdayFormat. These should be consistent. Since the library is officially named 'Day.js' but imported as 'dayjs', using lowercase 'dayjs' would be more consistent with the actual code.

Copilot uses AI. Check for mistakes.
Copy link
Author

@ishmamur-rahman-sazim ishmamur-rahman-sazim Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rtivital Copilot suggests to update Dayjs to dayjs in the JSDoc comment for monthLabelFormat L:63 in MiniCalendar.tsx.
Since this is unrelated to the PR scope, is it necessary to address this now, or can we add this as part of a general documentation cleanup?

weekdayFormat?: string;

/** Called when the next button is clicked */
onNext?: () => void;

Expand Down Expand Up @@ -96,6 +103,8 @@ const defaultProps = {
size: 'sm',
numberOfDays: 7,
monthLabelFormat: 'MMM',
withWeekday: false,
weekdayFormat: 'ddd',
} satisfies Partial<MiniCalendarProps>;

const varsResolver = createVarsResolver<MiniCalendarFactory>((_theme, { size }) => ({
Expand Down Expand Up @@ -126,6 +135,8 @@ export const MiniCalendar = factory<MiniCalendarFactory>((_props, ref) => {
minDate,
maxDate,
monthLabelFormat,
withWeekday,
weekdayFormat,
nextControlProps,
previousControlProps,
locale,
Expand Down Expand Up @@ -204,6 +215,9 @@ export const MiniCalendar = factory<MiniCalendarFactory>((_props, ref) => {
style: dayProps?.style,
})}
>
{withWeekday && (
<span {...getStyles('dayWeekday')}>{date.locale(_locale).format(weekdayFormat)}</span>
)}
<span {...getStyles('dayMonth')}>{date.locale(_locale).format(monthLabelFormat)}</span>
<span {...getStyles('dayNumber')}>{date.date()}</span>
</UnstyledButton>
Expand Down
Loading