|
| 1 | +--- |
| 2 | +title: 카운터 스타일링 |
| 3 | +description: CSS로 키 카운터의 모양과 효과를 커스터마이징하는 방법 |
| 4 | +--- |
| 5 | + |
| 6 | +# 카운터 스타일링 |
| 7 | + |
| 8 | +이 가이드에서는 CSS를 사용하여 키 카운터의 모양을 커스터마이징하는 방법을 설명합니다. |
| 9 | + |
| 10 | +## 기본 구조 |
| 11 | + |
| 12 | +카운터는 `.counter` 클래스와 `data-counter-state` 속성을 통해 상태를 나타냅니다: |
| 13 | + |
| 14 | +- `data-counter-state="inactive"`: 키를 누르지 않은 상태 |
| 15 | +- `data-counter-state="active"`: 키를 누르고 있는 상태 |
| 16 | + |
| 17 | +## 전역 카운터 스타일 |
| 18 | + |
| 19 | +모든 카운터에 공통으로 적용되는 스타일을 설정합니다: |
| 20 | + |
| 21 | +```css |
| 22 | +.counter { |
| 23 | + /* 폰트 스타일 */ |
| 24 | + font-size: 24px; |
| 25 | + font-weight: 700; |
| 26 | + |
| 27 | + /* 폰트 패밀리 */ |
| 28 | + font-family: "Roboto Mono", monospace; |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +## CSS 변수 |
| 33 | + |
| 34 | +카운터는 다음 CSS 변수를 지원합니다: |
| 35 | + |
| 36 | +| 변수 | 설명 | 기본값 | |
| 37 | +| ------------------------ | ------------------ | ------------- | |
| 38 | +| `--counter-color` | 텍스트 색상 | `#FFFFFF` | |
| 39 | +| `--counter-stroke-color` | 텍스트 외곽선 색상 | `transparent` | |
| 40 | +| `--counter-stroke-width` | 텍스트 외곽선 두께 | `0px` | |
| 41 | + |
| 42 | +## 비활성 상태 스타일 |
| 43 | + |
| 44 | +키를 누르지 않았을 때의 카운터 스타일입니다: |
| 45 | + |
| 46 | +```css |
| 47 | +.counter[data-counter-state="inactive"] { |
| 48 | + /* 텍스트 색상 */ |
| 49 | + --counter-color: #474244; |
| 50 | + |
| 51 | + /* 외곽선 비활성화 */ |
| 52 | + --counter-stroke-color: transparent; |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +## 활성 상태 스타일 |
| 57 | + |
| 58 | +키를 누르고 있을 때의 카운터 스타일입니다: |
| 59 | + |
| 60 | +```css |
| 61 | +.counter[data-counter-state="active"] { |
| 62 | + /* 텍스트 색상 */ |
| 63 | + --counter-color: #ff2b80; |
| 64 | + |
| 65 | + /* 외곽선 */ |
| 66 | + --counter-stroke-color: transparent; |
| 67 | + |
| 68 | + /* 글로우 효과 */ |
| 69 | + text-shadow: 0px 0px 3px #ff2b80; |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +## 특정 키의 카운터 스타일 |
| 74 | + |
| 75 | +클래스 선택자를 조합하여 특정 키의 카운터만 다르게 스타일링할 수 있습니다. |
| 76 | + |
| 77 | +### 예제: 파란색 키의 카운터 |
| 78 | + |
| 79 | +```css |
| 80 | +/* .blue 클래스를 가진 키의 카운터 - 비활성 상태 */ |
| 81 | +.blue .counter[data-counter-state="inactive"] { |
| 82 | + --counter-color: #1a4a5c; |
| 83 | +} |
| 84 | + |
| 85 | +/* .blue 클래스를 가진 키의 카운터 - 활성 상태 */ |
| 86 | +.blue .counter[data-counter-state="active"] { |
| 87 | + --counter-color: #2ebef3; |
| 88 | + --counter-stroke-color: transparent; |
| 89 | + text-shadow: 0px 0px 3px #2ebef3; |
| 90 | +} |
| 91 | +``` |
| 92 | + |
| 93 | +<Callout type="info"> |
| 94 | + 클래스 조합을 사용하면 키와 카운터의 색상을 일치시켜 통일감 있는 디자인을 만들 |
| 95 | + 수 있습니다. |
| 96 | +</Callout> |
| 97 | + |
| 98 | +## 스타일 예제 |
| 99 | + |
| 100 | +### 네온 글로우 스타일 |
| 101 | + |
| 102 | +```css |
| 103 | +.counter { |
| 104 | + font-size: 20px; |
| 105 | + font-weight: 700; |
| 106 | +} |
| 107 | + |
| 108 | +.counter[data-counter-state="inactive"] { |
| 109 | + --counter-color: #333; |
| 110 | +} |
| 111 | + |
| 112 | +.counter[data-counter-state="active"] { |
| 113 | + --counter-color: #00ff88; |
| 114 | + text-shadow: 0px 0px 2px #00ff88, 0px 0px 4px #00ff88, 0px 0px 8px #00ff88; |
| 115 | +} |
| 116 | +``` |
| 117 | + |
| 118 | +### 외곽선 스타일 |
| 119 | + |
| 120 | +```css |
| 121 | +.counter { |
| 122 | + font-size: 28px; |
| 123 | + font-weight: 900; |
| 124 | +} |
| 125 | + |
| 126 | +.counter[data-counter-state="inactive"] { |
| 127 | + --counter-color: #fff; |
| 128 | + --counter-stroke-color: #333; |
| 129 | + --counter-stroke-width: 2px; |
| 130 | +} |
| 131 | + |
| 132 | +.counter[data-counter-state="active"] { |
| 133 | + --counter-color: #fff; |
| 134 | + --counter-stroke-color: #ff2b80; |
| 135 | + --counter-stroke-width: 2px; |
| 136 | +} |
| 137 | +``` |
| 138 | + |
| 139 | +### 미니멀 스타일 |
| 140 | + |
| 141 | +```css |
| 142 | +.counter { |
| 143 | + font-size: 14px; |
| 144 | + font-weight: 400; |
| 145 | + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; |
| 146 | +} |
| 147 | + |
| 148 | +.counter[data-counter-state="inactive"] { |
| 149 | + --counter-color: #999; |
| 150 | +} |
| 151 | + |
| 152 | +.counter[data-counter-state="active"] { |
| 153 | + --counter-color: #333; |
| 154 | +} |
| 155 | +``` |
| 156 | + |
| 157 | +### 레인보우 그라데이션 스타일 |
| 158 | + |
| 159 | +```css |
| 160 | +.counter[data-counter-state="active"] { |
| 161 | + background: linear-gradient( |
| 162 | + 45deg, |
| 163 | + #ff2b80, |
| 164 | + #ff8c00, |
| 165 | + #ffee00, |
| 166 | + #00ff88, |
| 167 | + #00bfff, |
| 168 | + #8b5cf6 |
| 169 | + ); |
| 170 | + background-size: 300% 300%; |
| 171 | + -webkit-background-clip: text; |
| 172 | + -webkit-text-fill-color: transparent; |
| 173 | + animation: rainbow 2s ease infinite; |
| 174 | +} |
| 175 | + |
| 176 | +@keyframes rainbow { |
| 177 | + 0% { |
| 178 | + background-position: 0% 50%; |
| 179 | + } |
| 180 | + 50% { |
| 181 | + background-position: 100% 50%; |
| 182 | + } |
| 183 | + 100% { |
| 184 | + background-position: 0% 50%; |
| 185 | + } |
| 186 | +} |
| 187 | +``` |
| 188 | + |
| 189 | +## 키와 카운터 색상 맞추기 |
| 190 | + |
| 191 | +키와 카운터 색상을 일관되게 유지하는 예제입니다: |
| 192 | + |
| 193 | +```css |
| 194 | +/* 기본 키 - 핑크 테마 */ |
| 195 | +[data-state="active"] { |
| 196 | + --key-border: 3px solid #ff2b80; |
| 197 | + --key-text-color: #ff2b80; |
| 198 | + text-shadow: 0px 0px 3px #ff2b80; |
| 199 | +} |
| 200 | + |
| 201 | +.counter[data-counter-state="active"] { |
| 202 | + --counter-color: #ff2b80; |
| 203 | + text-shadow: 0px 0px 3px #ff2b80; |
| 204 | +} |
| 205 | + |
| 206 | +/* 파란색 키 - 블루 테마 */ |
| 207 | +.blue[data-state="active"] { |
| 208 | + --key-border: 3px solid #2ebef3; |
| 209 | + --key-text-color: #2ebef3; |
| 210 | + text-shadow: 0px 0px 3px #2ebef3; |
| 211 | +} |
| 212 | + |
| 213 | +.blue .counter[data-counter-state="active"] { |
| 214 | + --counter-color: #2ebef3; |
| 215 | + text-shadow: 0px 0px 3px #2ebef3; |
| 216 | +} |
| 217 | +``` |
| 218 | + |
| 219 | +## 고급 팁 |
| 220 | + |
| 221 | +### 숫자 폰트 최적화 |
| 222 | + |
| 223 | +카운터 숫자가 변경될 때 레이아웃이 흔들리지 않도록 고정폭 숫자를 사용합니다: |
| 224 | + |
| 225 | +```css |
| 226 | +.counter { |
| 227 | + font-variant-numeric: tabular-nums; |
| 228 | + font-feature-settings: "tnum"; |
| 229 | +} |
| 230 | +``` |
| 231 | + |
| 232 | +### 카운터 크기 제한 |
| 233 | + |
| 234 | +큰 숫자에서도 레이아웃이 깨지지 않도록 최소/최대 너비를 설정합니다: |
| 235 | + |
| 236 | +```css |
| 237 | +.counter { |
| 238 | + min-width: 30px; |
| 239 | + text-align: center; |
| 240 | +} |
| 241 | +``` |
0 commit comments