Hey buddy!
- User
Hey buddy!
- Assistant
Hello! How can I assist you today?
- User
Can you write me NextJS/React component which is movie card. Make sure it's typescript! It should have Movie/Show Poster then followed by Title below of it. plus add a badge floating on top of movie poster. badge should say TV. And remember, use Tailwind CSS!
- Assistant
Sure, I'll outline a simple Next.js/React TypeScript component for a movie card using Tailwind CSS. This example includes a movie/show poster followed by a title and a "TV" badge floating on the poster.
First, ensure you have Tailwind CSS installed in your Next.js project. If you haven't set up Tailwind CSS yet, follow the official installation instructions:
- User
hey, make position of badge top right corner!
- Assistant
Certainly! To position the badge in the top right corner of the movie card, you'll need to make a small adjustment to the
spanelement within theMovieCardcomponent. Update the className of thespanelement so that it usestop-0andright-0for positioning:import React from 'react'; // Define the props the MovieCard component expects interface MovieCardProps { title: string; posterUrl: string; } const MovieCard: React.FC<MovieCardProps> = ({ title, posterUrl }) => { return ( <div className="relative p-4 transition-shadow duration-300 bg-white rounded shadow hover:shadow-lg"> {/* Badge floating on the top right of the movie poster */} <span className="absolute top-0 right-0 px-2 py-1 text-xs font-bold text-white bg-blue-600 rounded-bl">TV</span> {/* Movie Poster */} <img src={posterUrl} alt={title} className="w-full rounded" /> {/* Title */} <h3 className="mt-2 text-lg font-semibold truncate">{title}</h3> </div> ); }; export default MovieCard;The
rounded-blutility is used to round the bottom-left corner of the badge to give it a consistent appearance to when it was in the top-left. Just make sure you adjust the to . Now, the badge will be positioned in the top right corner of the poster within the card. - User
write code inside which I can copy multiple movie cards and it show in proper grid format, showing maximum 5 per row and as screen viewport decreases , maximum cards lowers means, it get responsive!
- Assistant