[Autocomplete] How to change the fontSize?

See original GitHub issue

fontSize is not applying in AutoComplete. Sample code -
<AutoComplete menuStyle = {{fontSize:14}} listStyle={{fontSize:14}} .. .. />

Versions

  • Material-UI: 0.16.6
  • React: 15.3.1
  • Browser: Chrome

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:17
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
mgvarleycommented, Feb 23, 2017

I got this rendering as I wanted using the following but would be great if a simpler fontSize property was made available to the menu so we don’t have to map and use a MenuItem which feels like overkill for a simple use case such as this:

...
dataSource={results.map((val) => { return {
  text: val.description,
  value: (
    <MenuItem
      primaryText={val.description}
      style={{ fontSize: 15, width: 300, textOverflow: 'ellipsis', overflow: 'hidden' }}
    />
  ) }
})}
...

NB The ellipsis property does not seem to work as expected in this example

2reactions
gicontzcommented, Jan 15, 2021

Using styled-components global style

  1. Use classes property
<AutoComplete
   classes={{ input: 'autoComplete-text', option: 'autoComplete-text'}}
....
/>
  1. Create global style
import { createGlobalStyle } from 'styled-components';

const GlobalStyle = createGlobalStyle`
  .autoCompleteText {
    font-size: 13px;
  }
`;

export default GlobalStyle;
  1. Implement the GlobalStyle on Root Component
function App() {
return (
<ThemeProvider theme={theme}>
        <GlobalStyle/>
 ....

Using global stylesheet, just follow the first step, then import css file to target component or root component

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS AutoComplete font size [duplicate] - Stack Overflow
+1 I have the same issue and it seems that there is no way to prevent that font size change. Probably this should...
Read more >
[Autocomplete] How to change the fontSize? #5861 - GitHub
Can't set font size on autocomplete. IMO, we should never set font-sizes explicitly in MUI. They should be inherited from the theme /...
Read more >
Autofill hover font size - HTML & CSS - SitePoint Forums
I am trying to change the hover font size when users are using the autofill in webkit browsers. For example, when a user...
Read more >
Change Autocomplete Styles in WebKit - CodePen
Change autocomplete styles in WebKit */. 2. input:-webkit-autofill, ... font-size: 2em; ... Change autocomplete styles in WebKit */\\ninput:-webkit-autofill ...
Read more >
Change font size in autocomplete - Devart Forums
Hi Is it possible to change font size in autocomplete window? Thanks Image. Top. 1 post • Page 1 of 1. Return to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found