Support custom search icons in SearchBox
Bug Report
- Package version(s): 5.106.1002
- Browser and OS versions: Chrome/All
Priorities and help requested (not applicable if asking question):
Are you willing to submit a PR to fix? Yes
Requested priority: High
Describe the issue:
Office fabric searchbox, lets us change the icon, by ISearchBoxStyles here: https://developer.microsoft.com/en-us/fabric#/components/searchbox#Variants
But icon has been hardcoded here: https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/office-ui-fabric-react/src/components/SearchBox/SearchBox.base.tsx line 81..
Actual behavior:
Overriding style for SearchBox doesnt work
Expected behavior:
Overriding style for SearchBox should work
@prabhatmuroor Thanks for offering to open a PR. Please do so.
@prabhatmuroor what are you trying to do to the search icon that you cannot do?
https://codepen.io/micahgodbolt/pen/jvqgMm?editors=1010
@micahgodbolt I'm not the original author of the issue, but the missing behavior that I see is the ability to specify a different icon to be rendered. Some other Fabric components accept iconProps where you can specify which icon will be used, not just the styles to be applied to the icon.
This could be a by-design issue though, if you don't want to allow the Searchbox Component to render a different icon than what it does currently.
I'd like to be able to use a different icon (the Filter one specifically) will you take a PR for this?
If so, what approach is preferred:
- Exposing an enum property
searchIconof typeenum SearchBoxIcon { search, filter } - Adding a
searchIconName?: stringproperty. - Adding a
searchIconProps?: IIconPropsproperty (this would be more inline with what is done for theclearButtonPropsproperty. - Something else?
yeah, that's a valid ask. A single prop for iconProps?: IIconProps would allow people to cheaply tweak the icon without a full onRender.
I'm good with that. just go iconProps, as calling it 'search' kinda indicates that it's always search icon