card with 2 pages tailwind and react js
- Get link
- X
- Other Apps
Here is an example of creating a card in React using Tailwind CSS that includes an image and a bottom description:
impoimport React from 'react';
const Card = ({imgSrc, title, description}) => { return ( <div className="max-w-sm rounded overflow-hidden shadow-lg"> <img src={imgSrc} alt={title} className="w-full" /> <div className="px-6 py-4"> <div className="font-bold text-xl mb-2">{title}</div> <p className="text-gray-700 text-base"> {description} </p> </div> </div> );}
export default Card;
In this example, the Card component takes in three props: imgSrc, title, and description. These props are used to render an image, a title, and a description inside the card.
The card itself is a div element with the class max-w-sm rounded overflow-hidden shadow-lg. This class is using the tailwind classes max-w-sm, rounded, overflow-hidden, and shadow-lg which will set the max width of the card to sm and give the card rounded corners and a shadow effect.
The image is rendered using an img tag with the src prop set to the value of the imgSrc prop passed in, and the alt prop set to the value of the title prop passed in. The class w-full makes the image fill the full width of the container.
The title and description are rendered inside a div element with the classes px-6 py-4. This class is using the tailwind classes px-6 and py-4 which will give the div a padding of 1rem on the x-axis and 1rem on the y-axis respectively.
The title is rendered inside a div element with the classes font-bold text-xl mb-2, this class will make the text bold and with size xl and margin bottom of 0.5rem.
The description is rendered inside a p element with the class text-gray-700 text-base which will set the text color to gray and the font-size to base.
You can use this component in another component and pass the required props like this
import Card from './Card' function App(){ return( <Card imgSrc="imageurl" title="card title" description="card description" /> ) }
}
This is just one example of how you can use Tailwind CSS classes to create a card in React, and you can customize it based on your needs.
- Get link
- X
- Other Apps