-
Notifications
You must be signed in to change notification settings - Fork 26
Coding guidelines~SVG imports
Cory Crowley edited this page Mar 9, 2022
·
1 revision
There are three methods for using an SVG image in a React component. The recommended pattern is to use the Fluent UI Image component. Refer to the Svg Test Story component for usage details.
Example:
import { ReactComponent as AccessRestrictedComponent } from '../../Resources/Static/accessRestricted.svg';
import Error from '../../Resources/Static/error.svg';
const SvgTest = () => {
return (
// Fluent UI <Image /> component
<Image src={Error} height={100} /> // Recommended
// HTML <img/> tag
<img src={Error} style={{ height: 100, width: 100 }} />
// Direct react component
<AccessRestrictedComponent />
);
};
If you have a question for one of the project maintainers, please post the question here. We'll get back to you as soon as possible!