Can't load @mui/x-date-pickers as a custom component
See original GitHub issueDuplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯

Expected behavior 🤔
It renders like https://mui.com/x/react-date-pickers/date-picker/#basic-usage

Steps to reproduce 🕹
Steps:
or
- Create a custom component with:
import * as React from "react";
import { createComponent } from "@mui/toolpad-core";
import { TextField } from "@mui/material";
import {
AdapterDateFns,
LocalizationProvider,
DatePicker,
} from "https://esm.sh/@mui/x-date-pickers@5.0.0-alpha.3";
export interface DatePickerRootProps {
msg: string;
}
function DatePickerRoot({ msg }: DatePickerRootProps) {
const [value, setValue] = React.useState<Date | null>(null);
return (
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DatePicker
label="Basic example"
value={value}
onChange={(newValue) => {
setValue(newValue);
}}
renderInput={(params) => <TextField {...params} />}
/>
</LocalizationProvider>
);
}
DatePickerRoot.defaultProps = {
msg: "Hello world!",
};
export default createComponent(DatePickerRoot, {
argTypes: {
msg: { typeDef: { type: "string" } },
},
});
Context 🔦
I need a date picker for my license key generator:

Your environment 🌎
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Date picker, Time picker React components
Date pickers and Time pickers allow selecting a single value from a pre-determined set. On mobile, pickers are best suited for display in...
Read more >material ui lab date picker, Can't resolve '@ ...
This works for me very well npm install @mui/lab. In Material UI v5 you need to install @mui/lab.My dependencies are here :
Read more >Date picker component
v-date-picker is a fully featured date selection component that lets users select a date, or range of dates. # Usage. Date pickers come...
Read more >React 17 Material-UI Datepicker and Timepicker Example ...
For using the Datepicker component, we also need to install the Material UI ... Import MuiPickersUtilsProvider and KeyboardDatePicker from ...
Read more >The Ultimate MUI v5 DatePicker and TimePicker Tutorial (Plus ...
MUI recently changed the import location for the DatePicker component. It is now imported from @mui/x-date-pickers . Here are the imports needed ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yep, this illustrates well what we discussed in our last retro. Components imported from urls will have to depend on
react
. In this case esm.sh rewrites the import to one that lives on the CDN itself (see https://cdn.esm.sh/v78/@mui/x-date-pickers@5.0.0-alpha.3/es2022/x-date-pickers.js). So it brings in its own instance of thereact
module. It’s currently behaving as expected. We could look into what should be the behavior if your imported code tries to import a bare module identifier, but it’s going to raise questions about versioning and backwards compatibility.Regarding
@mui/...
packages, besides providing their components in the visual editor, I think we should also allow importing them using bare imports in custom componentsedit:
another example:
@Janpot Thanks, I have used this version in the end:
https://master--toolpad.mui.com/_toolpad/app/cl4hla83p01949xoizo5uxf2a/codeComponents/g823nzp