DocumentOutline

DocumentOutline is a vanilla JavaScript library that automatically generates the "Table of Contents" of an HTML document.

The table of contents you see on this page is generated with DocumentOutline.js.



How To Use

Import needed files:

Then initialize the outline:

Or initialize with custom options:



Documentation


Classes

DocumentOutline

Kind: global class


Functions

new DocumentOutline(options)

ParamTypeDescription
optionsObject 
[options.backgroundColor]Stringbackground color of the outline
[options.textColor]Stringtext color of the first-level sections
[options.accentColor]Stringaccent color of the outline
[options.textColorLight]Stringtext color of the sub sections
[options.defaultOpen]Stringindicate the initial mode of the outline. Outline is open by default on desktop and closed on mobile.

onSearchInput(text)

Called when a search is submitted

Kind: global function

ParamTypeDescription
textStringtext to search

showOutline()

Show document outline.

On desktop the outline is placed to the left of the main content takes 20% of the width.

On mobile the outline is placed above the main content and takes 100% of the width.

Kind: global function


hideOutline()

Hide document outline.

On desktop the outline reduces its width to 3%.

On mobile the outline disappears completely and a floating button appears in the bottom-left corner.

Kind: global function