Skip to main content

Migrate to the Polaris date field component

The Polaris date field component provides a text input with a calendar picker for selecting dates. It replaces the previous DateField component and is available as <s-date-field> in API versions 2025-10 and newer.


The following properties are different in the Polaris date field component.

The previous DateField readonly prop is now called readOnly (camelCase).

The previous DateField yearMonth prop is now called view. It takes a YYYY-MM string instead of a {year, month} object.

The previous DateField defaultYearMonth prop is now called defaultView. It takes a YYYY-MM string.

The previous disabled prop behavior has changed. Setting disabled to true still disables the entire field. For disabling specific dates or days, use the new disallow and disallowDays props.

Previous patternNew patternMigration notes
disabled={true}disabledNo change needed.
disabled={['2024-12-25', '2024-12-26']}disallow="2024-12-25,2024-12-26"Specific dates use comma-separated string in disallow.
disabled={['Sunday', 'Saturday']}disallowDays="sunday,saturday"Days of week use disallowDays.
disabled={[{start: '2024-12-01', end: '2024-12-10'}]}disallow="2024-12-01--2024-12-10"Date ranges use double-dash separator.

Migrating disabled dates

import '@shopify/ui-extensions/preact';
import {render} from 'preact';

export default function extension() {
render(<Extension />, document.body);
}

function Extension() {
return (
<s-date-field
label="Select delivery date"
defaultValue="2024-12-15"
disallowDays="saturday,sunday"
/>
);
}
import {
reactExtension,
DateField,
} from '@shopify/ui-extensions-react/checkout';

export default reactExtension(
'purchase.checkout.block.render',
() => <Extension />,
);

function Extension() {
return (
<DateField
label="Select delivery date"
value="2024-12-15"
disabled={['Saturday', 'Sunday']}
/>
);
}

The previous onYearMonthChange prop is now called onViewChange.

Migrating onYearMonthChange to onViewChange

import '@shopify/ui-extensions/preact';
import {render} from 'preact';

export default function extension() {
render(<Extension />, document.body);
}

function Extension() {
return (
<s-date-field
label="Select date"
defaultValue="2024-12-15"
view="2024-12"
onViewChange={(event) => console.log('View changed', event)}
/>
);
}
import {
reactExtension,
DateField,
} from '@shopify/ui-extensions-react/checkout';

export default reactExtension(
'purchase.checkout.block.render',
() => <Extension />,
);

function Extension() {
return (
<DateField
label="Select date"
value="2024-12-15"
yearMonth={{year: 2024, month: 12}}
onYearMonthChange={({year, month}) =>
console.log('View changed', year, month)
}
/>
);
}

The following properties aren't supported:

  • placeholder — no longer supported, use label instead.

The Polaris date field component introduces the following new properties:

New propTypeDescription
allowstringComma-separated list of allowed dates (whitelist).
allowDaysstringComma-separated list of allowed days of the week.
disallowstringComma-separated list of disallowed dates.
disallowDaysstringComma-separated list of disallowed days of the week.
requiredbooleanWhether the field is required.
autocompletestringAutocomplete attribute for the input.

Was this page helpful?