Collapse

Create versatile collapsible content areas anywhere in your help center.

The Collapse extension, as the name suggests, allows you to create collapsible sections of content anywhere in your help center. Each collapsible section comprises the collapsible content area as well as one or more triggers which, when clicked, show or hide the content.

You can have a single collapsible element controlled by multiple triggers, where a trigger is typically a link or button:

Single collapsible element

Similarly, multiple collapsible elements can be controlled by a single trigger:

Multiple collapsible elements

Use the data-parent attribute on one or more collapsible elements to group them on the basis of a common ancestor element. If two or more collapsible elements are grouped, only one can be open at a time.

You can use these elements for almost anything. Examples from our themes include collapsible reponsive navigation menus and interactive toggles and accordions produced by our Toggles extension.

Toggles powered by the Collapse extension
View code
79fa76d26d5824a04fd215b3e87a2a62965e0ba869e5c0f2f6751e4a058de5001c044050491ea84064471338f606a4369385c39027c44aaa9380b5b24a405d54ea1379b4a308088f9b093592bbd8e9e3e4b1b440616211f2403d93cf4736c99fa0b09b26a81ed98086f8378bb40e338ed07af6548d8d286583aea659d47482278fb1bf4baf9ec3928a8f03cb21c678f128c4403482a657baca32e89ec64ef1cb3b6c2bcd13ca3e5420b5bdcb42b0bfb756a93803f958ab2f00ac860e0c65a805c4aebedcca780fa18518f90be0c6b0e6d2c3f6842b6e12c6cac18ddfbd3011c3773e287c2fe34bd41667175181b0318670e2d50f63b40eec95448e8269637915f025bf0defabcb01c4b76eb13c0b4d5e513fd255864f194fe65357d90b4cf2cf5260a35f7123b44061739b01ef14599cb86989d3ef5572cbae7874d8da63e0b9410066ca078395b076ac34ad85f794230b518d4090c9a62a50efac91bb734d983cbbb8be720cb2cddc23b946418c2faef682dea697cf3419be8676253b84418a8a56d2775c6c73ef67f0ea833298730b806796539112392231c42afc2a19e0d1fbc37419951abf98a0c5c61cb14617051fc2bb65b394dc68e685dd51283717b3f5a581051fe439c51a7e7750ba22c68dc8ac6bb3ddf644f358e231c184bf1105f676ea055c3612d5a0a8781a49400605c05e6e5f131b15f0e2ab4000a3b295c2e2ed33d80cdacd8f78b2b1ffc6bd9de40193ee2cee3f2672ce06177c2ef250a22211167f08ece42bfb1fed46b27fcc80ce66d43fa1afca6420fe2827fe8ec361ebf870d635f155a4158109b9665d7756fe237bb35f5414d8a356cb0ea93c178b8d0255364c74550755fd2ce5a7428f5fdfa6afb339d8b688f9327f41ac0c7df01ffe79365b944b38eb491d6b71632bc19ae7ec550ff2fbb684d983a022d1b9d8878383ebe585776147a8d43f5c1648ccefaacbd202802eb1e5353b3535ddf7dfb55a119007ccfaec9ef2599b3d12fc9456bf927ddbc78c6be1df63fee67d97aa64d8dbe8f17864d4714fe33458bb2c2abb7cd13351313946d18509595a0062a14473150741ddfe33ba2f34b42a71525fc00f57d0ec0931724d27abfe8d5a91f28aa479900c7dd00bcfb96fe62cc25d7245f0f863601961a1f70841993d733ced45cb323ed7c7bd3b75d600a1a55ebcb40c9411303f23c3906caebcac2677668620739c58d002c3e972026eb7fcb7c3ebd80b87a90b000973195b42bdb97dc6d67d479a48cb8f5350b94a878273ba724b0050ce9c5ec976d5a371d299ffd2b578556bb09799955fb861648dc21a3b50c4ce9a850945a7a859ccd6f3a1b40dd1bad63c1b6867831a5acb1c02e6cb5f497e3b1c73102bd8f9c1e713b2b693aece1551f755555fa8d9d6b2924562c69059cf862c075877f6e247e20490894e271af5e0647c062715958bf3b7b0eb95682f3c1ab6288a7e7f932cfa3b57afebf7f4d12555ce8893c64f5bd03c153163f17ef915e3ffa3624ed952ca6c031f0f97c3acb4639a6e4deee2b838496fea8552754cf64ea0997e9c977a15e944d03decb015adfcc9b11195432939a20fa440e9ed212bb2b4fa544a1686b6c5b3b744da914fdf302e583a4f4253b105f5d1798e3ac2b2c934abcae714afa697979761533b6460af8d69bf3cce264ebb64ecb8c2360c898b2beadb1307a3229aa42445e0e224b95a07aca88302e790f73c68105c3e7ff10f62453b69f1d9f95e29a32625a0cc90a073d46e98aea60e3495d84c8dacfb4af7f60e31b5ae86df967ad015fdf3d5a13223ebd373130e72d560efdd7d7f954254022ec9e58eef31d8777bdc0ce897d3a35fcfc2deb0050a5c3bc62b690ae50156cff129715a123ff8bd831e6ab2ac625328ef289d443f48a4a6aafd1553a085520a4602e39d979cf7eee467a409a85bc3247d718f934e78a2d41ca74696347e04e210f5d0acaf085f785fa365362b10204d79b559405a657f0c8c53fdb272037c1536fac0fc8d959674915dc61170f8ad28180f7de1400597e3d74817a01d6a4f6236240e6be7c183f03121b4af9e8c8a1f2d1ed1379e7e6d998ce7b511991ac7b027e12f85a246406b9e839f00159b6e8cc688de451c0f09c17c86c2a3c16092906908946cdfe0e7c6027a789b20f1ff8917fb7c0ed86c165c4605be1ab176f37dddc477f9c5f75234fa73e01344ea6ddd0554b7a75ca7ab27e3e82765e1bfcf74d8087ea8592fad4fd6277e0d2820113493c3ff89ddf38627b335ff19ea320708fb3479e7196a62c14af6c8bdd29a72801b669f434fabd73fd9f01c11b8bef1435fb4a901c4b6aeaab039f0cc2c79946fe3895093def305aecc07d65c58e12434472d72a6f903066364ceeac641c1a37debb06482628dfc6ec0e2d7fbaa5348cd23b1ac759d6568d7d718e97ebce6b710ba52861e297e94acb0b85564855fde7beebc29d66edf763c6ede869e3dcc94296e41a83831ddae82aadb61b77ac228f466407cb9901881af2f43836c655facdc46e2e03847d95839cd57ff97295a6d159858da95977f01000f40b77f3cae2d8cd053474ee925cbd5e5843ca1ffc18b1ed698d811dc152493ed6d4777ed3701694092187de3be8167d31c2fb4ed866ae834fdd4b08c99c3a974efdf0212e64f1c94c161d0994a080c546f38dc7a658fada491aadc53f28d5e51c1d30f5167cf8598774bc1967b1fc88d0eee174adde2e858197bc2f02de12be78e2923816c4999c4912551a64b20b647b0416af07199e2aa845c78c28ed187037b04315e83054e8c0de5789c3cc014d09d0d1a6b329f0b6ace7e0d9496208853b4851399325de34e86e0bfe3f52f419befbcad2e314d3e78b1e925004e3437cfa6f86b9d253828ea453415d415912c93325f3ed61166e9d84de3fb0213393a48969e06fe622bfe561d79beec48b159e85dfd0ff9edb39695069ed6b8c8761f575acc9ba15b7f49f173babde4c1bc2ef1cf0021e17df6ba2e0bdd6d50c4ecdaed031e89a422822f9b5d343ec521c7893d83c78246e964194dddb0f7203865d395e6327c4f70b09994159c72cbed9be366916084d17a823e9ce5d729cbd45fe5f74ef6c3e35167019cbcb2addacaa138df1589e88c0a83ad0d708ff4942200a940f5ef647bbfb5da1d91451906cd223975dccc664804084436a18cd84148fda1c39e85497a2cc508101656b13796e3834974f72bf3c54704de67fce27aa09567d27d36f2c450b16682c0a331979f1a5be9182843dbe96ec02156e3b2ab41e1b34019bf4f8753913e84138fa6241ee5ae7131e08721f404fdb05c512e461bbbda4d3daa1ff74a3c8c96e435475da100bd64deba6b2a8cd5089494c540244767bc93da7f43890216e87fe56df402e60141a9ecfd5648a57e5b5a5aa6774810ba6b7852d1d5e9bed38cf42d4b1e79016e46dbc8c89ff5ec920e547bc2c1095804356d1eb358477b81b6e5ef567a4d8623720b941d019a0d3d26c67bd0b5acb6baf2bb12b56edafd000522ef9b695c1c26b94de1660f56f37f74f2076d4a607eceae96acd574053d98e285030fb2fc0a249a2b88c36f2fbe780fa254a4ee0662af2526ebd9205a3131b459c336e9cebae41f957c535beb731b0f1f0c0626e1421b7b73d3d2522cc13651a854b7aab7dad34a8ea4832a758ea3c98d60d37ded84da8e6cc591dac547848ddbf3492d83aa13a36b2dbac4f7ad2f782735c679307812d02f07be4428089a9a149de58f4ed2edabf339dc5473b34151d00fc1607ac7afa9e22a47f56e3c33d11444e22eff74b0faf0cb27c71aef8edaec5dcf7560cf658c0cbd888138357d8b8dcda2e59697425f464d91f7a3e87e6f950a44eaf3ab0c7088f256a56a5a698301fe28a3f220243db549065911971c2aa3f4dd2295d6021732b123e1b0a4f02cab1ff9314ddd581cc60b81722ccc2eacd55c4ae64f2d26f8de08477324f478607aa17962bbe443acb09b7ce19f238a97099ab17e2b6fbca835e7d00f0cbd078f1f18628969adb612affbf7027c1a67e9bd647f053fba68d0b7e383cd27eb0d582f2ab14d6e0180ab22e66ba6ed9a24076872854438ad0ac462b8189bf0aa0019cf20e653d2ef832b12d74a5e98118968cf234d9d54959694e3be9efb8eb392ffedee5918f3651df9e7526d08758424112e850b277a1a1bd99a30ab2fe0526fde4558b4f05cbddf1c44fa5b0f0a05a133c5c59efd56e9997cc8656025e6eb1db25120b17155001a9373f9bcb8c21fcc9fdf40bd9985bcb69ce87e8fd58769b14abc8ad37f71bf809bfaf313bea968b0066a1b365c11788e1f7574ba1d46c9777a60361e1bc8f8d8f73615109c51d02cae23c3b739f710a158d9f0c05ef53b19fd7512335609451add7e63ba31a16815ccea2aee0fb28dcadf30124e99ee

