Skip to main content

Image

Constrain an image to a given aspect ratio.

Polymorphic Component

By default, content is rendered inside an <img>, but this can be overriden by passing any valid tag name or component with the as prop.

Examples

Square Image (Default)

<Image src={someImage} />
<Image src={someImage} aspectRatio="square" />
<Image src={someImage} aspectRatio="1:1" />

Landscape Ratios



<Image 
...
aspectRatio="3:2|4:3|5:4"
/>

Portrait Ratios



<Image 
...
aspectRatio="2:3|3:4|4:5"
/>

Props

NameTypeDefault ValueRequiredDescription
aspectRatio"square" | ImageAspectRatio | "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4"ImageAspectRatio.SquareNoConstrain the image to a specific aspect ratio.

Enums

ImageAspectRatio

KeyValue
Square"square"
OneToOne"1:1"
TwoToThree"2:3"
ThreeToTwo"3:2"
ThreeToFour"3:4"
FourToThree"4:3"
FourToFive"4:5"
FiveToFour"5:4"