DEV Community

Cover image for Creating Cards In React
Tushar Nirmal
Tushar Nirmal

Posted on

Creating Cards In React

Creat New App In react using

npx create-react-app my-cards

Enter into your app using

npx create-react-app my-cards

then start your project using

npm start

Now Create Components in src for creating cards
Create Card body component using

import React from 'react';
import './cardstyle.css';

class CardBody extends React.Component {
render() {
return (

      <h2>{this.props.title}</h2>

      <p className="body-content">{this.props.text}</p>


    </div>
  )
}

}

export default CardBody;

then create card header using code

import React from 'react';
import './cardstyle.css';
class CardHeader extends React.Component {
render() {
const { image } = this.props;
var style = {
backgroundImage: 'url(' + image + ')',
};
return (






)
}
}

export default CardHeader;

Create Card using code (Note change path of Image and component as per your path)

import React from 'react';
import './cardstyle.css';
import CardBody from'./cardBody';
import CardHeader from './cardHeader';
import AnsMImg from './answerSheetMarking.jpg';

class Card extends React.Component {

render() {
  return (
    <article className="card">
      <CardHeader image={AnsMImg }/>
      <CardBody title={'Answer sheet marking'} 
      text={'Tool can read printed as well as handwritten answer sheets. Can transform the exam assessment manual process in schools and colleges.'}/>

    <button className="button button-primary" >
      Try it out
    </button> 
    </article>

  )
}

}
export default Card;

And Finally your card is ready

Render Card inside The App.js
and you can see your card in browser

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series πŸ‘€

Watch the Youtube series

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay