import * as React from 'react'; import { IImageProps, Image, ImageFit } from '@fluentui/react/lib/Image'; // These props are defined up here so they can easily be applied to multiple Images. // Normally specifying them inline would be fine. const imageProps: Partial = { imageFit: ImageFit.centerContain, width: 200, height: 200, // Show a border around the image (just for demonstration purposes) styles: props => ({ root: { border: '1px solid ' + props.theme.palette.neutralSecondary } }), }; export const ImageCenterContainExample = () => { return (

Setting the imageFit property to ImageFit.centerContain will cause the image to scale up or down proportionally. Images smaller than their frame will be rendered as ImageFit.center, while images larger than either frame's height or width will render as ImageFit.contain.

This image is smaller than the frame, so it's centered and rendered at its natural size.

Example of the image fit value "centerContain" on an image smaller than the frame.

This image is wider than the frame, so it's contained.

Example of the image fit value "centerContain" on an image wider than the frame.

This image is taller than the frame, so it's contained.

Example of the image fit value "centerContain" on an image taller than the frame.

These images are taller and wider than the frame, so they are contained.

Example of the image fit value "centerContain" on an image taller and wider than the frame.

Example of the image fit value "centerContain" on an image taller and wider than the frame.
); };