TeamWertarbyte / material-ui-search-bar

Material design search bar
https://mui.wertarbyte.com/#material-ui-search-bar
MIT License
261 stars 82 forks source link

Move SearchIcon to the left #84

Open chaos87 opened 4 years ago

chaos87 commented 4 years ago

Hi there,

First, thanks for the search bar, it works great for my use case!

One thing troubles me a tiny bit, I would like to move the Search Icon to the left side of the bar while keeping the Clear Icon on the right side. Now both Clear Icon and Search Icon are on the right side and they overlap each other rendering search icon useless when user inputs something.

I'm pretty sure it should be an easy code change, but have not been able to achieve it.

Thanks!

jersrej commented 4 years ago

+1 for this

rofrol commented 3 years ago

You can try with

  searchIconButton: {
    display: 'none'
  },

and add search icon on the left

or

const useStyles = makeStyles((theme) => ({
  searchContainer: {
    order: 2,
    border: '1px solid green'
  },
  searchIconButton: {
    order: 1,
    '& + *': { /* to select clear icon button */
      border: '1px solid pink',
      order: 2
    }
  }
}

return <SearchBar classes={{ searchContainer: classes.searchContainer, searchIconButton: classes.searchIconButton }} />