Why does my Layout of the carousel render vertically while flexed? - reactjs

I have an carousel set up for view of store products.
Here you can test the code out here in the demo snippet Codesandbox
Mapping through my array of images it renders vertically on the screen when they should over lap each other given the view of a carousel to click from left to right. The container is relative to its position, flexed with 0 inset. I don't understand how the images render vertically
export default function Storetwo(){
const [currentSlide, setCurrentSlide] = useState(0);
const [currentProduct, setCurrentProduct] = useState(slides[0]);
const { handleSubmit, reset, setValue, control } = useForm({ defaultValues });
const [data, setData] = useState(null);
const onSubmit = data => console.log(data);
const handlePreviousClick = () => {
setCurrentSlide(currentSlide === 0 ? slides.length - 1 : currentSlide - 1);
setCurrentProduct(slides[currentSlide]);
}
const handleNextClick = () => {
setCurrentSlide(currentSlide === slides.length - 1 ? 0 : currentSlide + 1);
setCurrentProduct(slides[currentSlide]);
}
return(
<div className=' md:flex p-2 h-[100vh] '>
{/* image container */}
<div className=" w-[100%] md:w-[100%] ">
{slides.map((slide, index) => (
<div key={index} className={`relative flex inset-0 z-10 justify-center items-center ${index === currentSlide ? 'block' : 'hidden'}`}>
<Image src={slide.image} width={200} height={200} key={index} alt="" className="object-cover p-10 " />
<div className=" top-40 left-10 justify-center items-center mx-auto flex ">
<button className='text-3xl ' onClick={handlePreviousClick}><ArrowBackIosIcon/></button>
<button className='text-3xl ' onClick={handleNextClick}><ArrowForwardIosIcon /></button>
</div>
</div>
))}
</div>
.../
Here are the vertical rendering images

Your link is broken, which is one of the reasons why external live examples aren't recommended on StackOverflow. Use Snippets instead.
As for your question, I believe you're misunderstanding how flexbox works (or maybe it's just an oversight).
You're applying flex to the divs that are being rendered as a result of your mapping, when you should be adding it to their container instead. It's the container that will set its children position as flexbox. Read more here.
[...]
return(
<div className=' md:flex p-2 h-[100vh] '>
{/* image container */}
<div className="flex w-[100%] md:w-[100%] "> {/* <= here */}
{slides.map((slide, index) => (
<div key={index} className={`relative flex inset-0 z-10 justify-center items-center ${index === currentSlide ? 'block' : 'hidden'}`}>
<Image src={slide.image} width={200} height={200} key={index} alt="" className="object-cover p-10 " />
<div className=" top-40 left-10 justify-center items-center mx-auto flex ">
<button className='text-3xl ' onClick={handlePreviousClick}><ArrowBackIosIcon/></button>
<button className='text-3xl ' onClick={handleNextClick}><ArrowForwardIosIcon /></button>
</div>
</div>
))}
</div>

Related

What ways are there to do an individual hover on elements that were iterated in React?

I'm rendering elements with the map function in react, the problem is that when hovering, the effect is applied to all the elements and what I'm looking for is an individual effect for each card.
This is my code:
const Card = () => {
const [isHovering, setIsHovering] = useState(false);
const handleMouseOver = () => {
setIsHovering(true);
};
const handleMouseOut = () => {
setIsHovering(false);
};
return (
<>
{productsList.map((product) => (
<div key={product.id}>
<div className="relative mb-4" onMouseOver={handleMouseOver} onMouseOut={handleMouseOut}>
<img src={product.img} alt="product" className="w-fit h-fit jshover cursor-pointer" />
{isHovering ? <CardOptions /> : ""}
</div>
<div className="flex justify-center flex-col px-3">
<h3 className="captialize font-sans font-bold text-black mb-3">Adicolor Classics Joggers</h3>
<div className="flex justify-between ">
<span className="capitalize font-normal font-sans text-[#777777]">Dress</span>
<span className="font-sans font-bold">$63.85</span>
</div>
</div>
</div>
))}
</>
)
}
I am iterating an external array of objects with the information of each card.
As seen in the image, I hover my mouse over a card and the "shop now" box appears on all cards.
What would be the best way to do it?
Without iteration of course it worked, but then using React is pointless.
Edit: [SOLVED] The state has to have the index of the iteration of the function. So the conditional rendering has to be conditioned on the index and not on a boolean value.
Like this:
const Card = () => {
const [isHovering, setIsHovering] = useState(-1);
const handleMouseOver = (item) => {
setIsHovering(item);
};
const handleMouseOut = () => {
setIsHovering(-1);
};
return (
<>
{productsList.map((product, index) => (
<div key={product.id}>
<div className="relative mb-4" onMouseOver={() => {
handleMouseOver(index);
}} onMouseOut={handleMouseOut}>
<img src={product.img} alt="product" className="w-fit h-fit jshover cursor-pointer" />
{isHovering === index ? <CardOptions /> : ""}
</div>
<div className="flex justify-center flex-col px-3">
<h3 className="captialize font-sans font-bold text-black mb-3">{product.title}</h3>
<div className="flex justify-between ">
<span className="capitalize font-normal font-sans text-[#777777]">{product.category}</span>
<span className="font-sans font-bold">{product.price}</span>
</div>
</div>
</div>
))}
</>
)

Uncaught Error: Rendered more hooks than during the previous render

Hello I am developing a page to search for gifs and I get the error when I search for a larger amount of gifs than I asked for the first time, for example if I ask for 15 gisf and then another 15 different gifs I get no error but if I ask for 15 and then 30 the error appears.
The gif grid component:
`
function Gifs(props: any) {
return (
<div className="gifs-container grid grid-cols-1 md:grid-cols-4 gap-5 ">
{props.gifList.map((gif: gif, index: number) => {
const [active, setActive] = useState(false);
return (
//img container
<div
className="gif-box w-[200px] h-[150px] relative text-white"
key={index}
>
{/* Image */}
<img
src={gif.url}
alt={gif.title}
className="w-full h-full object-cover"
/>
{/* Image overlay */}
<div
className="img-overlay absolute w-full h-full opacity-0 top-0 flex flex-col
items-center bg-[rgba(0,0,0,0.6)] transition duration-100 hover:opacity-100
justify-around overflow-hidden"
>
{/* Overlay Tittle */}
<div className="overlay-tittle font-bold text-xl text-center w-[80%]">
{notGif(gif.title)}
</div>
{/* Overlay Buttons */}
<div className="overlay-buttons grid-cols-2 w-[40%] flex justify-between items-center">
<button
className="viewLink w-8 h-8 hover:opacity-60"
onClick={() => {
window.open(gif.url, "_blank");
}}
></button>
<div className={`copyMessage ${active ? "active" : ""}`}>
<button
className="copyLink w-9 h-9 hover:opacity-60"
onClick={() => {
navigator.clipboard.writeText(gif.url);
setActive(true);
setTimeout(() => {
setActive(false);
}, 500);
}}
></button>
</div>
</div>
</div>
</div>
);
})}
</div>
);
}
export default Gifs;
the app component:
function App() {
const [gifList, setGifList] = useState<gif[]>([]);
const [gifCuantity, setGifCuantity] = useState("Cantidad");
const [gifName, setGifName] = useState("");
const setGifCuantityF = (newGifCuantity: string) => {
setGifCuantity(newGifCuantity);
};
const setGifNameF = (newGifName: string) => {
setGifName(newGifName);
};
const setGifListFun = (newGifList: gif[]) => {
setGifList(newGifList);
};
useEffect(() => {
if (gifCuantity !== "Cantidad" && gifName !== "") {
getGfifs(gifName, gifCuantity, setGifListFun);
setGifCuantity("Cantidad");
}
}, [gifName]);
return (
<div className="App">
<div className="h-screen ">
<div className="mx-auto flex flex-col justify-center items-center gap-8">
<Title />
<Browser
gifCuantity={gifCuantity}
setGifCuantityF={setGifCuantityF}
setGifNameF={setGifNameF}
/>
{/* <Cgifs gifList={gifList} /> */}
<Gifs gifList={gifList} />
</div>
</div>
</div>
);
}
`
i think the main proble is on the gifList useState, this is the useState that will contain all the gifs i fetch, so if the useState had array had 15 boxes and then i fetch for 20 gifs the error will say that the 5 new boxes were null before an now they are a useState

How to build carousel tailwind css flexbox with react slick

I first time build carousel with tailwind css and react slick.
Post component has own height calc(100vh - 65px). after I use flexbox like this:
data.map((i, index) => (
<div
key={index}
className="min-h-screen h-direct w-full mb-5 flex flex-col items-center p-2 md:px-6"
ref={index === data.length - 1 ? lastBookElementRef : null}
>
<Post
index={index}
item={i}
isModal={false}
t={t}
user={user}
/>
</div>
))
on Post page:
/* eslint-disable jsx-a11y/media-has-caption */
/* eslint-disable jsx-a11y/img-redundant-alt */
/* eslint-disable react/jsx-props-no-multi-spaces */
/* eslint-disable no-unused-expressions */
import { ArrowLeftOutlined, ArrowRightOutlined, DeleteOutlined, FileSyncOutlined, HeartFilled, HeartOutlined, LikeOutlined, UserOutlined } from '#ant-design/icons';
import axios from 'axios';
import Link from 'next/link';
import React, { useEffect, useRef, useState } from 'react';
import ReactPlayer from 'react-player';
import Slider from 'react-slick';
import { BallTriangle } from 'react-loader-spinner';
import calculateTime from '../calculateTime';
import { useSocket } from '../context/socket';
import Modal from './Modal';
const Post = ({ item, isModal, user, t }) => {
const [myLikes, setMyLikes] = useState(item.likes);
const [isOpen, setIsOpen] = useState(false);
const socket = useSocket();
const parentRef = useRef(null);
const scrollRef = useRef(null);
const [imageLoading, setImageLoading] = useState(item.files);
const imageLoaded = (id) => {
setImageLoading((prev) => prev.filter((t) => t.path !== id));
};
const [currentItem, setCurrentItem] = useState(0);
const settings = {
dots: false,
infinite: true,
speed: 500,
slidesToShow: 1,
slidesToScroll: 1,
initialSlide: 0,
swipeToSlide: true,
autoplay: false,
arrows: false,
lazyLoad: true,
};
const slide = useRef();
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
const addOrRemoveLike = async (postId) => {
const isLike = myLikes.filter((like) => like.user._id === user._id).length > 0;
try {
await axios({
method: 'PUT',
url: `${process.env.SERVER}/posts/${isLike ? 'unliked' : 'liked'}/${postId}`,
withCredentials: true,
});
if (!isLike) {
const users = [item.user._id];
if (item.user._id !== user._id) socket.emit('newnotification', { users });
}
isLike ? setMyLikes((prev) => prev.filter((p) => p.user._id !== user._id)) : setMyLikes((prev) => ([{ user }, ...prev]));
} catch (error) {
console.error(error);
}
};
const handleScroll = (direction) => {
const { current } = scrollRef;
setCurrentItem((prev) => (prev + 1) % (item.files.length));
const scrollAmount = current.offsetWidth ? current.offsetWidth : 100;
if (direction === 'left') {
current.scrollLeft -= scrollAmount;
} else {
current.scrollLeft += scrollAmount;
}
};
return (
<div className={`flex-1 w-[60%] border-b gap-3
md:w-full ${isModal ? 'flex-row' : 'flex-col'} flex items-center justify-start`}
>
{/* Top */}
<div className=" flex w-full flex-row items-center gap-3 ">
<div className="border overflow-hidden rounded-full w-14 h-14 sm:w-10 sm:h-10 flex items-center justify-center bg-nft-gray-2 dark:bg-nft-gray-3">
{
item.user.logo.length > 0
? <img src={`${process.env.SERVER}/${item.user.logo}`} className="w-full h-full object-cover" />
: <UserOutlined className="text-2xl sm:text-xl" />
}
</div>
<div className="flex-1 flex flex-row items-center justify-between gap-2">
<div className="flex-1 flex flex-col justify-start ">
<Link href={`user/${item.user.username}`}>
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a className="text-blue-600 dark:text-blue-500 font-medium"> {item.user.username} </a>
</Link>
<div className="w-10/12">
<h1 className="text-xs font-thin">
{item.location}
</h1>
<h1 className="text-xs font-thin">
<span className="font-medium">posted: </span>
{calculateTime(item.date, t)}
</h1>
</div>
</div>
{
user._id === item.user._id && (
<div>
<DeleteOutlined className="transition-all duration-500 text-xl cursor-pointer hover:text-nft-black-1 dark:hover:text-nft-gray-1" />
</div>
)
}
</div>
</div>
{/* Bottom */}
<div className="flex-1 w-full flex flex-col gap-1">
{/* FIles */}
<div
className="flex-2 w-full border bg-nft-gray-1 dark:bg-nft-black-1
relative
"
>
<ArrowLeftOutlined
className="absolute top-1/2 -translate-y-1/2 left-0 -translate-x-1/2
bg-nft-black-1 text-white text-xl flex justify-center items-center p-1 rounded-full cursor-pointer
hover:text-2xl transition-all duration-500
dark:bg-nft-gray-3 z-[5]
"
onClick={() => slide.current.slickPrev()}
/>
<ArrowRightOutlined
className="absolute top-1/2 -translate-y-1/2 right-0 translate-x-1/2
bg-nft-black-1 text-white text-xl flex justify-center items-center p-1 rounded-full cursor-pointer
hover:text-2xl transition-all duration-500
dark:bg-nft-gray-3 z-[5]
"
onClick={() => slide.current.slickNext()}
/>
<div className="h-[70%] w-full border bg-nft-gray-1 dark:bg-nft-black-1">
<div className="relative h-full">
<Slider {...settings} ref={slide}>
{
item.files.map((i, item) => (
<div key={item} className="w-full h-full flex justify-center items-center ">
{
i.type.startsWith('image')
? (
<img
onLoad={() => imageLoaded(i.path)}
src={`${process.env.SERVER}/${i.path}`}
className={` object-cover
${imageLoading.filter((t) => t.path === i.path).length > 0 && 'hidden'}
`}
alt="image"
/>
)
: (
<video
src={`${process.env.SERVER}/${i.path}`}
className="object-contain"
controls
controlsList="nodownload"
/>
)
}
</div>
))
}
</Slider>
</div>
</div>
</div>
{/* Statistics */}
<div className="flex-1 flex flex-col gap-2">
<div className="flex w-full flex-row justify-between items-center">
<div className=" flex flex-row gap-3 transition-all duration-500 items-center justify-start relative">
{
myLikes.filter((like) => like.user._id === user._id).length > 0
? (
<HeartFilled
className={`text-2xl text-red-500 dark:text-red-600 ${user.id === item.user._id && 'cursor-pointer'}`}
onClick={() => addOrRemoveLike(item._id)}
/>
)
: (
<HeartOutlined
className="text-2xl"
onClick={() => addOrRemoveLike(item._id)}
/>
)
}
{
myLikes.length > 0 && (
<div
className={`text-sm font-medium ${user._id === item.user._id && 'cursor-pointer '}`}
onClick={() => { setIsOpen(user._id === item.user._id); }}
>
{numberWithCommas(myLikes.length).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')} likes
</div>
)
}
</div>
<div className="text-sm relative before:content-[''] before:absolute before:block before:w-full before:h-[2px]
before:bottom-0 before:left-0 before:bg-blue-500 dark:before:bg-blue-600
before:hover:scale-x-100 before:scale-x-0 before:origin-top-left
before:transition-all before:ease-in-out before:duration-300
cursor-pointer text-blue-500 dark:text-blue-600
"
>Go to this post
</div>
</div>
<div className="flex flex-row gap-2 flex-wrap">
{item.tags.map((i) => (
<div key={i} className="flex flex-row items-center bg-blue-500 px-1 text-white dark:bg-blue-600 transition-all duration-500">
<p className="text-sm ">#{i}</p>
</div>
))}
</div>
<div className="flex flex-row">
<p className="text-sm truncate whitespace-nowrap overflow-hidden">{item.description}</p>
</div>
</div>
</div>
{
isOpen && (
<Modal
setClose={setIsOpen}
header="Likes"
>
{
myLikes.map((i, index) => (
<div
key={index}
className={` ${index !== myLikes.length - 1 && 'mb-2'} flex flex-row justify-center items-center cursor-pointer`}
>
<div className="w-full flex-1 p-2 shadow dark:bg-nft-black-2 flex flex-row items-center justify-between">
<div className="flex flex-row gap-5 flex-1 items-center">
<div className="h-10 w-10 rounded-full flex justify-center items-center bg-nft-gray-1 dark:bg-nft-black-1 overflow-hidden">
{
i.user.logo.length > 0
? (
<img
src={`${process.env.SERVER}/${i.user.logo}`}
className="w-full h-full object-cover"
/>
)
: <UserOutlined />
}
</div>
<div className="flex flex-col items-start justify-between">
<p>{i.user.username}</p>
{((i.user.firstName.length > 0) || (i.user.lastName.length > 0))
&& (
<h1
className="font-medium text-sm"
>{`${i.user.firstName} ${i.user.lastName}`}
</h1>
)}
</div>
</div>
</div>
</div>
))
}
</Modal>
)
}
</div>
);
};
export default Post;
I use react-slick for carousel. But height dont get. I parent div heigth h-[70%]. When I see without images everything good but after add react slick carousel images height increased. How do this?

Displaying text on only one image at at time in React

I am working on a portfolio page using React and Tailwind. I am trying to get to where when you hover over each image, it will display the text at the bottom of a single image. Right now when I hover over the image, all text displays on all images. How would I fix this? Also, I know there has to be a way to clean this up, I was trying to get it work first. Thank you for and advice you might have!
const Experience = () => {
const [isHovering, setIsHovering] = useState(false);
const handleMouseOver = () => {
setIsHovering(true);
}
const handleMouseOut = () => {
setIsHovering(false);
}
return (
<div
name="experience"
className="w-full h-screen bg-[#0a192f] text-gray-300"
>
<div className="max-w-[1000px] mx-auto flex flex-col justify-center w-full h-full">
<div>
<p className="text-4xl font-bold inline border-b-4 border-purple-800">
Experience
</p>
<p className="py-4">Technologies I have worked with</p>
</div>
<div className="w-full grid grid-cols-2 sm:grid-cols-4 gap-4 text-center py-8">
<div className="shadow-md shadow-[#040c16] hover:scale-110 duration-500">
<img
onMouseOver={handleMouseOver}
onMouseOut={handleMouseOut}
className="w-20 mx-auto"
src={CssLogo}
alt="Css Logo"
/>
{isHovering ? <p className="font-bold">CSS</p> : ""}
</div>
<div className="shadow-md shadow-[#040c16] hover:scale-110 duration-500">
<img
onMouseOver={handleMouseOver}
onMouseOut={handleMouseOut}
className="w-20 mx-auto"
src={HtmlLogo}
alt="HTML logo"
/>
{isHovering ? <p className="font-bold">HTML</p> : handleMouseOut}
</div>
<div className="shadow-md shadow-[#040c16] hover:scale-110 duration-500">
<img
onMouseOver={handleMouseOver}
onMouseOut={handleMouseOut}
className="w-20 mx-auto"
src={JavaScriptLogo}
alt="Js Logo"
/>
{isHovering ? (
<p className="font-bold">JavaScript</p>
) : (
handleMouseOut
)}
</div>
<div className="shadow-md shadow-[#040c16] hover:scale-110 duration-500">
<img
onMouseOver={handleMouseOver}
onMouseOut={handleMouseOut}
className="w-20 mx-auto"
src={MongoLogo}
alt="Mongo Logo"
/>
{isHovering ? (
<p className="font-bold">Mongo DB</p>
) : (
''
)}
</div>
<div className="shadow-md shadow-[#040c16] hover:scale-110 duration-500">
<img
onMouseOver={handleMouseOver}
onMouseOut={handleMouseOut}
className="w-20 mx-auto"
src={MysqlLogo}
alt="Mysql Logo"
/>
{isHovering ? (
<p className="font-bold">MySQL</p>
) : (
''
)}
</div>
<div className="shadow-md shadow-[#040c16] hover:scale-110 duration-500">
<img
onMouseOver={handleMouseOver}
onMouseOut={handleMouseOut}
className="w-20 mx-auto"
src={NodeLogo}
alt="Node Logo"
/>
{isHovering ? (
<p className="font-bold">Node JS</p>
) : (
''
)}
</div>
You have lots of text elements, but only one state value:
const [isHovering, setIsHovering] = useState(false);
So either all of them are "hovering" or all of them are "not hovering". Instead of a boolean, you might use some kind of identifier. For example:
const [hoveringID, setHoveringID] = useState();
And update the state to an identifier:
const handleMouseOver = (id) => {
setHoveringID(id);
}
const handleMouseOut = () => {
setHoveringID(undefined);
}
And pass some ID to those handlers:
onMouseOver={() => handleMouseOver(1)}
(Use a different ID for each element, of course.) And use that state to determine if that element is "hovering":
{hoveringID === 1 ? <p className="font-bold">CSS</p> : ""}
Taking it a step further, this all becomes much easier if you refactor all of that repeated code. Create data for your component:
const sections = [
{
id: 1,
src: CssLogo,
alt: "Css Logo",
hoverContent: "CSS"
},
//etc...
]
And just map over that data:
<div className="w-full grid grid-cols-2 sm:grid-cols-4 gap-4 text-center py-8">
{
sections.map(section => (
<div className="shadow-md shadow-[#040c16] hover:scale-110 duration-500">
<img
onMouseOver={() => handleMouseOver(section.id)}
onMouseOut={handleMouseOut}
className="w-20 mx-auto"
src={section.src}
alt={section.alt}
/>
{hoveringID === section.id ? <p className="font-bold">{section.hoverContent}</p> : ""}
</div>
))
}
</div>

TailwindCSS fade in Element on click

So I'm making this app and I need to fade in the menu when I click the button. I have it rendering on click using state, but I can't get it to fade in / fade out on click. When I edit the opacity value inside Chrome Dev Console the transition works fine, but when I want to change it using state it doesn't.
Any help? Thanks in advance!
import React, { useState } from "react";
import { useRouter } from "next/router";
import { MenuIcon, XIcon } from "#heroicons/react/outline";
function Header() {
const router = useRouter();
const [popCard, setPopCard] = useState("hidden");
const [fade, setFade] = useState(true);
const handleMenuClick = () => {
setPopCard("inline-block");
setFade(true);
};
const handleXClick = () => {
setPopCard("hidden");
setFade(false);
};
return (
<div className="text-center">
<header className="sticky z-50 top-0 shadow-md bg-white border-b p-5">
<div className="flex justify-between items-center">
<h1
className="text-6xl text-red-500 cursor-pointer"
onClick={() => router.push("/")}
>
Velvet
</h1>
<MenuIcon
className="h-8 text-red-500 cursor-pointer"
onClick={handleMenuClick}
/>
</div>
</header>
<div
className={
popCard +
" w-[60%] flex-col border my-10 pb-3 rounded-3xl shadow-lg transition duration-300 ease-in-out " +
`${fade === true ? "opacity-100" : "opacity-0"}`
}
>
<div className="flex justify-end">
<XIcon
className="h-6 text-red-500 cursor-pointer mt-2 mr-2 opacity-70"
onClick={handleXClick}
/>
</div>
<div className="space-y-8 text-3xl text-center mt-5 mb-10 text-red-500">
<h1>Contac</h1>
<h1>About Us</h1>
</div>
</div>
</div>
);
}
export default Header;
codesandbox: Sandbox
Just to be clear, I want the menu card to fade in when I click the menu button, and I want the menu card to fade out when I click the close button.
The solution is, you need to add duration, like this:
`transition-all duration-200 ${fade ? "opacity-100" : "opacity-0"}`
Here is my forked sandbox you had given, I've removed extra inline CSS, so it may become evident.
Here is the complete code:
function Header() {
const [popCard, setPopCard] = useState("hidden");
const [fade, setFade] = useState(false);
const handleMenuClick = () => {
setPopCard("inline-block");
setFade(true);
};
const handleXClick = () => {
setPopCard("hidden");
setFade(false);
};
console.log(fade, "fade");
return (
<div className="text-center">
<header className="sticky z-50 top-0 shadow-md bg-white border-b p-5">
<div className="flex justify-between items-center">
<h1 className="text-6xl text-red-500 cursor-pointer">Velvet</h1>
<button
className="text-3xl border rounded-lg px-5"
onClick={handleMenuClick}
>
Menu
</button>
</div>
</header>
<div className="p-10">
<div
className={`transition-all duration-200 ${
fade ? "opacity-100" : "opacity-0"
}`}
>
<div className="flex justify-end">
<button className="mt-2 mr-2 border p-2" onClick={handleXClick}>
Close
</button>
</div>
<div className="space-y-2 text-3xl text-center mt-5 mb-10 mx-5 text-red-500">
<h1>Kontakt</h1>
<h1>O Velvetu</h1>
</div>
</div>
</div>
</div>
);
}
export default Header;
Sandbox: https://codesandbox.io/s/sweet-swartz-mr3nru?file=/pages/index.js:41-1396

Resources