React Card & Modal Components

Accessible React component library with Card (4 variants), Modal (portal, focus trap, ARIA), SettingsPanel, and hooks: useFocusTrap, usePrefersReducedMotion, useModal. Keyboard navigation, screen reader support, reduced motion. Create React App, PropTypes, plain CSS.

Card Components

Card Variants

Four variants: default, elevated, outlined, compact. Interactive mode supports keyboard (Enter/Space) and click.

Default card
Elevated card
Outlined card
Compact card

Props & Accessibility

  • title, subtitle, image, actions
  • variant: default | elevated | outlined | compact
  • interactive → role="button", tabIndex=0
  • Enter/Space to activate when interactive
  • PropTypes validation

React Hooks

useFocusTrap

Keeps focus inside modal; restores on close. Tab/Shift+Tab wrap; Escape restores focus.

usePrefersReducedMotion

matchMedia('(prefers-reduced-motion: reduce)'). Respect system preference.

useModal

Reusable open/close state and optional payload.

SettingsPanel & Accessibility

SettingsPanel

  • Dense layout toggle (tighter spacing)
  • Disable animations (session)
  • System "Reduce motion" notice when set
  • aria-label, aria-describedby on options

Accessibility

  • Focus trap in modal
  • Keyboard: Tab, Enter, Space, Escape
  • ARIA attributes throughout
  • prefers-reduced-motion in CSS
  • prefers-contrast: high support

Complete Feature Set

Components

  • Card (4 variants, interactive)
  • Modal (portal, focus trap, 4 sizes)
  • SettingsPanel (dense, disable animations)

Hooks & Utils

  • useFocusTrap
  • usePrefersReducedMotion
  • useModal
  • utils/constants.js

About This Project

Project Overview

React Card & Modal Components is an accessible React component library with Card (default, elevated, outlined, compact), Modal (createPortal, focus trap, ARIA), and SettingsPanel. Built with React 18, Create React App, PropTypes, and plain CSS. Focus trap, keyboard navigation, screen reader support, and reduced-motion friendly.

By Molla Samser (RSK World). Designer & Tester: Rima Khatun. 2026.

Quick Stats

Version: 1.0.0
License: MIT
React: 18.2.0
Stack: CRA, PropTypes, CSS

Project Structure

SEO & Keywords

Primary Keywords

  • react card component
  • react modal component
  • focus trap
  • ARIA
  • createPortal
  • react portal
  • accessible modal
  • useFocusTrap
  • usePrefersReducedMotion
  • useModal
  • react accessibility
  • WCAG
  • keyboard navigation
  • reduced motion
  • RSK World

Page SEO

100%
SEO-Optimized
Meta Title & Description
Open Graph
Semantic HTML

Semantic headings (h1, h2, h3), meta description, keywords, canonical URL, author, and Open Graph tags for React Card & Modal Components demo.

Step-by-Step Installation Guide

Prerequisites

Before installing, ensure you have:

  • Node.js – version 14 or higher (18.x recommended). Check with node -v
  • npm – comes with Node.js. Check with npm -v
  • A code editor (e.g. VS Code, Cursor) and a terminal/command prompt

Installation Steps

  1. Download the project Download react-card-modal.zip from the project page (use the "Download Source Code" button above) or clone the repository if you have the repo URL.
  2. Extract the archive Unzip react-card-modal.zip into a folder of your choice (e.g. react-card-modal). Avoid paths with spaces or special characters.
  3. Open a terminal in the project folder cd react-card-modal (or your folder name). On Windows you can open the folder in File Explorer and type cmd or powershell in the address bar, or use "Open in Terminal" from your editor.
  4. Install dependencies Run npm install. Wait until all packages are installed. This installs React, react-dom, react-scripts, and prop-types.
  5. Start the development server Run npm start. The app will open in your browser at http://localhost:3000. If it doesn’t, open that URL manually. Leave the terminal open while developing.
  6. Optional: build for production Run npm run build. This creates an optimized build in the build folder, ready to deploy to any static host.
  7. Optional: run tests Run npm test to run the test suite (Create React App default setup).

What You’ll See After npm start

  • Header: "React Card & Modal Components" with author info
  • Settings panel: Dense layout & Disable animations toggles
  • Card grid: 4 clickable cards (Interactive, Outlined, Compact, Default)
  • Modal features grid and "Quick Demo" buttons
  • Click any card or "Open Sample Modal" to see the modal with focus trap
  • "Keyboard Shortcuts" button opens a small modal with Tab / Escape hints

Integrate Into Your App

  • Copy src/components, src/hooks, src/utils into your React project
  • In your public/index.html (or root HTML), add <div id="modal-root"></div> so Modal can use createPortal
  • Import Card, Modal, SettingsPanel and hooks as needed; ensure your app uses React 18

Troubleshooting

  • Port 3000 already in use – Stop the other process or run npm start and choose a different port when prompted (e.g. 3001).
  • npm install fails – Try npm cache clean --force, then npm install again. Ensure Node 14+ and a stable internet connection.
  • Modal doesn’t show or focus trap doesn’t work – Ensure #modal-root exists in your HTML and useFocusTrap ref is attached to the modal content div.
  • Blank page – Check the browser console for errors. Confirm id="root" exists and your entry file (e.g. index.js) renders the app into it.

Available Scripts

npm start
Dev Server
npm run build
Production
npm test
Testing

Detailed Feedback About the Project

Summary

React Card & Modal Components is a focused, accessible React UI kit: Card (4 variants, interactive), Modal (portal, focus trap, ARIA), and SettingsPanel, plus three hooks. It’s well-structured, light on dependencies, and strong on accessibility. Ideal for learning or for production apps that need accessible cards and modals without a full design system. By Molla Samser (RSK World), 2026.

Credits & Contact

Author

Molla Samser – Founder, RSK World. Designer & Tester: Rima Khatun. React Card & Modal Components © 2026.

rskworld.in | +91 93305 39277 | info@rskworld.com

License

MIT License. Use in personal and commercial projects. Attribution to Molla Samser / RSK World appreciated. See LICENSE file.