Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pickers] Expose Required Prop #16449

Closed
sayedMurtadha opened this issue Feb 4, 2025 · 1 comment
Closed

[pickers] Expose Required Prop #16449

sayedMurtadha opened this issue Feb 4, 2025 · 1 comment
Labels
component: pickers This is the name of the generic UI component, not the React module! duplicate This issue or pull request already exists new feature New feature or request

Comments

@sayedMurtadha
Copy link

sayedMurtadha commented Feb 4, 2025

Summary

In the pickers, if you want to mark the input field as required to get the HTML5 validation and the visual indication (*) of a required input field, you can use the slotProps.

What I would expect as a user of other MUI components is the required prop exposed to the pickers API directly instead of going down in the slotProps especially since it is directly related to the input and not a custom prop that would need to be hidden.

Examples

The below example shows how to do it for the DatePicker:

<DatePicker
  label="Example picker" 
  slotProps={{
    textField: {
      required: true,
    }
  }}
/>

The desired usage looks like below:

<DatePicker
  label="Example picker" 
  required
/>

Motivation

Consistency with other MUI material inputs and limiting any future backward incompatibility issues caused by a change in the underlying slots being used.

Search keywords: required, picker

@sayedMurtadha sayedMurtadha added new feature New feature or request status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 4, 2025
@zannager zannager added the component: pickers This is the name of the generic UI component, not the React module! label Feb 5, 2025
@LukasTy
Copy link
Member

LukasTy commented Feb 6, 2025

Hello @sayedMurtadha, thank you for creating this issue. 👍
It looks like we already have an issue targetting this problem: #7633.
I'm closing this one as duplicate. 😉

@LukasTy LukasTy closed this as completed Feb 6, 2025
@LukasTy LukasTy added duplicate This issue or pull request already exists and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! duplicate This issue or pull request already exists new feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants