faq-mars
Version:
A customizable, accessible FAQ/accordion component for React applications with built-in styling.
98 lines (75 loc) • 2.25 kB
Markdown
A customizable, accessible FAQ/accordion component for React applications with built-in styling.

- 🎨 **Auto-included CSS** with zero-config styling
- ♿ Built with accessibility (ARIA) support
- 🌀 Smooth fade-in animations and toggle transitions
- 📦 **No CSS imports needed** - styles bundled automatically
- 🌐 PropTypes validation with error warnings
- 🧩 Dual module support (CJS + ESM)
- 🛠️ CSS Variables for easy theme customization
## Installation 📦
```bash
npm install faq-mars
## Peer Dependencies ⚙️
## Ensure these are installed in your host project:
bash
npm install react react-dom prop-types
##### basic usage:
import React from 'react';
import Faq from 'faq-mars';
import 'faq-mars/dist/Faq.css';
const App = () => {
const faqItems = [
{
question: "How does it work?",
answer: "This component provides an interactive FAQ interface."
},
{
question: "Can I customize it?",
answer: <div>Yes! Use <code>className</code> props or CSS variables.</div>
}
];
return (
<div style={{ maxWidth: '800px', margin: '0 auto' }}>
<h1>Project FAQ</h1>
<Faq items={faqItems} />
</div>
);
};
1. Using CSS Classes
javascript
<Faq
items={items}
className="custom-container"
itemClassName="custom-item"
questionClassName="custom-question"
answerClassName="custom-answer"
/>
/* In your global CSS */
.faq-container {
--faq-border-color:
--faq-bg-color:
--faq-hover-bg:
--faq-text-color:
--faq-transition-speed: 0.3s;
--faq-border-radius: 8px;
}
/* Custom question style */
.custom-question {
background: linear-gradient(90deg,
color: white;
border-radius: 8px;
font-family: 'Comic Sans MS', cursive;
}
/* Custom answer animation */
.custom-answer {
background:
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
License 📄
MIT © raj kamal