React Rebass is a front-end framework that was designed keeping react in mind. In this article, we will know how to use Background Image Card Component in React rebass. Background Image Card is an important component that is required in each development. So to create a Background Image Card component we can import the Rebass Background Image Card component.
Background Image Card component is used to import a background image in a card.
Syntax:
<Box backgroundImage: 'url(link)'></Box>
Creating React Application And Installing Module:
Step 1: Create a React application using the following command.
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command.
cd foldername
Step 3: Install React Rebass in your given directory.
npm i rebass
Project Structure: It will look like the following.
Example: This is the basic example that shows how to use the Background Image Card component.
App.js
import React from "react" ; import { Box, Heading } from "rebass" ; const App = () => { return ( <div id= 'gfg' > <h2>neveropen</h2> <h4>React Rebass Background Image Card Component</h4> <Box sx={{ px: 4, py: 6, width: 825, backgroundImage: 'url( borderRadius: 8, color: 'green' }}> <Heading textAlign= 'center' fontSize={[5, 6]}> neveropen </Heading> </Box> </div> ); }; export default App; |
Step to Run Application: Run the application from the root directory of the project, using the following command.
npm start
Output:
Reference: https://rebassjs.org/recipes/background-image-card