codegouvfr / react-dsfr

🇫🇷 The Frech Government Design system React toolkit
https://react-dsfr.codegouv.studio
MIT License
403 stars 49 forks source link

mui: override autocomplete style #241

Closed ddecrulle closed 5 months ago

ddecrulle commented 5 months ago

Change the global style for mui autocomplete With this code

<MuiDsfrThemeProvider>
            <Autocomplete
                disablePortal
                id="combo-box-demo"
                options={communes}
                sx={{ width: 300 }}
                renderInput={params => <TextField {...params} label="Commencez votre saisie" />}
            />

            <Autocomplete
                disablePortal
                id="combo-box-demo"
                options={communes}
                sx={{ width: 300 }}
                renderInput={({ InputProps, disabled, id, inputProps }) => (
                    <Input
                        ref={InputProps.ref}
                        label="Le label du champ"
                        id={id}
                        disabled={disabled}
                        nativeInputProps={{ ...inputProps, placeholder: "Commencez votre saisie" }}
                    />
                )}
            />
        </MuiDsfrThemeProvider>

Before :

Capture d’écran 2024-03-05 à 17 11 16 Capture d’écran 2024-03-05 à 17 11 29

After :

Capture d’écran 2024-03-05 à 17 03 09 Capture d’écran 2024-03-05 à 17 03 29
garronej commented 5 months ago

Magnifique ça tue!