Kbd (키보드)
Kbd는 키보드 단축키와 키 조합을 표시하는 컴포넌트예요. 해요체로 쉽게 설명드릴게요.
출처: HeroUI Kbd
본문
사용법 (Usage)
import { Kbd } from "@heroui/react";
{"name": "kbd-basic"}
구조 (Anatomy)
import { Kbd } from "@heroui/react";
export default () => (
<Kbd>
<Kbd.Abbr title="Command">⌘</Kbd.Abbr>
<Kbd.Content>K</Kbd.Content>
</Kbd>
);
예시 (Examples)
변형 (Variants)
{"name": "kbd-variants"}
내비게이션 키 (Navigation Keys)
{"name": "kbd-navigation-keys"}
인라인 사용 (Inline Usage)
{"name": "kbd-inline-usage"}
안내 텍스트 (Instructional Text)
{"name": "kbd-instructional-text"}
특수 키 (Special Keys)
{"name": "kbd-special-keys"}
커스터마이징 (Customization)
Tailwind CSS
{"name": "kbd-custom-styles"}
Global CSS
Kbd 컴포넌트 클래스를 커스터마이징하려면 @layer components 지시어를 사용할 수 있어요.
더 알아보기.
@layer components {
.kbd {
@apply bg-gray-100 dark:bg-gray-800 border-gray-300;
}
.kbd__abbr {
@apply font-bold;
}
.kbd__content {
@apply text-sm;
}
}
스타일링 참고 (Styling Reference)
HeroUI는 BEM 방법론을 따라 컴포넌트 변형과 상태를 재사용하고 쉽게 커스터마이징할 수 있게 해요.
CSS 클래스 (CSS Classes)
Kbd 컴포넌트는 다음 CSS 클래스를 사용해요 (소스 스타일 보기):
기본 클래스 [!toc]
.kbd- 배경, 테두리, 간격이 있는 기본 키보드 키 스타일.kbd__abbr- 수정 키용 약어 요소.kbd__content- 키 텍스트용 콘텐츠 래퍼
API 참고 (API Reference)
Kbd
| Prop | Type | Default | Description |
|---|---|---|---|
children |
React.ReactNode |
- | Content of the key |
variant |
`"default" | "light"` | default |
className |
string |
- | Custom CSS classes |
Kbd.Abbr
| Prop | Type | Default | Description |
|---|---|---|---|
title |
string |
- | Title attribute for accessibility (e.g., "Command" for ⌘) |
children |
React.ReactNode |
- | The symbol or text to display (e.g., ⌘, ⌥, ⇧) |
className |
string |
- | Custom CSS classes |
Kbd.Key
| Prop | Type | Default | Description |
|---|---|---|---|
children |
React.ReactNode |
- | Text content of the key |
className |
string |
- | Custom CSS classes |
Kbd.Content 타입 (Type)
keyValue prop에서 사용 가능한 키 값:
| Modifier Keys | Special Keys | Navigation Keys | Function Keys |
|---|---|---|---|
command |
enter |
up |
fn |
shift |
delete |
down |
|
ctrl |
escape |
left |
|
option |
tab |
right |
|
alt |
space |
pageup |
|
win |
capslock |
pagedown |
|
help |
home |
||
end |
더 알아보기 (Learn more)
- React Aria UsesKeyboard - 키보드 키 컴포넌트