Creating collapsible elements

Use .collapse to create a hidden, collapsible element.

Use .{screen}:expand to expand the .collapse element on specific screen sizes. This is useful when you want an element to behave as a collapsible element on small screen sizes, but be visible on large screen sizes.

The Collapse extension is bundled into all of our themes by default, so you can start using it straight away. The source code can be found within the extensions.(min.)js file in the theme’s Assets folder.

Using attributes

Use the [data-toggle="collapse"] attribute to create a trigger.

The collapsible element targeted by the trigger is identified by a CSS selector specified in the href (in the case of a link) or data-target attribute. You can therefore target collapsible element by ID, class name or a number of other attributes.

The extension will apply the following classes to the collapsible element when visitors click on the associated trigger:

  • .collapsing during transitions and is responsible for the transition effect.
  • .is-visible when the element is visible.

If data attributes are used within article content you will need to ensure that the allow unsafe HTML setting is enabled within Zendesk Guide.

Options

Name Type Default Description
parent string
DOM element
null If a parent is provided, all collapsible elements under the specified parent will be hidden when this collapsible item is shown.
toggle boolean true If true, the collapsible element will be open upon initialization.

Events

Name Description
collapse:show Fires when the show() method is called, but before the collapse element is visible.
collapse:shown Fires when the collapse element is visible (after CSS transitions have completed).
collapse:hide Fires when the hide() method is called, but before the collapse element is hidden.
collapse:hidden Fires when the collapse element is hidden (after CSS transitions have completed).
document.addEventListener('collapse.show', function(e) {
  // Do something...
});

Related extensions

Article navigation Free

Article navigation

Display links to next and previous articles.

Category dropdown Free

Category dropdown

Display all categories within a menu in the page header.

Featured articles Free

Featured articles

Display a list of articles with one or more labels.