npm install react-transition-group @mui/icons-material
좋은 색상 조합은 웹사이트를 더 매력적으로 만든다.
색상 팔레트를 선택할 때는 대조되는 색상이나 조화로운 색상을 사용하기가 좋다.
사이트 전체에서 일관된 색상 팔레트를 사용하면 더 전문적으로 보일 것이다.
ColorPalette.js
import React, { useState } from "react";
import { Box, Typography, Grid } from "@mui/material";
import { CSSTransition } from "react-transition-group";
import "./fade.css";
const colors = [
{ background: "#f44336", text: "#fff" },
{ background: "#e91e63", text: "#fff" },
{ background: "#9c27b0", text: "#fff" },
{ background: "#673ab7", text: "#fff" },
{ background: "#3f51b5", text: "#fff" },
{ background: "#03a9f4", text: "#fff" },
{ background: "#00bcd4", text: "#fff" },
{ background: "#4caf50", text: "#fff" },
{ background: "#8bc34a", text: "#000" },
{ background: "#cddc39", text: "#000" },
{ background: "#ffeb3b", text: "#000" },
{ background: "#ffc107", text: "#000" },
{ background: "#ff9800", text: "#000" },
{ background: "#ff5722", text: "#fff" },
{ background: "#795548", text: "#fff" },
{ background: "#9e9e9e", text: "#fff" },
{ background: "#607d8b", text: "#fff" },
];
function ColorPalette() {
const [selectedColor, setSelectedColor] = useState(colors[0]);
const [showText, setShowText] = useState(true);
const handleColorChange = (color) => {
setShowText(false);
setTimeout(() => {
setSelectedColor(color);
setShowText(true);
}, 300);
};
return (
<Box
sx={{
height: "100vh",
backgroundColor: selectedColor.background,
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
}}
>
<Box sx={{ position: "absolute", top: 100 }}>
<Grid container spacing={2}>
{colors.map((color, index) => (
<Grid item key={index} onClick={() => handleColorChange(color)}>
<Box
sx={{
width: 50,
height: 50,
backgroundColor: color.background,
border: "1px solid black",
}}
></Box>
</Grid>
))}
</Grid>
</Box>
<CSSTransition
in={showText}
timeout={300}
classNames="fade"
unmountOnExit
mountOnEnter
>
<Typography variant="h4" style={{ color: selectedColor.text }}>
Hello, React!
</Typography>
</CSSTransition>
</Box>
);
}
export default ColorPalette;
동적으로 색상이 변한다.
아이콘은 사용자에게 기능을 명확하게 전달하고, 디자인을 향상시킬 수 있다.
Font Awesome, Material Icons 등 다양한 아이콘 라이브러리를 사용하여 웹사이트에 아이콘을 쉽게 추가할 수 있다.
Material Icons 예시)
import React, { useState } from "react";
import { Box, Typography, IconButton, TextField, Button } from "@mui/material";
import {
Home as HomeIcon,
Work as WorkIcon,
School as SchoolIcon,
} from "@mui/icons-material";
const categories = [
{
title: "Home",
icon: <HomeIcon />,
content: "This is the Home category.",
},
{
title: "Work",
icon: <WorkIcon />,
content: "This is the Work category.",
},
{
title: "School",
icon: <SchoolIcon />,
content: "This is the School category.",
},
];
function CategoryList() {
const [selectedCategory, setSelectedCategory] = useState(null);
const handleCategoryClick = (category) => {
setSelectedCategory(category);
};
return (
<Box
sx={{ display: "flex", flexDirection: "column", alignItems: "center" }}
>
<Box sx={{ display: "flex", justifyContent: "center", marginBottom: 2 }}>
{categories.map((category, index) => (
<IconButton key={index} onClick={() => handleCategoryClick(category)}>
{category.icon}
</IconButton>
))}
</Box>
{selectedCategory && (
<Box sx={{ width: "100%", maxWidth: 400 }}>
<Typography variant="h5">
{selectedCategory.icon}
{selectedCategory.title}
</Typography>
<Typography variant="body1" sx={{ marginBottom: 2 }}>
{selectedCategory.content}
</Typography>
<Box sx={{ display: "flex", flexDirection: "column" }}>
<TextField
label="Your Name"
variant="outlined"
size="small"
sx={{ marginBottom: 1 }}
/>
<TextField
label="Your Comment"
variant="outlined"
size="small"
multiline
rows={4}
sx={{ marginBottom: 1 }}
/>
<Button variant="contained" color="primary">
Submit
</Button>
</Box>
</Box>
)}
</Box>
);
}
export default CategoryList;
이런식으로 아이콘을 넣어서 글자를 보조하여 아이콘으로 확실하게 확인이 가능하게 하면 좋다.
최근 트렌드에 맞는 React 웹 디자인 UX/UI 구현하기 - 6편 (사용자 피드백 제공, 웹 접근성) (0) | 2023.04.07 |
---|---|
최근 트렌드에 맞는 React 웹 디자인 UX/UI 구현하기 - 5편 (컴포넌트 라이브러리, 로딩 애니메이션) (0) | 2023.04.06 |
최근 트렌드에 맞는 React 웹 디자인 UX/UI 구현하기 - 3편 (인터랙티브한 애니메이션, 타이포그래피) (0) | 2023.04.04 |
최근 트렌드에 맞는 React 웹 디자인 UX/UI 구현하기 - 2편 (미니멀리즘 디자인, 그리드 레이아웃) (0) | 2023.04.03 |
최근 트렌드에 맞는 React 웹 디자인 UX/UI 구현하기 - 1편 (반응형 디자인, 다크 모드 지원) (0) | 2023.03.31 |
내 블로그 - 관리자 홈 전환 |
Q
Q
|
---|---|
새 글 쓰기 |
W
W
|
글 수정 (권한 있는 경우) |
E
E
|
---|---|
댓글 영역으로 이동 |
C
C
|
이 페이지의 URL 복사 |
S
S
|
---|---|
맨 위로 이동 |
T
T
|
티스토리 홈 이동 |
H
H
|
단축키 안내 |
Shift + /
⇧ + /
|
* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.