|
| 1 | +import React from 'react'; |
| 2 | + |
| 3 | +import Anchor from '../Anchor'; |
| 4 | +import PropTable from '../PropTable'; |
| 5 | +import ReactPlayground from '../ReactPlayground'; |
| 6 | +import Samples from '../Samples'; |
| 7 | + |
| 8 | +export default function DropdownSection() { |
| 9 | + return ( |
| 10 | + <div className="bs-docs-section"> |
| 11 | + <h2 className="page-header"> |
| 12 | + <Anchor id="btn-dropdowns">Dropdowns</Anchor> <small>DropdownButton, SplitButton, Dropdown</small> |
| 13 | + </h2> |
| 14 | + |
| 15 | + <h3><Anchor id="btn-dropdowns-single">Single button dropdowns</Anchor></h3> |
| 16 | + <p>Create a dropdown button with the <code>{"<DropdownButton />"}</code> component.</p> |
| 17 | + <ReactPlayground codeText={Samples.DropdownButtonBasic} /> |
| 18 | + |
| 19 | + <h3><Anchor id="btn-dropdowns-split">Split button dropdowns</Anchor></h3> |
| 20 | + <p>Similarly, create split button dropdowns with the <code>{"<SplitButton />"}</code> component.</p> |
| 21 | + <ReactPlayground codeText={Samples.SplitButtonBasic} /> |
| 22 | + |
| 23 | + <h3><Anchor id="btn-dropdowns-sizing">Sizing</Anchor></h3> |
| 24 | + <p>Dropdowns work with buttons of all sizes.</p> |
| 25 | + <ReactPlayground codeText={Samples.DropdownButtonSizes} /> |
| 26 | + |
| 27 | + <h3><Anchor id="btn-dropdowns-nocaret">No caret variation</Anchor></h3> |
| 28 | + <p>Remove the caret using the <code>noCaret</code> prop.</p> |
| 29 | + <ReactPlayground codeText={Samples.DropdownButtonNoCaret} /> |
| 30 | + |
| 31 | + <h3><Anchor id="btn-dropdowns-dropup">Dropup variation</Anchor></h3> |
| 32 | + <p>Trigger dropdown menus that site above the button by adding the <code>dropup</code> prop.</p> |
| 33 | + <ReactPlayground codeText={Samples.SplitButtonDropup} /> |
| 34 | + |
| 35 | + <h3><Anchor id="btn-dropdowns-right">Dropdown right variation</Anchor></h3> |
| 36 | + <p>Trigger dropdown menus that align to the right of the button using the <code>pullRight</code> prop.</p> |
| 37 | + <ReactPlayground codeText={Samples.SplitButtonRight} /> |
| 38 | + |
| 39 | + <h3><Anchor id="btn-dropdowns-custom">Dropdown Customization</Anchor></h3> |
| 40 | + <p> |
| 41 | + If the default handling of the dropdown menu and toggle components aren't to your liking, you can |
| 42 | + customize them, by using the more basic <code>Dropdown</code> Component to explicitly specify |
| 43 | + the Toggle and Menu components |
| 44 | + </p> |
| 45 | + <div className="bs-callout bs-callout-info"> |
| 46 | + <h4>Additional Import Options</h4> |
| 47 | + <p> |
| 48 | + As a convenience Toggle and Menu components available as static properties |
| 49 | + on the Dropdown component. However, you can also import them directly, from |
| 50 | + the <code>/lib</code> directory like: <code>{'require("react-bootstrap/lib/DropdownToggle")'}</code>. |
| 51 | + </p> |
| 52 | + </div> |
| 53 | + <ReactPlayground codeText={Samples.DropdownButtonCustom} /> |
| 54 | + |
| 55 | + <h4>Custom Dropdown Components</h4> |
| 56 | + |
| 57 | + <p> |
| 58 | + For those that want to customize everything, you can forgo the included Toggle and Menu components, |
| 59 | + and create your own. In order to tell the Dropdown component what role your custom components play |
| 60 | + add a special prop <code>bsRole</code> to your menu or toggle components. The Dropdown expects |
| 61 | + at least one component with <code>bsRole="toggle"</code> and exactly one with <code>bsRole="menu"</code>. |
| 62 | + </p> |
| 63 | + <ReactPlayground codeText={Samples.DropdownButtonCustomMenu} /> |
| 64 | + |
| 65 | + <h3><Anchor id="btn-dropdowns-props">Props</Anchor></h3> |
| 66 | + |
| 67 | + <h4><Anchor id="btn-dropdowns-props-dropdown-button">DropdownButton</Anchor></h4> |
| 68 | + <PropTable component="DropdownButton"/> |
| 69 | + |
| 70 | + <h4><Anchor id="btn-dropdowns-props-split">SplitButton</Anchor></h4> |
| 71 | + <PropTable component="SplitButton"/> |
| 72 | + |
| 73 | + <h4><Anchor id="btn-dropdowns-props-dropdown">Dropdown</Anchor></h4> |
| 74 | + <PropTable component="Dropdown"/> |
| 75 | + </div> |
| 76 | + ); |
| 77 | +} |
0 commit comments