You've already forked matrix-react-sdk
							
							
				mirror of
				https://github.com/matrix-org/matrix-react-sdk.git
				synced 2025-10-31 01:45:39 +03:00 
			
		
		
		
	* extend svg module Signed-off-by: Kerry Archibald <kerrya@element.io> * POC in QuickSettingsButton Signed-off-by: Kerry Archibald <kerrya@element.io> * stylelint Signed-off-by: Kerry Archibald <kerrya@element.io> * update copyright Signed-off-by: Kerry Archibald <kerrya@element.io> * remove aria-hidden, quick docs Signed-off-by: Kerry Archibald <kerrya@element.io>
		
			
				
	
	
	
		
			1.1 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			1.1 KiB
		
	
	
	
	
	
	
	
Icons
Icons are loaded using @svgr/webpack. This is configured in element-web
Each .svg exports a ReactComponent at the named export Icon.
Icons have role="presentation" and aria-hidden automatically applied. These can be overriden by passing props to the icon component.
eg
import { Icon as FavoriteIcon } from 'res/img/element-icons/favorite.svg';
const MyComponent = () => {
    return <>
        <FavoriteIcon>
        <FavoriteIcon className="mx_MyComponent-icon" role="img" aria-hidden="false">
    </>;
}
Styling
Icon components are svg elements and can be styled as usual.
// _MyComponents.scss
.mx_MyComponent-icon {
    height: 20px;
    width: 20px;
    * {
        fill: $accent;
    }
}
// MyComponent.tsx
import { Icon as FavoriteIcon } from 'res/img/element-icons/favorite.svg';
const MyComponent = () => {
    return <>
        <FavoriteIcon>
        <FavoriteIcon className="mx_MyComponent-icon" role="img" aria-hidden="false">
    </>;
}