Rapid Rails UI Pro

Upgrade to unlock this component

Get Pro →

Accordion

A flexible accordion component for creating collapsible content sections with smooth animations, icons, and multiple visual styles.

Key Features

  • Multiple Variants - Default, bordered, separated, flush, ghost
  • Semantic Colors - Primary, success, warning, danger, info, and more
  • Smooth Animations - Powered by Stimulus with configurable transitions
  • Exclusive Mode - One item open at a time, or allow multiple
  • Icon Support - Leading and trailing icons in headers
  • Subtitles - Secondary text below titles for context
  • Custom Chevrons - Position, custom icons, or hide completely
  • Always-Open Items - Non-collapsible pinned content
  • Turbo Frame Support - Lazy load content on expand
  • Accessibility - Full ARIA support with keyboard navigation
  • JavaScript API - Programmatic control with data-action attributes

Basic Usage

Create an accordion with collapsible items using the block syntax. Combine with other components for rich content.

Canada's first national park, established in 1885 in the heart of the Rocky Mountains.

UNESCO Site 6,641 km² Alberta
Learn more about Banff →

One of the world's most powerful waterfalls, straddling the border between Ontario and New York.

750,000 gallons/second 167 feet tall

The Aurora Borealis is visible across northern Canada, with Yukon and Northwest Territories offering the best views.

Best: Sept-March Whitehorse Yellowknife
<%= rui_accordion do |accordion| %>
  <% accordion.with_item(title: "Banff National Park") do %>
    <div class="space-y-3">
      <%= rui_text("Canada's first national park...", size: :sm) %>
      <div class="flex flex-wrap gap-2">
        <%= rui_badge("UNESCO Site", color: :primary, size: :sm) %>
        <%= rui_badge("6,641 km²", color: :success, size: :sm) %>
      </div>
      <%= rui_link("Learn more →", href: "#", size: :sm) %>
    </div>
  <% end %>
  <% accordion.with_item(title: "Niagara Falls") do %>
    ...icons, text, and buttons...
  <% end %>
<% end %>

Colors

Accordions support semantic colors and any Tailwind color that apply to borders, backgrounds, and text.

Semantic Colors

Zinc (Default)

General-purpose language known for readability and extensive libraries.

ML/AI Web Data Science

Primary

JavaScript with static typing for building large-scale applications.

Type Safety

IDE Support

Success

Fast, simple, and built for concurrency. Created at Google.

Visit golang.org →

Danger

Elegant and productive. Optimized for developer happiness.

Rails ❤️

Tailwind Colors

All Tailwind colors are supported with automatic dark mode variants.

Red

Red color support with dynamic styling

Blue

Blue color support with dynamic styling

Purple

Purple color support with dynamic styling

Amber

Amber color support with dynamic styling

<!-- Semantic colors -->
<%= rui_accordion(color: :primary) do |accordion| %>
  <% accordion.with_item(title: "Item 1") do %>
    <div class="space-y-2">...</div>
  <% end %>
<% end %>

<!-- Tailwind colors (all supported!) -->
<%= rui_accordion(color: :red) do |accordion| %>
  <% accordion.with_item(title: "Item 1") do %>...<% end %>
<% end %>
<%= rui_accordion(color: :blue) do |accordion| %>...<% end %>
<%= rui_accordion(color: :purple) do |accordion| %>...<% end %>
<%= rui_accordion(color: :pink) do |accordion| %>...<% end %>

Sizes

Five size options for different contexts. Here featuring classic comedy shows.

Extra Small

1989-1998

NBC

Small

A mockumentary sitcom about everyday office life at Dunder Mifflin.

9 Seasons Emmy Winner

Base (Default)

Six friends navigate life, love, and careers in New York City. One of the most-watched shows in television history.

8.9/10 IMDb

236 Episodes

Large

Detective Jake Peralta and his diverse squad solve crimes while dealing with their quirky captain. A modern comedy classic.

Action Comedy Crime
<%= rui_accordion(size: :base) do |accordion| %>
  <% accordion.with_item(title: "Friends") do %>
    <div class="space-y-2">
      <%= rui_text("Six friends navigate life...", size: :sm) %>
      <div class="flex items-center gap-3">
        <%= rui_icon(:star, size: :sm, color: :warning) %>
        <%= rui_text("8.9/10 IMDb", size: :sm, weight: :medium) %>
        <%= rui_badge("236 Episodes", size: :sm) %>
      </div>
    </div>
  <% end %>
<% end %>

Variants

Different visual styles for various design contexts. Featuring Canadian cities and provinces.

Default

Canada's largest city and financial capital. Home to the CN Tower and diverse neighborhoods.

2.9 million

Capital of ON

A coastal seaport city surrounded by mountains. Known for its film industry and natural beauty.

Pacific Coast Tech Hub

Bordered

The cultural capital of Canada. A bilingual city famous for its festivals, cuisine, and European charm.

Explore Old Montreal →

One of North America's oldest European settlements. UNESCO World Heritage Site.

Founded 1608

Separated

Gateway to the Canadian Rockies. Host of the famous Calgary Stampede rodeo.

Near Banff

Capital of Alberta. Home to West Edmonton Mall, once the world's largest shopping center.

Festival City

Flush

The national capital. Home to Parliament Hill and world-class museums.

Capital of Canada

Major port city on the Atlantic coast. Rich maritime history and vibrant music scene.

Ghost

Geographic center of North America. Known for harsh winters and the Forks historic site.

Capital of BC on Vancouver Island. British colonial architecture and gardens.

<%= rui_accordion(variant: :separated) do |accordion| %>
  <% accordion.with_item(title: "Calgary, Alberta") do %>
    <div class="space-y-2">
      <%= rui_text("Gateway to the Canadian Rockies...", size: :sm) %>
      <div class="flex items-center gap-2">
        <%= rui_icon(:mountain, size: :sm) %>
        <%= rui_text("Near Banff", size: :xs, color: :muted) %>
      </div>
    </div>
  <% end %>
<% end %>

Shapes

Control the border radius of accordion items. Here showcasing music genres from around the world.

Rounded (Default)

Standard rounded corners on first/last items

Born in New Orleans in the early 20th century. Known for improvisation and swing.

1900s USA

African American origin from the Deep South. The foundation of rock and R&B.

Square

Sharp corners throughout

Synthesizers and digital production. From ambient to techno.

House Techno Ambient

Experimental sounds with mechanical and transgressive themes.

Pill

Extra rounded corners on first/last items

Jamaican music with offbeat rhythms. Bob Marley made it global.

Jamaica 🇯🇲

Precursor to reggae with upbeat tempo and horn sections.

None

No border radius

Western art music tradition spanning centuries of orchestral composition.

Explore composers →

Theatrical art form combining singing, orchestral music, and drama.

<%= rui_accordion(shape: :rounded) do |accordion| %>
  <% accordion.with_item(title: "Jazz") do %>
    <div class="space-y-2">
      <%= rui_text("Born in New Orleans...", size: :sm) %>
      <div class="flex gap-2">
        <%= rui_badge("1900s", size: :xs, color: :zinc) %>
        <%= rui_badge("USA", size: :xs, color: :info) %>
      </div>
    </div>
  <% end %>
<% end %>

Item Options

Icons in Headers

Add Lucide icons to accordion headers for visual context.

Configure your application settings and preferences.

Manage your profile information and avatar.

Control how and when you receive notifications.

<%= rui_accordion do |accordion| %>
  <% accordion.with_item(title: "Settings", icon: :settings) do %>
    <%= rui_text("Configure your application settings...", size: :sm, color: :muted) %>
  <% end %>
  <% accordion.with_item(title: "User Profile", icon: :user) do %>
    <%= rui_text("Manage your profile information...", size: :sm, color: :muted) %>
  <% end %>
  <% accordion.with_item(title: "Notifications", icon: :bell) do %>
    <%= rui_text("Control how and when you receive...", size: :sm, color: :muted) %>
  <% end %>
