Repository navigation
[number field] Create component from the Base UI equivalent - #49275
silviuaavram wants to merge 135 commits into
Conversation
Deploy previewBundle size
PerformanceNo regressions in 32 benchmarks · precise to ±9.4% (±13.4% at worst) · ran 4m 06s · details Check out the code infra dashboard for more information about this PR. |
56d2061 to
61da9c7
Compare
9612ca1 to
e560e35
Compare
6f0fedf to
9eb8215
Compare
88b9934 to
1325c6b
Compare
996ea52 to
de7a45f
Compare
2912491 to
0a41b99
Compare
fb79a33 to
8cf2564
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The color and size PropTypes validators reject supported custom values, causing development warnings on React versions that check PropTypes.
2 open issues
1 file not reviewed
pnpm-lock.yaml: Generated file
What changed in this PR
Promotes the documentation’s NumberField example into a public Material UI component, addressing #48335. It combines Base UI numeric behavior with Material inputs, form styling, and customization APIs.
Changes:
- Adds NumberField with three variants, numeric formatting, stepping, scrubbing, typed slots, and theme integration.
- Replaces copy-and-paste implementations with component demos and generated API documentation.
- Adds public-type and augmentation checks, adapts documentation tests, and coordinates ButtonBase keyboard cancellation with Base UI.
| File | Description |
|---|---|
| test/moduleAugmentation/material/numberFieldCustomProps.tsconfig.json | Isolates augmentation checks. |
| test/moduleAugmentation/material/numberFieldCustomProps.spec.tsx | Checks custom props, slots, and theme types. |
| test/e2e-website/demo-docs-production.spec.ts | Moves multi-file demo checks to Autocomplete. |
| pnpm-lock.yaml | Records the Material package’s Base UI dependency. |
| packages/mui-material/src/styles/props.ts | Registers NumberField theme prop types. |
| packages/mui-material/src/styles/overrides.ts | Registers NumberField style override keys. |
| packages/mui-material/src/styles/components.ts | Adds NumberField theme configuration. |
| packages/mui-material/src/NumberField/utils/useUtilityClasses.ts | Composes NumberField utility classes. |
| packages/mui-material/src/NumberField/utils/resolveInputProps.ts | Resolves native prop precedence before merging. |
| packages/mui-material/src/NumberField/utils/index.ts | Exports internal helpers. |
| packages/mui-material/src/NumberField/utils/getControlElements.tsx | Places controls in input adornments. |
| packages/mui-material/src/NumberField/NumberFieldRootSlot.tsx | Composes form structure and initial label state. |
| packages/mui-material/src/NumberField/NumberFieldInputSlot.tsx | Integrates Material inputs, controls, and scrubbing. |
| packages/mui-material/src/NumberField/numberFieldClasses.ts | Defines public utility classes. |
| packages/mui-material/src/NumberField/NumberFieldButtonSlot.tsx | Merges button behavior, refs, and state. |
| packages/mui-material/src/NumberField/NumberField.types.ts | Defines public props and slot types. |
| packages/mui-material/src/NumberField/NumberField.tsx | Implements the public component. |
| packages/mui-material/src/NumberField/NumberField.spec.tsx | Checks public TypeScript contracts. |
| packages/mui-material/src/NumberField/index.ts | Exports component, types, and classes. |
| packages/mui-material/src/internal/svg-icons/Remove.tsx | Adds the decrement icon. |
| packages/mui-material/src/internal/svg-icons/OpenInFull.tsx | Adds the scrub cursor icon. |
| packages/mui-material/src/internal/svg-icons/ImportExport.tsx | Adds the scrub handle icon. |
| packages/mui-material/src/InputAdornment/InputAdornment.d.ts | Adds a NumberField demo documentation link. |
| packages/mui-material/src/Input/Input.d.ts | Adds a NumberField demo documentation link. |
| packages/mui-material/src/index.js | Exports NumberField from the package. |
| packages/mui-material/src/index.d.ts | Exports NumberField declarations. |
| packages/mui-material/src/FormLabel/FormLabel.d.ts | Removes the obsolete demo documentation link. |
| packages/mui-material/src/FilledInput/FilledInput.d.ts | Adds a NumberField demo documentation link. |
| packages/mui-material/src/ButtonBase/useButtonBase.ts | Honors Base UI keyboard-handler cancellation. |
| packages/mui-material/src/Button/Button.d.ts | Removes the obsolete demo documentation link. |
| packages/mui-material/package.json | Adds Base UI and the NumberField entry point. |
| docs/translations/api-docs/number-field/number-field.json | Adds API descriptions. |
| docs/public/static/error-codes.json | Registers the invalid control-position error. |
| docs/pages/material-ui/api/number-field.json | Adds generated API metadata. |
| docs/pages/material-ui/api/number-field.js | Adds the API page. |
| docs/pages/material-ui/api/input.json | Adds the NumberField demo link. |
| docs/pages/material-ui/api/input-adornment.json | Adds the NumberField demo link. |
| docs/pages/material-ui/api/form-label.json | Removes the obsolete demo link. |
| docs/pages/material-ui/api/filled-input.json | Adds the NumberField demo link. |
| docs/pages/material-ui/api/button.json | Removes the obsolete demo link. |
| docs/pages/experiments/number-field.tsx | Adds a manual integration playground. |
| docs/data/material/pagesApi.js | Registers the NumberField API route. |
| docs/data/material/components/number-field/number-field.md | Documents the component and customization APIs. |
| docs/data/material/components/number-field/demos/validation/ValidationNumberField.tsx | Demonstrates controlled validation. |
| docs/data/material/components/number-field/demos/validation/index.ts | Registers the validation demo. |
| docs/data/material/components/number-field/demos/validation/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/theme/NumberFieldTheme.tsx | Demonstrates theme defaults and overrides. |
| docs/data/material/components/number-field/demos/theme/index.ts | Registers the theme demo. |
| docs/data/material/components/number-field/demos/theme/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/steps/NumberFieldSteps.tsx | Demonstrates steps, modifiers, and snapping. |
| docs/data/material/components/number-field/demos/steps/index.ts | Registers the stepping demo. |
| docs/data/material/components/number-field/demos/steps/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/state/NumberFieldState.tsx | Demonstrates values and commit callbacks. |
| docs/data/material/components/number-field/demos/state/index.ts | Registers the state demo. |
| docs/data/material/components/number-field/demos/state/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/stacked-controls/StackedNumberField.tsx | Demonstrates stacked chevron controls. |
| docs/data/material/components/number-field/demos/stacked-controls/index.ts | Registers the stacked-controls demo. |
| docs/data/material/components/number-field/demos/stacked-controls/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/spinner-demo/SpinnerDemo.tsx | Rebuilds the spinner using NumberField. |
| docs/data/material/components/number-field/demos/spinner-demo/NumberSpinner.tsx | Removes the standalone spinner implementation. |
| docs/data/material/components/number-field/demos/sizes/NumberFieldSizes.tsx | Demonstrates sizes across variants. |
| docs/data/material/components/number-field/demos/sizes/index.ts | Registers the sizes demo. |
| docs/data/material/components/number-field/demos/sizes/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/scrub-area-placement/NumberFieldScrubAreaPlacement.tsx | Demonstrates independent handle placement. |
| docs/data/material/components/number-field/demos/scrub-area-placement/index.ts | Registers the placement demo. |
| docs/data/material/components/number-field/demos/scrub-area-placement/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/scrub-area-options/NumberFieldScrubAreaOptions.tsx | Demonstrates drag direction and sensitivity. |
| docs/data/material/components/number-field/demos/scrub-area-options/index.ts | Registers the scrub-options demo. |
| docs/data/material/components/number-field/demos/scrub-area-options/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/scrub-area-customization/index.ts | Registers the scrub-customization demo. |
| docs/data/material/components/number-field/demos/scrub-area-customization/CustomizedNumberFieldScrubArea.tsx | Demonstrates custom handles and cursors. |
| docs/data/material/components/number-field/demos/scrub-area-customization/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/full-width/index.ts | Registers the full-width demo. |
| docs/data/material/components/number-field/demos/full-width/FullWidthNumberField.tsx | Demonstrates container-width sizing. |
| docs/data/material/components/number-field/demos/full-width/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/format/index.ts | Registers the formatting demo. |
| docs/data/material/components/number-field/demos/format/FormattedNumberFields.tsx | Demonstrates localized currencies and percentages. |
| docs/data/material/components/number-field/demos/format/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/form/NumberFieldForm.tsx | Demonstrates submission and controlled reset. |
| docs/data/material/components/number-field/demos/form/index.ts | Registers the form demo. |
| docs/data/material/components/number-field/demos/form/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/form-props/index.ts | Registers the form-props demo. |
| docs/data/material/components/number-field/demos/form-props/FormPropsNumberFields.tsx | Demonstrates required, disabled, and read-only states. |
| docs/data/material/components/number-field/demos/form-props/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/field-demo/NumberField.tsx | Removes the standalone field implementation. |
| docs/data/material/components/number-field/demos/field-demo/index.ts | Removes the obsolete demo registration. |
| docs/data/material/components/number-field/demos/field-demo/FieldDemo.tsx | Removes the previous field demo. |
| docs/data/material/components/number-field/demos/controls-position/NumberFieldControlPositions.tsx | Demonstrates start, end, and split controls. |
| docs/data/material/components/number-field/demos/controls-position/index.ts | Registers the control-position demo. |
| docs/data/material/components/number-field/demos/controls-position/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/constraints/NumberFieldConstraints.tsx | Demonstrates bounds and out-of-range input. |
| docs/data/material/components/number-field/demos/constraints/index.ts | Registers the constraints demo. |
| docs/data/material/components/number-field/demos/constraints/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/color/NumberFieldColors.tsx | Demonstrates focus colors. |
| docs/data/material/components/number-field/demos/color/index.ts | Registers the color demo. |
| docs/data/material/components/number-field/demos/color/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/basic/index.ts | Registers the basic demo. |
| docs/data/material/components/number-field/demos/basic/client.ts | Adds its client boundary. |
| docs/data/material/components/number-field/demos/basic/BasicNumberFields.tsx | Demonstrates the three variants. |
| docs/data/material/components/number-field/demos/adornments/NumberFieldAdornments.tsx | Demonstrates consumer prefixes and suffixes. |
| docs/data/material/components/number-field/demos/adornments/index.ts | Registers the adornments demo. |
| docs/data/material/components/number-field/demos/adornments/client.ts | Simplifies the client-provider export. |
Review effort: Balanced
|
@claude review xhigh |
PR reviewThis adds a large new public component ( Verification limits: Bugs (7)1. 🔴
|
|
@claude review xhigh |
fa329d1 to
a6a6770
Compare

Closes #48335
Adds
@mui/material/NumberField, replacing the docs-only implementation. Base UI handles numeric input, formatting, and stepping. Material UI provides the input variants, labels, controls, and theme integration.Documentation preview
Features
TextFieldsizing, withhiddenLabelavailable as an opt-in.onValueChangeandonValueCommittedreceive a number ornulland adetails.reasonidentifying the interaction. Text edits commit on blur, keyboard and wheel steps commit immediately, and pointer adjustments commit on release.controlsPositionplaces the stepper buttons at the end (default), splits them across both sides, stacks them as chevrons, or hides them withfalse.scrubAreaPositionindependently places a drag handle at the start or end.startAdornmentandendAdornmentaccept text, icons, or buttons directly. For example,startAdornment="$"andendAdornment="/hr"display an hourly rate. Adornments sit closest to the editable input when they share a side with a scrub handle or stepper, and stay mounted when the controls move.sx, andMuiNumberFieldtheme overrides support customization. The root and slotrenderprops change the rendered element while preserving Material styling and Base UI behavior.Base UI component mapping
RootrootFormControland owns numeric state and form submission.Groupinputrole="group"without an extra wrapper.InputhtmlInputIncrement/DecrementincrementButton/decrementButtonIconButtonwith plus/minus icons or stacked chevrons.ScrubAreascrubAreaScrubAreaCursorscrubAreaCursorMaterial UI supplies the
inputLabel,formHelperText, andcontrolsslots. Split controls reuse thecontrolsslot on each side, withownerState.positionidentifying which side is rendering. Consumer adornment wrappers can be styled withMuiNumberField-startAdornmentandMuiNumberField-endAdornment. The scrub handle and cursor are customized through their own slots.Implementation and suggested review order
Files are under
packages/mui-material/src/NumberField/.NumberField.types.tsandNumberField.tsxNumberFieldRootSlot.tsxFormControlcomposition, label and helper text associations, and initial filled and adorned state during SSR.NumberFieldInputSlot.tsxandNumberFieldInputRootSlot.tsxNumberFieldControlsSlot.tsx,NumberFieldButtonSlot.tsx, andNumberFieldScrubAreaSlot.tsxRenderElement.tsxandutils/resolveInputProps.tsrenderhandling, slot replacement precedence, and native input prop resolution.Set
namedirectly onNumberFieldto submit the unformatted value once. A field displaying$5.00submits"5". Supplyingnameonly through an input slot triggers a development warning. The forwardedreftargets theFormControlroot, andinputReftargets the visible input.Shared changes
@base-ui/react@^1.9.0with deep imports.Documentation and validation
The 18 demos cover variants, formatting, constraints, control placement, scrubbing, adornments, forms, rendering, and theme customization. The anatomy section shows the rendered HTML, including the input group and its label and helper text associations.
Interaction tests verify callback values and reasons for typing, clearing, pasting, blurring, keyboard steps, button presses, wheel steps, and dragging. Other tests cover slot replacement, event and ref composition, form submission, SSR and hydration, and public types.
Visual regression coverage includes all 18 demos and four additional fixtures for empty fields, unlabeled filled fields alongside
TextField, stacked controls at a larger font size, and filled split controls with an end scrub handle. The PR’s unit, browser, type, lint, and regression checks passed.Known limitations
onReset. Base UI #1346:last-child. The anatomy docs recommendgapon the parent to space adjacent fields. Base UI follow-up