Component

Basic Accordion

Simple documentation accordion with chevron rotation and smooth height animation. Clean, accessible, and ready for knowledge bases and developer docs.

  • Component
  • Tailwind
  • HTML
  • MIT

What it does

Capabilities

  • Chevron rotation
  • Height animation
  • Independent toggles
  • Focus rings
  • Aria-expanded
  • Grid-rows animation

Preview

Live component

Interactive preview
Open preview
9:41 100%
devsnips.site/library/tailwind/components/accordions/basic-accordion/
fluid · no fixed width 100%
No dependencies Production-ready

Install

Add to your project

terminal
npx devsnips add Tailwind/Components/Accordions/basic-accordion
registry path: Tailwind/Components/Accordions/basic-accordion

Source

Implementation

code.html
<!--
Snippet Name: Basic Accordion
Description: Simple documentation accordion with chevron rotation and smooth height animation.
Author: DevSnips Contributors
Usage Example: Drop into a docs/knowledge-base layout. Each item toggles independently.
-->
<div class="divide-y divide-gray-200 border-y border-gray-200" data-accordion="basic">
  <div class="group" data-accordion-item>
    <h3>
      <button
        type="button"
        id="basic-trigger-1"
        aria-controls="basic-panel-1"
        aria-expanded="false"
        class="accordion-trigger flex w-full items-center justify-between gap-4 py-4 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 rounded-md"
      >
        <span class="text-sm font-medium text-gray-900">Getting started with the CLI</span>
        <svg class="accordion-chevron h-5 w-5 shrink-0 text-gray-400 transition-transform duration-300 ease-out" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
        </svg>
      </button>
    </h3>
    <div
      id="basic-panel-1"
      role="region"
      aria-labelledby="basic-trigger-1"
      class="accordion-panel grid grid-rows-[0fr] transition-[grid-template-rows] duration-300 ease-out"
    >
      <div class="overflow-hidden">
        <div class="pb-4 pr-8 text-sm leading-relaxed text-gray-600">
          Install the CLI from npm, then run <code class="rounded bg-gray-100 px-1.5 py-0.5 text-[13px] font-medium text-gray-800">devsnips init</code> to scaffold a new project. This creates a folder structure that matches the component family layout used across the library.
        </div>
      </div>
    </div>
  </div>

  <div class="group" data-accordion-item>
    <h3>
      <button
        type="button"
        id="basic-trigger-2"
        aria-controls="basic-panel-2"
        aria-expanded="false"
        class="accordion-trigger flex w-full items-center justify-between gap-4 py-4 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 rounded-md"
      >
        <span class="text-sm font-medium text-gray-900">Configuring environment variables</span>
        <svg class="accordion-chevron h-5 w-5 shrink-0 text-gray-400 transition-transform duration-300 ease-out" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
        </svg>
      </button>
    </h3>
    <div
      id="basic-panel-2"
      role="region"
      aria-labelledby="basic-trigger-2"
      class="accordion-panel grid grid-rows-[0fr] transition-[grid-template-rows] duration-300 ease-out"
    >
      <div class="overflow-hidden">
        <div class="pb-4 pr-8 text-sm leading-relaxed text-gray-600">
          Copy the example file to <code class="rounded bg-gray-100 px-1.5 py-0.5 text-[13px] font-medium text-gray-800">.env.local</code> and fill in your API keys. Variables are loaded automatically and validated at startup, so the app fails fast if a required value is missing.
        </div>
      </div>
    </div>
  </div>

  <div class="group" data-accordion-item>
    <h3>
      <button
        type="button"
        id="basic-trigger-3"
        aria-controls="basic-panel-3"
        aria-expanded="false"
        class="accordion-trigger flex w-full items-center justify-between gap-4 py-4 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 rounded-md"
      >
        <span class="text-sm font-medium text-gray-900">Deploying to production</span>
        <svg class="accordion-chevron h-5 w-5 shrink-0 text-gray-400 transition-transform duration-300 ease-out" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
        </svg>
      </button>
    </h3>
    <div
      id="basic-panel-3"
      role="region"
      aria-labelledby="basic-trigger-3"
      class="accordion-panel grid grid-rows-[0fr] transition-[grid-template-rows] duration-300 ease-out"
    >
      <div class="overflow-hidden">
        <div class="pb-4 pr-8 text-sm leading-relaxed text-gray-600">
          Push to the <code class="rounded bg-gray-100 px-1.5 py-0.5 text-[13px] font-medium text-gray-800">main</code> branch to trigger the preview pipeline. Once CI passes and a reviewer approves, promote the preview to production from the dashboard with a single click.
        </div>
      </div>
    </div>
  </div>

  <script>
    (function () {
      const root = document.currentScript.closest('[data-accordion]');
      if (!root) return;
      root.querySelectorAll('[data-accordion-item]').forEach((item) => {
        const trigger = item.querySelector('.accordion-trigger');
        const panel = item.querySelector('.accordion-panel');
        const chevron = item.querySelector('.accordion-chevron');
        if (!trigger || !panel) return;
        const toggle = () => {
          const open = trigger.getAttribute('aria-expanded') === 'true';
          trigger.setAttribute('aria-expanded', String(!open));
          panel.classList.toggle('grid-rows-[1fr]', !open);
          panel.classList.toggle('grid-rows-[0fr]', open);
          if (chevron) chevron.style.transform = open ? '' : 'rotate(180deg)';
        };
        trigger.addEventListener('click', toggle);
      });
    })();
  </script>
</div>
115 lines UTF-8 · LF · Spaces: 2
DevSnips AI ready Claude · Cursor · Windsurf

Agent skill & Model Context Protocol

Pass this component straight into your AI workflow. DevSnips exposes each resource as a structured, addressable registry entry, so your agent installs the real files instead of approximating them.

devsnips://components/accordions/basic-accordion
Prompt instruction
I want to use this DevSnips resource in production:

Page:
https://devsnips.site/library/tailwind/components/accordions/basic-accordion/

Install: npx devsnips add
Tailwind/Components/Accordions/basic-accordion

This is the Basic Accordion — Simple documentation accordion with chevron rotation and smooth height animation. Clean, accessible, and ready for knowledge bases and developer docs.

Use this DevSnips resource as the starting point for my project.
Adapt it to my project's stack and conventions, fix any issues,
and make it production-ready while preserving its intended design
and behavior.

Paste into ChatGPT, Claude or your agent — it already carries the page URL and the exact install path.

Resource URI
devsnips://components/accordions/basic-accordion