<% end %>

Default Expanded

Set items to be expanded by default.

This section is open when the page loads.

This section starts collapsed.

<%= rui_accordion do |accordion| %>
  <% accordion.with_item(title: "Expanded by Default", expanded: true) do %>
    <%= rui_text("This section is open when the page loads.", size: :sm, color: :muted) %>
  <% end %>
  <% accordion.with_item(title: "Collapsed by Default") do %>
    <%= rui_text("This section starts collapsed.", size: :sm, color: :muted) %>
  <% end %>
<% end %>

Disabled Items

Prevent interaction on specific items.

This section can be toggled.

This section cannot be opened.

This section can also be toggled.

<%= rui_accordion do |accordion| %>
  <% accordion.with_item(title: "Active Section") do %>
    <%= rui_text("This section can be toggled.", size: :sm, color: :muted) %>
  <% end %>
  <% accordion.with_item(title: "Disabled Section", disabled: true) do %>
    <%= rui_text("This section cannot be opened.", size: :sm, color: :muted) %>
  <% end %>
  <% accordion.with_item(title: "Another Active Section") do %>
    <%= rui_text("This section can also be toggled.", size: :sm, color: :muted) %>
  <% end %>
<% end %>

Subtitles

Add secondary text below the title for additional context.

Configure your account details, change email, and update your password.

Manage your subscription, update payment details, and download invoices.

Choose which notifications to receive via email, SMS, or push.

<%= rui_accordion do |accordion| %>
  <% accordion.with_item(title: "Account Settings", subtitle: "Manage your profile and preferences", icon: :user) do %>
    <%= rui_text("Configure your account details...", size: :sm, color: :muted) %>
  <% end %>
  <% accordion.with_item(title: "Billing", subtitle: "View invoices and payment methods", icon: :credit_card) do %>
    <%= rui_text("Manage your subscription...", size: :sm, color: :muted) %>
  <% end %>
<% end %>

Trailing Icons

Add icons after the title for status indicators.

Upgrade to Pro to unlock this feature.

This task has been verified and completed.

<%= rui_accordion do |accordion| %>
  <% accordion.with_item(title: "Pro Feature", icon: :star, icon_trailing: :lock) do %>
    <%= rui_text("Upgrade to Pro to unlock this feature.", size: :sm, color: :muted) %>
  <% end %>
  <% accordion.with_item(title: "Completed Task", icon: :check_circle, icon_trailing: :badge_check) do %>
    <%= rui_text("This task has been verified and completed.", size: :sm, color: :muted) %>
  <% end %>
<% end %>

Always-Open Items

Create items that cannot be collapsed - useful for static headers or pinned content.

Important Notice

This section is always visible and cannot be collapsed.

This section can be toggled open and closed.

<%= rui_accordion do |accordion| %>
  <% accordion.with_item(title: "Important Notice", collapsible: false, icon: :alert_circle) do %>
    <%= rui_text("This section is always visible...", size: :sm, color: :muted) %>
  <% end %>
  <% accordion.with_item(title: "Collapsible Section") do %>
    <%= rui_text("This section can be toggled...", size: :sm, color: :muted) %>
  <% end %>
<% end %>

Chevron Options

Chevron Position

Control where the expand/collapse indicator appears. Featuring Canadian cuisine.

Right (Default)

Fries topped with cheese curds and gravy. Quebec's most famous export.

Quebec Comfort Food

Left

Sweet pastry with butter, sugar, and egg filling. Ontario's signature dessert.

Ontario
<%= rui_accordion(chevron_position: :right) do |accordion| %>
  <% accordion.with_item(title: "Poutine") do %>
    <%= rui_text("Fries topped with cheese curds and gravy...", size: :sm) %>
  <% end %>
<% end %>

<%= rui_accordion(chevron_position: :left) do |accordion| %>
  <% accordion.with_item(title: "Butter Tart") do %>
    <%= rui_text("Sweet pastry with butter, sugar, and egg...", size: :sm) %>
  <% end %>
<% end %>

Custom Expand/Collapse Icons

Use custom icons instead of the default chevron.

Plus/Minus Style

Three-layer dessert bar from British Columbia. No baking required.

See the recipe →

Rotating Icon

Canada produces 71% of the world's maple syrup. Quebec leads production.


<%= rui_accordion(expand_icon: :plus, collapse_icon: :minus) do |accordion| %>
  <% accordion.with_item(title: "Nanaimo Bar") do %>
    <%= rui_text("Three-layer dessert bar...", size: :sm) %>
  <% end %>
<% end %>

<%= rui_accordion(expand_icon: :chevron_down) do |accordion| %>
  <% accordion.with_item(title: "Maple Syrup", expanded: true) do %>
    <%= rui_text("Canada produces 71% of the world's maple syrup.", size: :sm) %>
  <% end %>
<% end %>

Hide Chevron

Remove the expand/collapse icon entirely.

Fried dough pastry shaped like a beaver's tail. Popular at ByWard Market in Ottawa.

Street Food Since 1978

Traditional meat pie from Quebec. A holiday staple across French Canada.

French-Canadian
<%= rui_accordion(show_chevron: false) do |accordion| %>
  <% accordion.with_item(title: "BeaverTails", icon: :cookie) do %>
    <%= rui_text("Fried dough pastry shaped like a beaver's tail.", size: :sm) %>
  <% end %>
<% end %>

Dividers

Control the visual separator between items. Featuring Canadian sports.

With Dividers (Default)

Canada's national winter sport. Home to 7 NHL teams.

NHL

Canada's national summer sport. Indigenous origins.

NLL

Without Dividers

Strategic ice sport. Canada dominates at the Olympics.

Invented by Canadian James Naismith. Toronto Raptors won 2019 NBA title.

2019 Champs 🏆

<%= rui_accordion(dividers: true) do |accordion| %>
  <% accordion.with_item(title: "Hockey") do %>
    <%= rui_text("Canada's national winter sport.", size: :sm) %>
    <%= rui_badge("NHL", size: :xs, color: :primary) %>
  <% end %>
<% end %>

<%= rui_accordion(dividers: false, spacing: :sm) do |accordion| %>
  <% accordion.with_item(title: "Curling") do %>
    <%= rui_text("Strategic ice sport.", size: :sm) %>
  <% end %>
<% end %>

Exclusive Mode

Control whether only one item can be open at a time. Featuring Canadian wildlife.

Exclusive (Default)

Only one item open at a time

The largest deer species. Found across Canada's forests.

Up to 700kg

Iconic predator of Western Canada and the Rockies.

Non-Exclusive

Multiple items can be open

Canada's national animal. Master dam builders.

National Symbol

Migratory bird known for V-formation flight.

Migratory

<%= rui_accordion(exclusive: true) do |accordion| %>
  <% accordion.with_item(title: "Moose") do %>
    <%= rui_text("The largest deer species.", size: :sm) %>
    <%= rui_badge("Up to 700kg", size: :xs) %>
  <% end %>
<% end %>

<%= rui_accordion(exclusive: false) do |accordion| %>
  <% accordion.with_item(title: "Beaver") do %>
    <%= rui_text("Canada's national animal.", size: :sm) %>
  <% end %>
<% end %>

Animation

Toggle smooth expand/collapse animations. Featuring Canadian seasons.

Animated (Default)

Snow-covered landscapes from coast to coast. Best time for skiing and hockey.

-30°C

Maple syrup season in Quebec. Cherry blossoms in Vancouver.

Maple Season

No Animation

Festival season across the nation. Long days with midnight sun in the north.

+35°C

Stunning autumn colors in Ontario and Quebec. Thanksgiving celebrations.


<%= rui_accordion(animate: true) do |accordion| %>
  <% accordion.with_item(title: "Winter") do %>
    <%= rui_text("Snow-covered landscapes...", size: :sm) %>
    <%= rui_badge("-30°C", size: :xs, color: :info) %>
  <% end %>
<% end %>

<%= rui_accordion(animate: false) do |accordion| %>
  <% accordion.with_item(title: "Summer") do %>
    <%= rui_text("Festival season...", size: :sm) %>
  <% end %>
<% end %>

Real-World Examples

FAQ Section

Getting started is easy! Follow these steps:

  1. 1

    Add the gem to your Gemfile

  2. 2

    Run bundle install

  3. 3

    Run the installer

  4. 4

    Start using components!

RapidRailsUI works with:

Rails 7+ Tailwind CSS Turbo Stimulus

Need help? Here are your options:

<%= rui_accordion(variant: :separated, color: :primary) do |accordion| %>
  <% accordion.with_item(title: "How do I get started?", icon: :help_circle) do %>
    <div class="space-y-3">
      <%= rui_text("Getting started is easy!", size: :sm, weight: :medium) %>
      <ol class="space-y-2 ml-4">
        <li class="flex items-start gap-2">
          <%= rui_badge(text: "1", color: :primary, size: :xs, shape: :circle) %>
          <%= rui_text("Add the gem to your Gemfile", size: :sm, color: :muted) %>
        </li>
        ...
      </ol>
    </div>
  <% end %>
  <% accordion.with_item(title: "What frameworks are supported?", icon: :code) do %>
    <div class="flex flex-wrap gap-2">
      <%= rui_badge(text: "Rails 7+", color: :danger, size: :sm) %>
      <%= rui_badge(text: "Tailwind CSS", color: :info, size: :sm) %>
    </div>
  <% end %>
<% end %>

User Settings Panel

JD

John Doe

john@example.com

Display Name

John Doe

Username

@johndoe

Profile Visibility

Public

Show Activity Status

On

Two-Factor Auth

Enabled

Email Notifications

Enabled

Push Notifications

Disabled

SMS Alerts

Off
<%= rui_accordion(variant: :flush, exclusive: false) do |accordion| %>
  <% accordion.with_item(title: "Account Settings", icon: :user, expanded: true) do %>
    <div class="space-y-4 py-2">
      <div class="flex items-center gap-4">
        <%= rui_avatar(name: "John Doe", size: :lg, status: :online) %>
        <div>
          <%= rui_text("John Doe", size: :base, weight: :semibold) %>
          <%= rui_text("john@example.com", size: :sm, color: :muted) %>
        </div>
      </div>
    </div>
  <% end %>
  <% accordion.with_item(title: "Privacy Settings", icon: :shield) do %>
    <div class="flex items-center justify-between">
      <%= rui_text("Profile Visibility", size: :sm, weight: :medium) %>
      <%= rui_badge(text: "Public", color: :success, size: :xs) %>
    </div>
  <% end %>
<% end %>

E-commerce Product Details

Premium quality product crafted with attention to detail. Made from sustainable materials with a focus on durability and style.

Eco-Friendly Handmade Limited Edition

Material

100% Organic Cotton

Weight

250g

Dimensions

30cm x 20cm x 10cm

Color

Midnight Blue

Free shipping on orders over $50

30-day return policy with full refund

Delivery in 3-5 business days

4.0 out of 5

(128 reviews)

SM

Sarah M.

Verified

Amazing quality! Exceeded my expectations.

<%= rui_accordion(variant: :bordered, size: :sm) do |accordion| %>
  <% accordion.with_item(title: "Description", icon: :file_text, expanded: true) do %>
    <%= rui_text("Premium quality product...", size: :sm, color: :muted) %>
    <div class="flex gap-2 pt-2">
      <%= rui_badge(text: "Eco-Friendly", color: :success, size: :xs) %>
      <%= rui_badge(text: "Handmade", color: :info, size: :xs) %>
    </div>
  <% end %>
  <% accordion.with_item(title: "Customer Reviews", icon: :star) do %>
    <div class="flex items-start gap-3">
      <%= rui_avatar(name: "Sarah M", size: :sm) %>
      <div>
        <div class="flex items-center gap-2">
          <%= rui_text("Sarah M.", size: :sm, weight: :medium) %>
          <%= rui_badge(text: "Verified", color: :success, size: :xs) %>
        </div>
        <%= rui_text("Amazing quality!", size: :sm, color: :muted) %>
      </div>
    </div>
  <% end %>
<% end %>

Team Directory

AC
Alex Chen

Tech Lead

Lead
JK
Jordan Kim

Senior Developer

Senior
SW
Sam Wilson

Developer

Member
MP
Maya Patel

Design Lead

Lead
CL
Chris Lee

UI Designer

Member
TB
Taylor Brown

Marketing Manager

Manager
<%= rui_accordion(variant: :separated, exclusive: false) do |accordion| %>
  <% accordion.with_item(title: "Engineering Team", icon: :code_2, expanded: true) do %>
    <div class="flex items-center justify-between">
      <div class="flex items-center gap-3">
        <%= rui_avatar(name: "Alex Chen", size: :sm, status: :online) %>
        <div>
          <%= rui_link("#", "Alex Chen", size: :sm, weight: :medium, underline: :hover) %>
          <%= rui_text("Tech Lead", size: :xs, color: :muted) %>
        </div>
      </div>
      <%= rui_badge(text: "Lead", color: :primary, size: :xs) %>
    </div>
  <% end %>
<% end %>

Order History

Status

Delivered

Premium Widget x2

$49.98

Shipping

Free

Total

$49.98

Status

Processing

Deluxe Bundle

$129.00

<%= rui_accordion(variant: :bordered) do |accordion| %>
  <% accordion.with_item(title: "Order #12345 - Nov 28, 2024", icon: :package) do %>
    <div class="flex items-center justify-between">
      <%= rui_text("Status", size: :xs, color: :muted, weight: :medium) %>
      <%= rui_badge(text: "Delivered", color: :success, size: :sm) %>
    </div>
    <div class="flex gap-2">
      <%= rui_button("Track Order", size: :sm, variant: :outline) %>
      <%= rui_button("Reorder", size: :sm, color: :primary) %>
    </div>
  <% end %>
<% end %>

Accessibility

The Accordion component follows WAI-ARIA best practices for accessible disclosure widgets.

ARIA Attributes

  • role="region" on the accordion container
  • aria-expanded indicates current state of each item
  • aria-controls links headers to their content panels
  • aria-labelledby on content regions for screen reader context

Keyboard Navigation

  • Enter or Space toggles the focused item
  • Tab navigates between interactive elements
  • Focus states are clearly visible with ring styles

Semantic HTML

  • Collapsible items use <button> elements for proper interaction
  • Non-collapsible items use <div> to indicate they're not interactive
  • Disabled items have the disabled attribute and reduced opacity

JavaScript API

The Accordion component exposes Stimulus actions and custom events for programmatic control.

Stimulus Actions

Use these actions via data-action attributes:

Action Description
accordion#toggle Toggles the clicked item (default action on header click)
accordion#expandAll Expands all accordion items (non-exclusive mode)
accordion#collapseAll Collapses all accordion items
Using Stimulus Actions
<%# Expand/collapse all buttons %>
<div class="flex gap-2 mb-4">
  <button data-action="accordion#expandAll"
          class="px-3 py-1 text-sm bg-zinc-200 rounded">
    Expand All
  </button>
  <button data-action="accordion#collapseAll"
          class="px-3 py-1 text-sm bg-zinc-200 rounded">
    Collapse All
  </button>
</div>

<%= rui_accordion do |accordion| %>
  <% accordion.with_item(title: "Item 1") do %>Content 1<% end %>
  <% accordion.with_item(title: "Item 2") do %>Content 2<% end %>
<% end %>

Custom Events

Listen to these events for lifecycle hooks:

Event When Detail
accordion:expanded An item is expanded { index, item }
accordion:collapsed An item is collapsed { index, item }
Listening to Events
<%# Listen for accordion state changes %>
<div data-controller="my-controller"
     data-action="accordion:expanded->my-controller#onExpand
                  accordion:collapsed->my-controller#onCollapse">
  <%= rui_accordion do |accordion| %>
    <% accordion.with_item(title: "FAQ 1") do %>Answer 1<% end %>
  <% end %>
</div>

<%# In your Stimulus controller %>
// my_controller.js
onExpand(event) {
  const { index, item } = event.detail
  console.log(`Expanded item ${index}`)
}

onCollapse(event) {
  const { index, item } = event.detail
  console.log(`Collapsed item ${index}`)
}

Programmatic Control

Control the accordion from JavaScript using the Stimulus controller:

Programmatic Control
// Get the accordion controller
const accordionElement = document.querySelector('[data-controller="accordion"]')
const accordionController = application.getControllerForElementAndIdentifier(
  accordionElement,
  "accordion"
)

// Open/close specific items by index
accordionController.open(0)      // Expand first item
accordionController.close(0)     // Collapse first item
accordionController.toggleItem(1) // Toggle second item

// Expand/collapse all
accordionController.expandAll()
accordionController.collapseAll()

// Direct item manipulation
accordionController.expandItem(2)   // Expand with animation
accordionController.collapseItem(2) // Collapse with animation

API Reference

Appearance

Visual styling options for the accordion

Parameter Type Default Description
color Symbol :zinc Color theme for headers and borders
:zinc :primary :secondary :success :warning :danger :info
size Symbol :base Size of headers and content
:xs :sm :base :lg :xl
variant Symbol :default Visual style variant
:default :bordered :separated :flush :ghost
shape Symbol :rounded Border radius style
:none :rounded :square :pill

Layout

Spacing and divider options

Parameter Type Default Description
spacing Symbol :base Space between items
:none :xs :sm :base :lg :xl
dividers Boolean true Show dividers between items

Behavior

Interaction and animation options

Parameter Type Default Description
exclusive Boolean true Only one item can be open at a time
animate Boolean true Enable smooth expand/collapse animations

Chevron

Expand/collapse icon configuration

Parameter Type Default Description
expand_icon Symbol :chevron_down Icon for collapsed state (Lucide icon name)
collapse_icon Symbol Icon for expanded state (if nil, expand_icon rotates)
show_chevron Boolean true Show/hide the expand/collapse icon
chevron_position Symbol :right Position of chevron icon
:left :right

Item Options

Options for accordion.with_item() - each collapsible section

Parameter Type Default Description
title* String Header text for the accordion item
icon Symbol/String Lucide icon name to display before title
icon_trailing Symbol/String Lucide icon name to display after title
subtitle String Secondary text displayed below the title

Item State

State and behavior options for items

Parameter Type Default Description
expanded Boolean false Whether item starts in expanded state
disabled Boolean false Prevents the item from being toggled
collapsible Boolean true If false, item stays open (always visible)

Turbo Frame

Lazy loading content via Turbo Frames

Parameter Type Default Description
src String URL for Turbo Frame lazy loading
loading Symbol :lazy Loading strategy for Turbo Frame
:lazy :eager

Stimulus Events

JavaScript events dispatched by the accordion

Parameter Type Default Description
accordion:expanded Event Dispatched when an item is expanded. Detail includes { index, item }
accordion:collapsed Event Dispatched when an item is collapsed. Detail includes { index, item }

Slots

Content slots for customizing component parts

Slot Description
items Multiple accordion items via accordion.with_item(title:, ...) { content }

Related Components