mui / mui/material-ui

Standardize Components with options

Open
#45,269 2 comments 10 reactions 1 assignee View on GitHub

@DiegoAndai is already working on this.

Since Feb 10, 2025.

scope: autocomplete scope: select scope: tabs type: enhancement waiting for 👍
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Summary

There are various ways to present a list of options to users, each with its own use case. Some common choices include Autocomplete, Select, Radio Group, Checkbox Group, Button Group, and Tabs. While they serve different purposes, they all ultimately allow users to make a selection from a given list.

To improve the developer experience, I’d love to see a more consistent API across these components. For now, I want to focus on two key differences, though this idea could be extended further.

Standardized API for Options

Currently, different components handle options inconsistently. For example, Autocomplete accepts an options prop along with getOptionKey and getOptionLabel, while Select requires its options to be passed as MenuItem children. Instead, all these components—Autocomplete, Select, Radio Group, Checkbox Group, Button Group, and Tabs—should support a unified API with options, getOptionKey, getOptionValue, and renderOption. This would streamline usage and improve maintainability.

Flexible Value Handling

Another inconsistency lies in how selected values are managed. In a Select component, the value is just the key of the selected option. However, an Autocomplete requires the entire object. In real-world forms, relationships between data often require pre-filling fields with default values, which can mean fetching additional data just to display an Autocomplete's value properly. To address this, these components should support both approaches:

  • One mode where they accept and return the entire object (onChange provides the full option, and default values must be full objects).
  • Another mode where they work solely with keys (onChange returns only the key, and default values can be set with just the key).

Standardizing these aspects would make working with these components far more intuitive and flexible across different use cases.

Search keywords: select,autocomplete,tabs,groups

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.