npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pt-faq

v1.2.5

Published

Simple and customizable FAQ component for React applications.

Downloads

1,046

Readme

FAQ Component for React

A customizable FAQ (Frequently Asked Questions) React component designed to easily integrate an FAQ section into your application. This component supports light and dark modes and allows for easy customization of styles.

Features

  • Dynamic FAQ List: Easily add and manage FAQs.
  • Light and Dark Mode Support: Customize the appearance for both light and dark themes.
  • Responsive Design: Fully responsive and optimized for all screen sizes.
  • TypeScript Support: Built with TypeScript for better type safety and developer experience.
  • Customizable Styles: Use Tailwind CSS classes to customize the appearance of the FAQ component.

Installation

To install the package, use npm:

npm install pt-faq

Note: You also need to install and configure Tailwind CSS if it isn't already in your project. Follow the Tailwind CSS installation guide if necessary.

Usage

Here’s how you can use the FAQ component in your project:


// src/App.tsx
import React from 'react';
import { FAQ } from "pt-faq";

const faqs = [
  {
    question: "What is your return policy?",
    answer: "You can return any item within 30 days for a full refund.",
  },
  {
    question: "Do you offer international shipping?",
    answer: "Yes, we ship worldwide. Shipping costs will be calculated at checkout.",
  },
  {
    question: "How can I track my order?",
    answer: "You will receive a tracking number via email once your order has shipped.",
  },
  {
    question: "Can I change my order after placing it?",
    answer: "Once an order is placed, it cannot be modified. However, you can cancel it within 1 hour of placing it.",
  },
];

const App = () => {
  return (
    <div className="App">
      <FAQ
        faqs={faqs}
        contact={{ url: "https://example.com/contact" }}
        classNames={{
          section: 'mx-auto h-full max-w-7xl px-2 py-10 md:px-0 bg-gradient-to-r from-white to-gray-100 dark:from-black dark:to-gray-900',
          container: 'mx-auto mt-8 rounded-xl max-w-3xl space-y-4 md:mt-16 ',
          border: 'cursor-pointer rounded-md border shadow-lg transition-all duration-200 hover:shadow-lg hover:border-black',
          question: 'flex text-lg font-semibold text-blue-600 dark:text-blue-400',  // Adjusted for clarity
          answer: 'text-gray-600 dark:text-gray-400',
          button: 'bg-blue-100 dark:bg-gray-700 flex w-full items-center justify-between px-4 py-5 sm:p-6',
          link: 'text-base mt-6 text-center text-gray-600 dark:text-gray-400',
        }}
      />
    </div>
  );
};

export default App;

Props

| Prop | Type | Required | Description | | -------------- | -------------- | -------------- | -------------- | | faqs |Array<{ question: string; answer: string }> | Yes | An array of objects containing questions and answers for the FAQ section.| | contact | { url: string } | No| Optional. Adds a "Contact Us" link if users can't find the answer. | | colors | Object | No | Customize colors for both light and dark modes (background, text, border). |

Customization

  • This package allows full customization using Tailwind CSS classes. To change the background, text, and border colors, simply pass the relevant Tailwind CSS classes via the className prop.

  • Add a contact link by passing the contact prop with a url.

Example for light mode:

  <FAQ 
  faqs={faqItems} 
  className="bg-white text-gray-900 border-gray-200"
/>

Example for dark mode:

<FAQ 
faqs={faqItems} 
className="bg-gray-900 text-white border-gray-700"
/>

Example of Contact Link

    <FAQ
     faqs={faqs}
     contact={{ url: 'https://yourwebsite.com/contact' }}
    />

Styling With Tailwind

Ensure Tailwind CSS is set up in your project. You can install it by following the Tailwind CSS Installation Guide.

Development

If you’d like to contribute or modify this package, follow these steps:


    git clone https://github.com/impriyanshu29/faq-npm.git
    cd my-faq-package
    npm install
    npm run build

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

  • This project was inspired by the need for a simple and customizable FAQ component for React applications.

  • Special thanks to the React community for their support and feedback.

Contact

For any questions or feedback, feel free to reach me at Email me