PHPackages                             sjaakp/yii2-collapse - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. sjaakp/yii2-collapse

ActiveYii2-extension[Framework](/categories/framework)

sjaakp/yii2-collapse
====================

Collapse and Accordion widgets for the Yii 2.0 framework

1.1.0(7y ago)213.4k↓33.3%1MITPHP

Since Apr 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/sjaakp/yii2-collapse)[ Packagist](https://packagist.org/packages/sjaakp/yii2-collapse)[ RSS](/packages/sjaakp-yii2-collapse/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Yii2-collapse
=============

[](#yii2-collapse)

[![Latest Stable Version](https://camo.githubusercontent.com/6ad0c9953208368810ed55d8c0afb22a490467a952ff140d155e97727a128683/68747470733a2f2f706f7365722e707567782e6f72672f736a61616b702f796969322d636f6c6c617073652f762f737461626c65)](https://packagist.org/packages/sjaakp/yii2-collapse)[![Total Downloads](https://camo.githubusercontent.com/46b65e2df8aa4d3efacebcb7174903504678a990ccffd9c1cae24fb2edfb47af/68747470733a2f2f706f7365722e707567782e6f72672f736a61616b702f796969322d636f6c6c617073652f646f776e6c6f616473)](https://packagist.org/packages/sjaakp/yii2-collapse)[![License](https://camo.githubusercontent.com/31124c56f64c8c5d5ece8fd500656986fbf96e66a763e6e7dc2cccdf12e52577/68747470733a2f2f706f7365722e707567782e6f72672f736a61616b702f796969322d636f6c6c617073652f6c6963656e7365)](https://packagist.org/packages/sjaakp/yii2-collapse)

**Yii2-collapse** offers three widgets for the [Yii 2.0](https://www.yiiframework.com/ "Yii") PHP Framework:

- **Collapse** renders a [Bootstrap Collapse](https://getbootstrap.com/docs/4.3/components/collapse/#example "Bootstrap")element with a toggle link and a collapsible panel;
- **CollapseGroup** two or more **Collapse**s of which only one can be open;
- **Accordion** renders a [Bootstrap Accordion](https://getbootstrap.com/docs/4.3/components/collapse/#accordion-example "Bootstrap")element with several panels of which only one can be open. An **Accordion** essentially is a kind of **CollapseGroup**. The difference is that the **Collapse**'s are all direct children of the surrounding element.

All three widgets can be used with either Bootstrap 3.x or Bootstrap 4.x.

A demonstration of the widgets is [here](http://www.sjaakpriester.nl/software/collapse).

Installation
------------

[](#installation)

Install **yii2-collapse** in the usual way with [Composer](https://getcomposer.org/). Add the following to the require section of your `composer.json` file:

`"sjaakp/yii2-collapse": "*"`

or run:

`composer require sjaakp/yii2-collapse`

You can manually install **yii2-collapse** by [downloading the source in ZIP-format](https://github.com/sjaakp/yii2-collapse/archive/master.zip).

Using the Collapse widget
-------------------------

[](#using-the-collapse-widget)

Using the **Collapse** widget in an Yii2 view file can be as simple as:

```

    ...

        Some more details
        The first detail...

    ...

```

The HTML between `begin()` and `end()` can be as complicated as you like.

Instead of initializing **Collapse** with the label text, it can also be initialized with an `array` of several options, like:

```

    ...

        Some more details
        The first detail...

    ...

```

Using the CollapseGroup widget
------------------------------

[](#using-the-collapsegroup-widget)

The **CollapseGroup** widget can be used like:

```

    ...

    ...

        Some more details
        The first detail...

    ...

    ...

```

`beginCollapse()` can also be initiallized with an array of **Collapse** options.

Using the Accordion widget
--------------------------

[](#using-the-accordion-widget)

Use the **Accordion** widget as follows:

```

    ...

        Some details
        The first detail...

        Some more details
        The tenth detail...

        Even some more details
        The twentieth detail...

    ...

```

As with **Collapse**, **Accordion** can also be initialized with an `array` of several options.

#### Common options

[](#common-options)

**Collapse** and **Accordion** (but *not* **CollapseGroup**) both have the following options:

- **label** `string` The text of the (first) label.
- **encode** `bool` Whether to HTML-encode the label(s). Default: `true`.
- **open** `bool` Whether the (first) panel is initially open. Default: `false` (Collapse), `true` (Accordion).
- **toggleOptions** `array` HTML options for the toggle link(s). Default: `['class' => 'btn-collapse']`. This class styles the toggle link with a triangle.

#### Collapse option

[](#collapse-option)

- **options** `array` HTML options for the panel. `'tag'` is a special option, defining the HTML-tag. If it is not set, the HTML-tag is `'div'`

#### CollapseGroup option

[](#collapsegroup-option)

- **options** `array` HTML options for the surrounding element. `'tag'` is a special option, defining the HTML-tag. If it is not set, the HTML-tag is `'div'`

#### Accordion options

[](#accordion-options)

- **options** `array` HTML options for the surrounding element. `'tag'` is a special option, defining the HTML-tag. If it is not set, the HTML-tag is `'div'`
- **panelOptions** `array` HTML options for the panels.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

2575d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/156f636aceedc73021a2bfafb5433271c2c55d6cf4bce06b12902c85b4b491f1?d=identicon)[sjaakp](/maintainers/sjaakp)

---

Top Contributors

[![sjaakp](https://avatars.githubusercontent.com/u/5585878?v=4)](https://github.com/sjaakp "sjaakp (4 commits)")

---

Tags

yii2extensionwidgetyiicollapseaccordion

### Embed Badge

![Health badge](/badges/sjaakp-yii2-collapse/health.svg)

```
[![Health](https://phpackages.com/badges/sjaakp-yii2-collapse/health.svg)](https://phpackages.com/packages/sjaakp-yii2-collapse)
```

###  Alternatives

[miloschuman/yii2-highcharts-widget

Highcharts widget for Yii 2 Framework.

1761.5M14](/packages/miloschuman-yii2-highcharts-widget)[thiagotalma/yii2-fullcalendar

Widget for Yii Framework 2.0 to use FullCalendar

1777.7k](/packages/thiagotalma-yii2-fullcalendar)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
