diff --git a/docs/data/date-pickers/custom-field/MultiInputFieldTextFieldProps.js b/docs/data/date-pickers/custom-field/MultiInputFieldTextFieldProps.js new file mode 100644 index 0000000000000..dba43392856db --- /dev/null +++ b/docs/data/date-pickers/custom-field/MultiInputFieldTextFieldProps.js @@ -0,0 +1,24 @@ +import * as React from 'react'; +import dayjs from 'dayjs'; +import { DemoContainer } from '@mui/x-date-pickers/internals/demo'; +import { LocalizationProvider } from '@mui/x-date-pickers-pro'; +import { AdapterDayjs } from '@mui/x-date-pickers-pro/AdapterDayjs'; +import { DateRangePicker } from '@mui/x-date-pickers-pro/DateRangePicker'; + +export default function MultiInputFieldTextFieldProps() { + return ( + + + ({ + color: position === 'start' ? 'success' : 'warning', + focused: true, + }), + }} + defaultValue={[dayjs('2022-04-17'), null]} + /> + + + ); +} diff --git a/docs/data/date-pickers/custom-field/MultiInputFieldTextFieldProps.tsx b/docs/data/date-pickers/custom-field/MultiInputFieldTextFieldProps.tsx new file mode 100644 index 0000000000000..dba43392856db --- /dev/null +++ b/docs/data/date-pickers/custom-field/MultiInputFieldTextFieldProps.tsx @@ -0,0 +1,24 @@ +import * as React from 'react'; +import dayjs from 'dayjs'; +import { DemoContainer } from '@mui/x-date-pickers/internals/demo'; +import { LocalizationProvider } from '@mui/x-date-pickers-pro'; +import { AdapterDayjs } from '@mui/x-date-pickers-pro/AdapterDayjs'; +import { DateRangePicker } from '@mui/x-date-pickers-pro/DateRangePicker'; + +export default function MultiInputFieldTextFieldProps() { + return ( + + + ({ + color: position === 'start' ? 'success' : 'warning', + focused: true, + }), + }} + defaultValue={[dayjs('2022-04-17'), null]} + /> + + + ); +} diff --git a/docs/data/date-pickers/custom-field/MultiInputFieldTextFieldProps.tsx.preview b/docs/data/date-pickers/custom-field/MultiInputFieldTextFieldProps.tsx.preview new file mode 100644 index 0000000000000..fdd2643d75f3e --- /dev/null +++ b/docs/data/date-pickers/custom-field/MultiInputFieldTextFieldProps.tsx.preview @@ -0,0 +1,9 @@ + ({ + color: position === 'start' ? 'success' : 'warning', + focused: true, + }), + }} + defaultValue={[dayjs('2022-04-17'), null]} +/> \ No newline at end of file diff --git a/docs/data/date-pickers/custom-field/custom-field.md b/docs/data/date-pickers/custom-field/custom-field.md index b6f21c3ab9957..f16a6f3ec7ae8 100644 --- a/docs/data/date-pickers/custom-field/custom-field.md +++ b/docs/data/date-pickers/custom-field/custom-field.md @@ -23,6 +23,12 @@ You can use the `fieldSeparator` slot to pass custom props to the `Typography` r {{"demo": "MultiInputFieldSeparatorSlotProps.js"}} +### Customize the `start` and `end` fields differently [](/x/introduction/licensing/#pro-plan 'Pro plan') + +You can pass conditional props to the `textField` slot to customize the input styling based on the `position`. + +{{"demo": "MultiInputFieldTextFieldProps.js"}} + ### Use single input fields on range pickers [](/x/introduction/licensing/#pro-plan 'Pro plan') You can pass the single input fields to the range picker to use it for keyboard editing: diff --git a/docs/data/date-pickers/date-range-picker/date-range-picker.md b/docs/data/date-pickers/date-range-picker/date-range-picker.md index ce3792537a4e3..ccbc5864cead4 100644 --- a/docs/data/date-pickers/date-range-picker/date-range-picker.md +++ b/docs/data/date-pickers/date-range-picker/date-range-picker.md @@ -88,7 +88,7 @@ You can pass the `SingleInputDateRangeField` component to the Date Range Picker {{"demo": "SingleInputDateRangePicker.js"}} :::info -For more information, check out the [Custom field](/x/react-date-pickers/custom-field/#use-single-input-fields-on-range-pickers) page. +You can find more information in a [dedicated documentation page section](/x/react-date-pickers/custom-field/#use-single-input-fields-on-range-pickers). ::: ### Add shortcuts @@ -97,6 +97,10 @@ To simplify range selection, you can add [shortcuts](/x/react-date-pickers/short {{"demo": "BasicRangeShortcuts.js", "bg": "inline", "defaultCodeOpen": false}} +### Customize the field + +You can find the documentation in the [Custom field page](/x/react-date-pickers/custom-field/). + ## Validation You can find the documentation in the [Validation page](/x/react-date-pickers/validation/).