PHPackages                             kartik-v/yii2-widget-affix - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. kartik-v/yii2-widget-affix

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

kartik-v/yii2-widget-affix
==========================

A scrollspy and affixed enhanced navigation to highlight page sections (sub repo split from yii2-widgets)

v1.0.0(11y ago)153.8M—4.1%4[1 issues](https://github.com/kartik-v/yii2-widget-affix/issues)3BSD 3-ClausePHP

Since Nov 9Pushed 8y ago1 watchersCompare

[ Source](https://github.com/kartik-v/yii2-widget-affix)[ Packagist](https://packagist.org/packages/kartik-v/yii2-widget-affix)[ Docs](https://github.com/kartik-v/yii2-widget-affix)[ RSS](/packages/kartik-v-yii2-widget-affix/feed)WikiDiscussions master Synced 1mo ago

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

yii2-widget-affix
=================

[](#yii2-widget-affix)

[![Latest Stable Version](https://camo.githubusercontent.com/a9aeeea469eae2da40dccd42d75048e2f9bc349afa43a4da95d24223587300ad/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7769646765742d61666669782f762f737461626c65)](https://packagist.org/packages/kartik-v/yii2-widget-affix)[![License](https://camo.githubusercontent.com/6c615277f5d95ba93c593d37f14b8fa7fc1e5d11a6ef4d200ccf11505c5f64e9/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7769646765742d61666669782f6c6963656e7365)](https://packagist.org/packages/kartik-v/yii2-widget-affix)[![Total Downloads](https://camo.githubusercontent.com/b4d1276328c4475e6f2419e30e73f4749ea487033b0fb87c230a03bec8c070d3/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7769646765742d61666669782f646f776e6c6f616473)](https://packagist.org/packages/kartik-v/yii2-widget-affix)[![Monthly Downloads](https://camo.githubusercontent.com/9070abf48b5c860db0b23a988c9568a7a21edc3e976499ef794f30e4159f0958/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7769646765742d61666669782f642f6d6f6e74686c79)](https://packagist.org/packages/kartik-v/yii2-widget-affix)[![Daily Downloads](https://camo.githubusercontent.com/0455bffd3029511be0fca6d803ff953ba7e9aa9adcae419dfbbccb4bf60f0b53/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7769646765742d61666669782f642f6461696c79)](https://packagist.org/packages/kartik-v/yii2-widget-affix)

Extends [Yii Menu widget](https://github.com/yiisoft/yii2/blob/master/framework/widgets/Menu.php). This widget offers a [scrollspy](http://getbootstrap.com/javascript/#scrollspy) and [affixed](http://getbootstrap.com/javascript/#affix) enhanced navigation (upto 2-levels) to highlight sections and secondary sections in each page. The affix widget can be used to generate both the:

- **Sidebar Menu:** Displays the scrollspy/affix navigation menu as a sidebar, and/or
- **Main Body:** Displays the main body sections based on the section &amp; subsection headings and content passed.

> **Note:**If you have the `header` section fixed to the top, you must add a CSS class `kv-header` to the header container. Similarly, for a fixed footer you must add the class `kv-footer` to your footer container. This will ensure a correct positioning of the affix widget on the page.

The parameters to pass are:

- `type` The affix content type. Must be either `menu` or `body`. Defaults to `menu`
- `items`: The affix content items as an array. Check the [affix combined usage](http://demos.krajee.com/widget-details/affix#affix-menu-body) for a detailed example.

> NOTE: This extension is a sub repo split of [yii2-widgets](https://github.com/kartik-v/yii2-widgets). The split has been done since 08-Nov-2014 to allow developers to install this specific widget in isolation if needed. One can also use the extension the previous way with the whole suite of [yii2-widgets](http://demos.krajee.com/widgets).

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/). Check the [composer.json](https://github.com/kartik-v/yii2-widget-affix/blob/master/composer.json) for this extension's requirements and dependencies. Read this [web tip /wiki](http://webtips.krajee.com/setting-composer-minimum-stability-application/) on setting the `minimum-stability` settings for your application's composer.json.

To install, either run

```
$ php composer.phar require kartik-v/yii2-widget-affix "*"

```

or add

```
"kartik-v/yii2-widget-affix": "*"

```

to the `require` section of your `composer.json` file.

Latest Release
--------------

[](#latest-release)

> NOTE: The latest version of the module is v1.0.0 released on 08-Nov-2014. Refer the [CHANGE LOG](https://github.com/kartik-v/yii2-widget-affix/blob/master/CHANGE.md) for details.

Demo
----

[](#demo)

You can refer detailed [documentation and demos](http://demos.krajee.com/widget-details/affix) on usage of the extension.

Usage
-----

[](#usage)

```
use kartik\affix\Affix;

$content = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.';
$items = [[
	'url' => '#sec-1',
	'label' => 'Section 1',
	'icon' => 'play-circle',
	'content' => $content,
	'items' => [
		['url' => '#sec-1-1', 'label' => 'Section 1.1', 'content' => $content],
		['url' => '#sec-1-2', 'label' => 'Section 1.2', 'content' => $content],
		['url' => '#sec-1-3', 'label' => 'Section 1.3', 'content' => $content],
		['url' => '#sec-1-4', 'label' => 'Section 1.4', 'content' => $content],
		['url' => '#sec-1-5', 'label' => 'Section 1.5', 'content' => $content],
	],
]];

// Displays sidebar menu
echo Affix::widget([
	'items' => $items,
	'type' => 'menu'
]);

// Displays body sections
echo Affix::widget([
	'items' => $items,
	'type' => 'body'
]);
```

License
-------

[](#license)

**yii2-widget-affix** is released under the BSD 3-Clause License. See the bundled `LICENSE.md` for details.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity51

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% 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

Unknown

Total

1

Last Release

4209d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3592619?v=4)[Kartik Visweswaran](/maintainers/kartik-v)[@kartik-v](https://github.com/kartik-v)

---

Top Contributors

[![kartik-v](https://avatars.githubusercontent.com/u/3592619?v=4)](https://github.com/kartik-v "kartik-v (10 commits)")[![camohob](https://avatars.githubusercontent.com/u/7923965?v=4)](https://github.com/camohob "camohob (2 commits)")

---

Tags

pluginjqueryyii2extensionwidgetbootstrapnavigationaffixscrollspy

### Embed Badge

![Health badge](/badges/kartik-v-yii2-widget-affix/health.svg)

```
[![Health](https://phpackages.com/badges/kartik-v-yii2-widget-affix/health.svg)](https://phpackages.com/packages/kartik-v-yii2-widget-affix)
```

###  Alternatives

[kartik-v/yii2-widget-sidenav

An enhanced side navigation menu styled for bootstrap (sub repo split from yii2-widgets)

364.0M8](/packages/kartik-v-yii2-widget-sidenav)[kartik-v/yii2-widget-rating

A Yii2 widget for the simple yet powerful bootstrap-star-rating plugin with fractional rating support (sub repo split from yii2-widgets)

444.1M8](/packages/kartik-v-yii2-widget-rating)[kartik-v/yii2-widget-timepicker

Enhanced Yii2 wrapper for the bootstrap timepicker plugin (sub repo split from yii2-widgets)

404.9M14](/packages/kartik-v-yii2-widget-timepicker)[kartik-v/yii2-widget-switchinput

A Yii2 wrapper widget for the Bootstrap Switch plugin to use checkboxes &amp; radios as toggle switchinputes (sub repo split from yii2-widgets)

384.4M13](/packages/kartik-v-yii2-widget-switchinput)[kartik-v/yii2-widget-datepicker

Enhanced Yii2 wrapper for the bootstrap datepicker plugin (sub repo split from yii2-widgets).

1097.0M60](/packages/kartik-v-yii2-widget-datepicker)[kartik-v/yii2-widget-touchspin

A Yii2 wrapper widget for the Bootstrap Switch plugin to use checkboxes &amp; radios as toggle touchspines (sub repo split from yii2-widgets)

184.1M6](/packages/kartik-v-yii2-widget-touchspin)

PHPackages © 2026

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