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

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

Image of DataStax

Langflow: Simplify AI Agent Building

Langflow is the easiest way to build and deploy AI-powered agents. Try it out for yourself and see why.

Get started for free

👋 Kindness is contagious

Please show some love ❤️ or share a kind word in the comments if you found this useful!

Got it!