import { IImageProps, Image, ImageFit } from '@fluentui/react/lib/Image'; import * as React from 'react'; // 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.centerCover, 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 ImageCenterCoverExample = () => { return (

Setting the imageFit property to ImageFit.centerCover 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.cover.

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

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

This image has a wider aspect ratio (more landscape) than the frame but is not as tall as the frame, so it's rendered at its natural size while cropping the sides.

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

This image has a taller aspect ratio (more portrait) than the frame but is not as wide as the frame, so it's rendered at its natural size while cropping the top and bottom.

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

These images are taller and wider than the frame, so they grow just enough to "cover" the frame area.

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

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