GitHub
ComponentsImageBackground

ImageBackground

A React component for displaying an image behind child content. It works like Image but acts as a container — any children are rendered on top of the image.

import { ImageBackground, Text } from '@react-pdf/renderer';

const Cover = () => (
  <ImageBackground
    src="https://react-pdf.org/images/mountains.jpg"
    style={{ height: 200, padding: 24, justifyContent: 'flex-end' }}
  >
    <Text style={{ color: 'white', fontSize: 24 }}>Annual report</Text>
  </ImageBackground>
);
Show preview

Valid props

Prop nameDescriptionTypeDefault
srcSource of the image. See moreSource objectundefined
sourceAlias of src. See moreSource objectundefined
styleDefines view styles. See moreObject, Arrayundefined
imageStyleDefines styles applied to the background imageObject, Arrayundefined
debugEnables debug mode on view bounding box. See moreBooleanfalse
fixedRenders component in all wrapped pages. See moreBooleanfalse
breakForces the wrapping algorithm to start a new page when rendering this element. See moreBooleanfalse
minPresenceAheadHint that no page wrapping should occur between all sibling elements following the element within n points. See moreNumber0
cacheEnables image caching between consecutive rendersBooleantrue
srcSetResponsive image sources for resolution-based selectionStringundefined
sizesDisplay width used for srcSet source selectionString, Numberundefined
bookmarkAttach bookmark to element. See moreString or Bookmarkundefined

On this page