02밝은 값과 어두운 값이 반대로 겹쳐 도드라지는 글자
밝은 그림자와 어두운 그림자를 서로 반대 방향에 겹쳐, 같은 배경 위에서 글자가 도드라지거나 파인 듯 보인다.
쓰임카드 배지 라벨
EMBOSS_DEPTH_PXbuildEmbossShadowrenderEmboss

<main class="stage">
<div class="em is-demo" id="em">
<p class="em__badge"><span class="em__badgeLabel">빛 각도</span> <span class="em__badgeValue" id="emValue">0deg</span></p>
<h1 class="em__word" id="emWord">요철</h1>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// 핵심: 각도 값(angleDeg) 하나로 밝은 그림자와 어두운 그림자를 서로 반대 방향에 배치한다.
// 각도가 돌면 빛이 도는 것처럼 도드라짐과 파임이 자리를 바꾼다.
$duration: $dur-loop;
$easing: linear;
$color: $subject-ink;
@include stage($stage-yellow);
.em {
display: grid;
gap: $sp-4;
justify-items: center;
text-align: center;
}
.em__badge {
margin: 0;
padding: $sp-1 $sp-3;
border-radius: $r-pill;
background: rgba(23, 20, 26, .08);
color: $subject-ink;
font-weight: 700;
font-size: 11px;
font-variant-numeric: tabular-nums;
}
.em__word {
margin: 0;
font-weight: 800;
font-size: clamp(72px, 24vw, 140px);
line-height: 1;
white-space: nowrap;
color: $color;
will-change: text-shadow;
}
@media (max-width: 340px) {
.em__word { font-size: clamp(52px, 26vw, 92px); }
}
@media (prefers-reduced-motion: reduce) {
.em__word { transition: none; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ffd23f;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.em {
display: grid;
gap: 16px;
justify-items: center;
text-align: center;
}
.em__badge {
margin: 0;
padding: 4px 12px;
border-radius: 999px;
background: rgba(23, 20, 26, 0.08);
color: #17141a;
font-weight: 700;
font-size: 11px;
font-variant-numeric: tabular-nums;
}
.em__word {
margin: 0;
font-weight: 800;
font-size: clamp(72px, 24vw, 140px);
line-height: 1;
white-space: nowrap;
color: #17141a;
will-change: text-shadow;
}
@media (max-width: 340px) {
.em__word {
font-size: clamp(52px, 26vw, 92px);
}
}
@media (prefers-reduced-motion: reduce) {
.em__word {
transition: none;
}
}(function () {
var EMBOSS_DEPTH_PX = 12.5;
var PERIOD_MS = 1000;
var word = document.getElementById('emWord');
var value = document.getElementById('emValue');
var reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
// 값(angleDeg) 하나로 밝은 그림자·어두운 그림자를 서로 반대 방향에 배치한다
function buildEmbossShadow(angleDeg) {
var rad = (angleDeg * Math.PI) / 180;
var lx = (Math.cos(rad) * EMBOSS_DEPTH_PX).toFixed(2);
var ly = (Math.sin(rad) * EMBOSS_DEPTH_PX).toFixed(2);
var dx = (-Math.cos(rad) * EMBOSS_DEPTH_PX).toFixed(2);
var dy = (-Math.sin(rad) * EMBOSS_DEPTH_PX).toFixed(2);
return [
lx + 'px ' + ly + 'px 0 rgba(255,255,255,.85)',
dx + 'px ' + dy + 'px 1px rgba(10,10,14,.75)'
].join(', ');
}
function renderEmboss(angleDeg) {
word.style.textShadow = buildEmbossShadow(angleDeg);
value.textContent = Math.round(angleDeg % 360) + 'deg';
}
var startTime = null;
function loop(now) {
if (startTime === null) startTime = now;
var t = (now - startTime) % PERIOD_MS;
var angle = (t / PERIOD_MS) * 360;
renderEmboss(angle);
requestAnimationFrame(loop);
}
if (reduce) {
renderEmboss(45);
} else {
requestAnimationFrame(loop);
}
})();// TextShadowEmbossEngraveDual — vanilla 판(run/412/demo/02-text-shadow-emboss-engrave-dual/index.html) 의 React 포트.
// 각도 값(angleDeg) 하나로 밝은 그림자와 어두운 그림자를 서로 반대 방향에 배치한다.
// 각도가 돌면 빛이 도는 것처럼 도드라짐과 파임이 자리를 바꾼다.
import { useEffect, useRef, useState } from "react";
import styles from "./TextShadowEmbossEngraveDual.module.scss";
type Box<T> = { current: T };
const EMBOSS_DEPTH_PX = 12.5;
const PERIOD_MS = 1000;
function buildEmbossShadow(angleDeg: number): string {
const rad = (angleDeg * Math.PI) / 180;
const lx = (Math.cos(rad) * EMBOSS_DEPTH_PX).toFixed(2);
const ly = (Math.sin(rad) * EMBOSS_DEPTH_PX).toFixed(2);
const dx = (-Math.cos(rad) * EMBOSS_DEPTH_PX).toFixed(2);
const dy = (-Math.sin(rad) * EMBOSS_DEPTH_PX).toFixed(2);
return [
lx + "px " + ly + "px 0 rgba(255,255,255,.85)",
dx + "px " + dy + "px 1px rgba(10,10,14,.75)"
].join(", ");
}
export default function TextShadowEmbossEngraveDual() {
const wordRef = useRef<HTMLHeadingElement | null>(null);
const valueRef = useRef<HTMLSpanElement | null>(null);
const t0Ref = useRef<number>(0) as Box<number>;
const frameRef = useRef<number>(0) as Box<number>;
const [demo] = useState(true);
const [reduce, setReduce] = useState(false);
function render(angleDeg: number): void {
const word = wordRef.current;
const value = valueRef.current;
if (!word || !value) return;
word.style.textShadow = buildEmbossShadow(angleDeg);
value.textContent = Math.round(angleDeg % 360) + "deg";
}
useEffect(() => {
setReduce(window.matchMedia("(prefers-reduced-motion: reduce)").matches);
}, []);
useEffect(() => {
if (reduce) {
render(45);
return;
}
function loop(now: number): void {
if (t0Ref.current === 0) t0Ref.current = now;
const t = (now - t0Ref.current) % PERIOD_MS;
const angle = (t / PERIOD_MS) * 360;
render(angle);
frameRef.current = requestAnimationFrame(loop);
}
frameRef.current = requestAnimationFrame(loop);
return () => cancelAnimationFrame(frameRef.current);
}, [reduce]);
const cls = [styles.em, demo ? styles.isDemo : ""].filter(Boolean).join(" ");
return (
<main className={styles.stage}>
<div className={cls}>
<p className={styles.badge}><span>빛 각도</span> <span ref={valueRef}>0deg</span></p>
<h1 className={styles.word} ref={wordRef}>요철</h1>
</div>
</main>
);
}02 밝은 값과 어두운 값이 반대로 겹쳐 도드라지는 글자 — 측정 누적면적 10.903% · 움직인 프레임 23/23GODRICH 원작 · zip 에 SCSS·React 포함 · css 텍스트 그림자 효과 9가지 — 층 값이 입체를 만든다
이 데모가 속한 글
css 텍스트 그림자 효과 9가지 — 층 값이 입체를 만든다css 텍스트 그림자 효과는 text-shadow 값 하나를 층 문자열로 계산해 조립하는 아홉 가지 패턴이다. 그림자는 빛이 사라진 자리인데, 이 아홉 글자는 그림자만으로 빛을 대신한다 — 01번은 겹친 층 값으로 이 글의 데모 전부 보기


