h1 BEM Accordion .sidebar#js-sidebar-1(data-block="sidebar") .sidebar__item.js-accordion--open .sidebar__title.js-accordion--open h2 Responsive Accordion .sidebar__content.js-accordion--open p Here is my attempt at creating a object oriented-ish accordion using BEM CSS guidlines. This accordion is fully responsive and completely barebones, making it easy to style however you want. .inner#js-sidebar-2(data-block="inner") .inner__item .inner__title h2 Implementation .inner__content p Use #[strong @mixin accordion()] to apply the base styles necessary to make the accordion work. Then initialize the accordion with js. p By default, the CSS mixin is super barebones, but you can pass the value #[strong 'base'] to the mixin to apply some base styles. You can always add your own presets to the mixin. p Also make sure to add #[strong data-block] to your accordion with the name used for your block. This data-attribute is used as a naming hook for js. .inner__item .inner__title h2 Things to Note .inner__content p Because the accordion works by adjusting the __content element's height, #[strong no vertical padding] can be applied to the __content element. To help prevent any issues, I've added !important styles to prevent vertical padding. If you need control of spacing in the __content element, I recommend having all content wrapped in another div. p The style #[strong .js-accordion--open] class is used to designate the open state. This class gets applied to 3 elements in the accordion block: __item, __title, & __content. .sidebar__item .sidebar__title h2 Height Auto Transition .sidebar__content p Accordion transitions are handled by CSS3 transitions. To make the accordion responsive, I've implemented a way to basically pull off a height: 0; to height: auto; transition. p This transition is pulled off by expanding __content to the element's scrollHeight and then setting the height to auto using transitionend. The reverse animation is achieved using a 4ms delay between reassignign the content height and animating the height back to 0. .sidebar__item .sidebar__title h2 Data Attribute vs JS-Class .sidebar__content p I bounced back and forth between applying the .js-accordion--open class and using a data-state. I stuck with a simple class since jsperf indicates data-attributes still take a performance hit. p Ultimately, neither trigger case adheres directly to the BEM guidelines. I wanted to be able simply use modifiers (ex: .accordion__content--open), but filtering through a sea of element--modifier combinations or using i-bem was something I didn't want to tackle. br h1 Barebone .barebone#js-barebones(data-block="barebone") .barebone__item .barebone__title h2 Barebones Title 1 .barebone__content p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et dui sit amet massa vehicula semper id eu neque. Nulla venenatis consectetur mauris. Integer eu ornare eros. In malesuada viverra urna sed vehicula. .barebone__item .barebone__title h2 Barebones Title 2 .barebone__content p Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam id lorem vestibulum, ornare ipsum vel, varius magna. Integer venenatis nibh urna, et hendrerit felis venenatis in. .barebone__item .barebone__title h2 Barebones Title 3 .barebone__content p Curabitur accumsan augue eget purus lacinia, at fringilla velit vestibulum. Aenean iaculis enim elit. Vestibulum convallis, massa et vestibulum feugiat, leo ipsum commodo libero, vel lacinia diam libero vel purus.