-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support replacing icons in various elements #22631
Comments
|
@Studio384 I have two questions:
|
Then I've got to say that I'm 100% lost and that this seems like a gap in MUI's documentation on how to do that. Because in regards to Font Awesome; how would I do this? The example given above doesn't work for Select's while it does work in the components listed in "these do work". This seems just inconsistent and could use some better documentation. Right now, MUI just shorts out with the following error:
Which, of course, is correct. |
@Studio384 Right, you have to make sure the provided prop matches the expected type. It can either be an element or a component. |
For anyone looking for a solution for using import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCheck } from '@fortawesome/free-solid-svg-icons/faCheck'
// ... other imports omitted
const SomeStep = () => {
return (
return (
<Step active={false} index={2}>
<StepLabel StepIconComponent={StepDoneIcon}>
{title}
</StepLabel>
<StepContent>
<Typography>
Some Info
</Typography>
</StepContent>
</Step>
)
}
interface FAStepIconProps extends StepIconProps {
faIcon: IconDefinition
}
const FAStepIcon = ({faIcon, active}: FAStepIconProps) => {
const theme = useTheme()
return (
<Box sx={{
backgroundColor: active ? theme.palette.primary.main : theme.palette.grey['300'],
borderRadius: 9999,
padding: '2px',
ml: '-2px'
}}>
<FontAwesomeIcon color="white" fixedWidth size="lg" icon={faIcon} />
</Box>
)
}
const StepDoneIcon = (props: StepIconProps) => {
return (
<FAStepIcon {...props} faIcon={faCheck} />
)
} |
Summary 馃挕
Some of the components in Material UI ship with built-in icons from the Material Design Icon set and only provide an option to replace them with other icons that don't require a component as Font Awesome does.
Examples 馃寛
In case of Font Awesome, the following would be required to render the icon, but Material UI doesn't allow this.
These are the places with the behavior I'd expect:
Breadcrumbs
'sseperator
propertyButton
'sstartIcon
andendIcon
propertyBottomNavigationAction
'sicon
propertyTab
'sicon
propertyAccordionSummary
'sexpandIcon
propertyChip
'sicon
anddeleteIcon
propertyThese components have icons that either can only be replaced with MUI icons or not at all:
StepLabel
Select
TablePagination
I'm sure I missed of others.
Motivation 馃敠
We use MUI, but are not looking to have Material Design as our design system. We're now stuck with using 2 iconsets; the iconset we use everywhere (being Font Awesome), and the iconset used by Material UI-components that don't allow for icons to be replaced.
My appologies if I'm overlooking something here.
The text was updated successfully, but these errors were encountered: