Phoenix UI

Phoenix UI home page
  1. Getting Started
  2. Installation: Tailwind CLI

Accordion

The accordion component allows the user to show and hide sections of related content on a page.

An accordion is a lightweight container that may either be used standalone, or be connected to a larger surface, such as a card.

Examples

Below you can view various demos with example markup.

Basic

Here is an example of a basic accordion inside a paper component.

Basic Accordion

Custom Icon

Here is an example of customizing the component icons.

Custom Icon Accordion

Default Open

Here is an example of setting the the component to "open" by default.

Custom Icon Accordion

API

API documentation for the component. Learn about imports and available attributes.

Import

There are multiple ways to import components.


    # PhoenixUI macro which imports all components
    use PhoenixUI
    # Or import component individually
    import PhoenixUI.Components.Accordion, only: [accordion: 1]
    

Attributes

Below is a list of attributes that can be applied to the component.

Name Type Default Description
HTML attribute any Supports all HTML attributes.
close_icon heroicon attrs color: "slate", name: "chevron-up" Heroicon component attributes for close icon.
extend_class string Adds additional classes.
header* slot Control for showing and hiding the panel content.
max_size {100..5000//100}px 5000px In order to support transitions, have to apply a max height.
open bool false Determines whether the accordion is open by default.
open_icon heroicon attrs color: "slate", name: "chevron-down" Heroicon component attributes for open icon.
panel* slot Section of content associated with an accordion header.
phx-{any} binding Supports all Phoenix DOM element bindings.