react-localstorage-keyboard-nav
하는 일
이 스킬은 상태를 기억하고 키보드로 작동하는 React 컴포넌트를 만드는 방법을 보여 줍니다. 메뉴와 명령 팔레트 스타일의 목록을 다룹니다. React 인터페이스를 만드는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓화살표 키와 Enter로 이동할 수 있는 React 메뉴나 목록을 원할 때.
- ✓페이지를 새로고침한 뒤에도 컴포넌트가 마지막 선택을 기억하기를 원할 때.
- ✓React로 명령 팔레트나 검색 팝업을 만들고 있을 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/react-localstorage-keyboard-nav/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“마지막으로 고른 항목을 기억하고 화살표 키로 쓸 수 있는 React 명령 메뉴를 만들어 주실 수 있나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
작은 사용자 정의 도우미가 값을 localStorage에 저장합니다. 다른 도우미는 화살표 키와 Enter를 감지해, 사용자가 목록을 이동하고 항목을 고를 수 있게 합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
React Components with localStorage Persistence & Keyboard Navigation
This skill guides you through creating reusable React components that:
- Persist state to localStorage
- Implement keyboard navigation
- Follow modal/command palette patterns
Core Pattern
// 1. Define localStorage hooks
const useLocalStorage = (key: string, initialValue: any) => {
const [value, setValue] = useState(() => {
const stored = localStorage.getItem(key);
return stored ? JSON.parse(stored) : initialValue;
});
useEffect(() => {
localStorage.setItem(key, JSON.stringify(value));
}, [key, value]);
return [value, setValue];
};
// 2. Implement keyboard navigation
const useKeyboardNav = (items: any[], onSelect: (item: any) => void) => {
const [selectedIndex, setSelectedIndex] = useState(0);
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'ArrowDown') {
setSelectedIndex(prev => Math.min(prev + 1, items.length - 1));
} else if (e.key === 'ArrowUp') {
setSelectedIndex(prev => Math.max(prev - 1, 0));
} else if (e.key === 'Enter') {
onSelect(items[selectedIndex]);
}
};
useEffect(() => {
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}, [selectedIndex, items]);
return { selectedIndex };
};
Implementation Steps
Create Component Scaffolding
mkdir -p src/components/{Modal,CommandPalette} touch src/components/Modal/SettingsModal.tsx touch src/components/CommandPalette/CommandPalette.tsxImplement localStorage Persistence
// SettingsModal.tsx const SettingsModal = () => { const [settings, setSettings] = useLocalStorage('app-settings', DEFAULT_SETTINGS); // ... modal implementation };Add Keyboard Navigation
// CommandPalette.tsx const CommandPalette = ({ commands }) => { const { selectedIndex } = useKeyboardNav(commands, (cmd) => cmd.action()); // ... render commands with highlighted selectedIndex };Export Components
// src/components/index.ts export * from './Modal/SettingsModal'; export * from './CommandPalette/CommandPalette';
Best Practices
- Create a
settings-keys.tsfile to manage localStorage keys - Use TypeScript interfaces for settings/commands
- Implement proper focus management for accessibility
자주 묻는 질문
특정 React 버전이 필요한가요?
예시는 표준 React 훅을 사용하므로, 대부분의 최신 React 프로젝트에 맞습니다.
상태는 어디에 저장되나요?
같은 기기의 브라우저 localStorage에 저장됩니다.
검색 팝업에 쓸 수 있나요?
네. 스킬은 검색 팝업에 맞는 모달과 명령 팔레트 패턴을 설명합니다.
상세 정보
작성자의 원본 설명
Create React components with localStorage persistence and keyboard navigation support
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #13078
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
agentpilot
7.8k작업을 준비하고 AgentPilot 루프를 실행해 변경을 제안, 테스트, 점수화하면서 프로젝트를 단계적으로 개선하도록 돕습니다.
openspace
7.8k에이전트 스킬을 저장하고 가져오는 도구인 OpenSpace를 설정하고, MCP를 통해 AI 앱에 연결하도록 돕습니다.
rsi-arena
7.8kAIME나 Terminal-Bench 같은 표준 AI 벤치마크 테스트를 설정하고 실행해 서로 다른 개선 방법을 비교하도록 돕습니다.
experiment-guide
7.8k프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.
비슷한 스킬
angular-developer
280k에이전트가 Angular 코드를 만들고 프로젝트 구조를 조언하도록 돕습니다. 새 프로젝트 시작, 코드 부분 생성, 성능과 접근성 개선에 유용합니다.
frontend-a11y
280k모든 사람이 웹 인터페이스를 쓸 수 있도록 에이전트를 돕습니다. 웹사이트와 앱이 화면 읽기 프로그램과 키보드 탐색에서 잘 작동하도록 합니다.
frontend-patterns
280k프론트엔드 개발의 현대적인 패턴을 적용하도록 에이전트를 돕습니다. React와 Next.js에서 성능을 최적화하고, 상태를 관리하며, 모범 사례를 따릅니다.