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

@tailus/themer-accordion

v0.0.6

Published

Accordion themes

Downloads

3

Readme

Accordion Component Theme Documentation

Overview

The accordion component theme is a collection of Tailwindcss utilities that can be used to create accordion components with different styles, and variants. Accordion components are used to display a list of content sections that can be expanded and collapsed individually.

Installation

To install the accordion component theme, run the following command:

npm install @tailus/themer-accordion

Importation

To import the accordion component theme, you can use the following import:

import {
    accordion,
    outlinedAccordion,
    softAccordion,
    ghostAccordion,
    outlinedElevatedAccordion,
} from "@tailus/themer-accordion";

Variants

The accordion component theme provides four variants:

  • accordion (default): The default variant.
  • outlined: An outlined variant with rounded corners and lighter border colors.
  • soft: A soft variant with rounded corners and lighter background colors.
  • ghost: A ghost variant with no borders or background colors.
  • outlinedElevated: An outlined variant with elevated borders.

Reference

The accordion component theme contains the following properties:

accordion = {
    root: string;
    item: string;
    trigger: {
        parent: string;
        content: string;
        icon: string;
    };
    content: string;
};
  • root: The Tailwindcss utility for the root element of the accordion component.
  • item: The Tailwindcss utility for the accordion item.
  • trigger: An object containing the Tailwindcss utilities for the trigger element, which is used to expand and collapse the accordion item.
    • parent: The Tailwindcss utility for the parent element of the trigger element.
    • content: The Tailwindcss utility for the content of the trigger element.
    • icon: The Tailwindcss utility for the icon of the trigger element.
  • content: The Tailwindcss utility for the content of the accordion item.

Usage

To use the accordion component theme, simply import the appropriate variant and add the appropriate Tailwindcss utilities to the accordion element and its child elements. For example, to create a default accordion component, you would import the accordion variant and add its properties to the accordion element.

Example

Radix-UI

import React from "react";
import classNames from "classnames";
import * as Accordion from "@radix-ui/react-accordion";
import { ChevronDownIcon } from "@radix-ui/react-icons";
import { accordion as accordionTheme } from "@tailus/themer-accordion";

const AccordionUI = () => (
    <Accordion.Root
        className="w-full min-w-[28rem] max-w-md"
        type="single"
        defaultValue="item-1"
        collapsible
    >
        <AccordionItem value="item-1">
            <AccordionTrigger>Is it accessible? </AccordionTrigger>
            <AccordionContent>Yes. It adheres to the WAI-ARIA design pattern.</AccordionContent>
        </AccordionItem>

        <AccordionItem value="item-2">
            <AccordionTrigger>Is it unstyled?</AccordionTrigger>
            <AccordionContent>
                Yes. It's unstyled by default, giving you freedom over the look and feel.
            </AccordionContent>
        </AccordionItem>

        <AccordionItem value="item-3">
            <AccordionTrigger>Can it be animated?</AccordionTrigger>
            <AccordionContent>
                Yes! You can animate the Accordion with CSS or JavaScript.
            </AccordionContent>
        </AccordionItem>
    </Accordion.Root>
);

const AccordionItem = React.forwardRef(({ children, className, ...props }: any, forwardedRef) => (
    <Accordion.Item
        className={classNames(accordionTheme.item, className)}
        {...props}
        ref={forwardedRef}
    >
        {children}
    </Accordion.Item>
));

const AccordionTrigger = React.forwardRef(
    ({ children, className, ...props }: any, forwardedRef) => (
        <Accordion.Header className="flex">
            <Accordion.Trigger
                className={classNames(accordionTheme.trigger.parent, className)}
                {...props}
                ref={forwardedRef}
            >
                {children}
                <ChevronDownIcon
                    className={classNames(accordionTheme.trigger.icon, className)}
                    aria-hidden
                />
            </Accordion.Trigger>
        </Accordion.Header>
    )
);

const AccordionContent = React.forwardRef(
    ({ children, className, ...props }: any, forwardedRef) => (
        <Accordion.Content
            className={classNames(accordionTheme.content, className)}
            {...props}
            ref={forwardedRef}
        >
            <div className="pb-4">{children}</div>
        </Accordion.Content>
    )
);

export default AccordionUI;

Customization

The accordion component theme can be customized using the config file. The following example shows how to customize the accordion component theme:

// tailwind.config.js
tailus: {
    components: {
        accordion: {
            borderRadius: "xl",
            borderColor : "gray.200",
            borderHoverColor : "gray.300",
            background : "gray.100",
            backgroundHover : "gray.200",
            shadow : {
                size : "lg",
                opacity:"10"
            },
            dark : {
                borderColor : "gray.800",
                borderHoverColor : "gray.700",
                background : "gray.900",
                backgroundHover : "gray.800",
            }
        },
    },
},