1 # JavaScript Components
3 This document details the format for JavaScript components in BookStack.
5 #### Defining a Component in JS
14 #### Using a Component in HTML
16 A component is used like so:
19 <div component="dropdown"></div>
21 <!-- or, for multiple -->
23 <div components="dropdown image-picker"></div>
26 The names will be parsed and new component instance will be created if a matching name is found in the `components/index.js` componentMapping.
28 #### Element References
30 Within a component you'll often need to refer to other element instances. This can be done like so:
33 <div component="dropdown">
34 <span refs="dropdown@toggle othercomponent@handle">View more</span>
38 You can then access the span element as `this.$refs.toggle` in your component.
40 #### Component Options
43 <div component="dropdown"
44 option:dropdown:delay="500"
49 Will result with `this.$opts` being: