mdb-ui-kit/docs/components/button-dropdown.md

320 lines
13 KiB
Markdown
Raw Normal View History

---
layout: docs
title: Button dropdown
group: components
---
2016-03-18 01:25:31 +03:00
[//]: # DO NOT EDIT IT WILL BE OVERWRITTEN - copy of bootstrap documentation generated by gulp docs:copy:bs-docs
{% callout info %}
2016-03-09 19:23:01 +03:00
**Bootstrap Reference Documentation**
This is a part of the reference documentation from <a href="http://getbootstrap.com">Bootstrap</a>.
It is included here to demonstrate rendering with Bootstrap Material Design default styling.
See the <a href="/material-design/buttons">Material Design</a> section for more elements and customization options.
{% endcallout %}
2016-03-09 19:23:01 +03:00
Use any button to trigger a dropdown menu by placing it within a `.btn-group` and providing the proper dropdown menu markup.
{% callout danger %}
#### Plugin dependency
Button dropdowns require the [dropdown plugin]({{ site.baseurl }}/components/dropdowns/) to be included in your version of Bootstrap.
{% endcallout %}
## Contents
* Will be replaced with the ToC, excluding the "Contents" header
{:toc}
### Single button dropdowns
Turn a button into a dropdown toggle with some basic markup changes.
<div class="bd-example">
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Default</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Primary</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
<div class="btn-group">
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Success</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
<div class="btn-group">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Info</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
<div class="btn-group">
<button type="button" class="btn btn-warning dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Warning</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
<div class="btn-group">
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Danger</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
</div>
{% highlight html %}
<!-- Single button -->
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Action
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div>
{% endhighlight %}
### Split button dropdowns
Similarly, create split button dropdowns with the same markup changes, only with a separate button.
<div class="bd-example">
<div class="btn-group">
<button type="button" class="btn btn-secondary">Default</button>
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
<div class="btn-group">
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
<div class="btn-group">
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
<div class="btn-group">
<button type="button" class="btn btn-info">Info</button>
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
<div class="btn-group">
<button type="button" class="btn btn-warning">Warning</button>
<button type="button" class="btn btn-warning dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
<div class="btn-group">
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
</div>
{% highlight html %}
<!-- Split button -->
<div class="btn-group">
<button type="button" class="btn btn-danger">Action</button>
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div>
{% endhighlight %}
### Sizing
Button dropdowns work with buttons of all sizes.
<div class="bd-example">
<div class="btn-toolbar" role="toolbar">
<div class="btn-group">
<button class="btn btn-secondary btn-lg dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Large button
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
</div><!-- /btn-toolbar -->
<div class="btn-toolbar" role="toolbar">
<div class="btn-group">
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Small button
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
</div><!-- /btn-toolbar -->
</div><!-- /example -->
{% highlight html %}
<!-- Large button group -->
<div class="btn-group">
<button class="btn btn-secondary btn-lg dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Large button
</button>
<div class="dropdown-menu">
...
</div>
</div>
<!-- Small button group -->
<div class="btn-group">
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Small button
</button>
<div class="dropdown-menu">
...
</div>
</div>
{% endhighlight %}
### Dropup variation
Trigger dropdown menus above elements by adding `.dropup` to the parent.
<div class="bd-example">
<div class="btn-toolbar" role="toolbar">
<div class="btn-group dropup">
<button type="button" class="btn btn-secondary">Dropup</button>
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
<div class="btn-group dropup">
<button type="button" class="btn btn-primary">Right dropup</button>
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#0">Action</a>
<a class="dropdown-item" href="#0">Another action</a>
<a class="dropdown-item" href="#0">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#0">Separated link</a>
</div>
</div><!-- /btn-group -->
</div>
</div>
{% highlight html %}
<div class="btn-group dropup">
<button type="button" class="btn btn-secondary">Dropup</button>
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
<!-- Dropdown menu links -->
</div>
</div>
{% endhighlight %}