BeefUp Just a jQuery accordion plugin

GitHub

Examples

Item 1

Item 2

Nested Item

$('.example').beefup();

Open single

Open just one accordion at once. It is possible to choose one item that will not automatically close.

Item 1

Item 2

Nested Item 1

Nested Item 2

Locked item

$('.example-opensingle').beefup({
	openSingle: true,
	stayOpen: 'last'
});

Animations

By default the accordion will slide down and up. It is possible to set the animation type to "slide", "fade" or leave empty "", and to define the open and the close animation speed.

Fade

$('.example-fade').beefup({
	animation: 'fade',
	openSpeed: 400,
	closeSpeed: 400
});

Scroll

Scroll to the top of the open accordion. Use the property "scrollOffset" to add additional space or "scrollSpeed" to define the animation speed.

Item 1

Item 2

$('.example-scroll').beefup({
	scroll: true,
	scrollOffset: -10
});

Self block

Block accordion close event on click.

Item 1

$('.example-selfblock').beefup({
	selfBlock: true
});

Self close

Close the accordion on click outside of the element.

Item

$('.example-selfclose').beefup({
	selfClose: true
});

Breakpoints

Change settings on different screen sizes.

Item 1

Item 2

$('.example-breakpoints').beefup({
	scroll: true,
	scrollOffset: -10,
	breakpoints: [
		{
			breakpoint: 768,
			settings: {
				animation: 'fade',
				scroll: false
			}
		},
		{
			breakpoint: 1024,
			settings: {
				animation: 'slide',
				openSpeed: 800,
				openSingle: true
			}
		}
	]
});

Advanced

API Methods

Trigger open, close, click or scroll events.

Open

var $beefup = $('.example-api').beefup();
$beefup.open($('#beefup'));

Callbacks

Also available are event driven callback methods on init, open and close.

Item

$('.example-callbacks').beefup({
	onInit: function($el) {
		$el.css('border-color', 'blue');
	},
	onOpen: function($el) {
		$el.css('border-color', 'green');
	},
	onClose: function($el) {
		$el.css('border-color', 'red');
	}
});

HTML5 data attributes

Overwrite default options by using HTML5 data attributes.

Item

$('.example-data').beefup();
<article class="beefup example-data" data-beefup-options='{"animation": "", "openSpeed": 800}'>
	...
</article>

Customize

Tabs

Tab 1

Tab 2

Tab 3

$('.tab__item').beefup({
	animation: '',
	openSingle: true,
	openSpeed: 0,
	closeSpeed: 0,
	onOpen: function($el) {
		// Add active class to tabs
		$('a[href="#' + $el.attr('id') + '"]').parent().addClass(this.openClass)
				.siblings().removeClass(this.openClass);
	}
});
.tab__head {
	margin: 0 0 -1px;
	padding: 0;
	list-style: none;
}

.tab__head li {
	display: inline-block;
	z-index: 100;
	background: #fff;
	border: 1px solid #ddd;
	font-weight: bold;
}

.tab__head li.is-open {
	border-bottom-color: transparent;
}

.tab__head a {
	display: block;
	padding: 0 10px;
	color: inherit;
	font-size: 16px;
	line-height: 2.5;
	text-decoration: none;
	white-space: nowrap;
}

.tab__item.beefup {
	display: none;
	margin: 0;
	border-radius: 0;
}

.tab__item.beefup.is-open {
	display: block;
}

.tab__item .beefup__head {
	display: none;
}

$('.dropdown').beefup({
	animation: 'fade',
	openSingle: true,
	selfClose: true
});
.dropdown__menu li {
	font-size: 16px;
}

.dropdown__menu a {
	cursor: pointer;
	display: block;
	clear: both;
	padding: 3px 10px;
	color: inherit;
	text-decoration: none;
	white-space: nowrap;
}

.dropdown__menu a:hover {
	background-color: #f5f5f5;
}

.dropdown.beefup {
	display: inline-block;
	position: relative;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
}

.dropdown .beefup__head {
	cursor: pointer;
	display: inline-block;
	margin-bottom: 0;
	padding: 0 40px 0 10px;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-size: 16px;
	font-weight: bold;
	line-height: 2.5;
	text-align: center;
	vertical-align: middle;
	white-space: nowrap;
}

.dropdown .beefup__body {
	float: left;
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 1000;
	margin: 2px 0 0;
	padding: 5px 0;
	min-width: 160px;
	background-color: #fff;
	border: 1px solid #ddd;
	border-radius: 4px;
	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
	font-size: 14px;
	list-style: none;
	text-align: left;
}