React Bootstrap Buttons
React Buttons - Bootstrap 4 & Material Design
Note: This documentation is for an older version of Bootstrap (v.4). A
newer version is available for Bootstrap 5. We recommend migrating to the latest version of our product - Material Design for
Bootstrap 5.
Go to docs v.5
Basic examples
Bootstrap includes several predefined button styles, each serving its own semantic purpose, with a few extras thrown in for more control.
import React, { Fragment } from "react";
import { MDBBtn } from "mdbreact";
const ButtonPage = () => {
return (
<Fragment>
<MDBBtn color="primary">Primary</MDBBtn>
<MDBBtn>Default</MDBBtn>
<MDBBtn color="secondary">Secondary</MDBBtn>
<MDBBtn color="success">Success</MDBBtn>
<MDBBtn color="info">Info</MDBBtn>
<MDBBtn color="warning">Warning</MDBBtn>
<MDBBtn color="danger">Danger</MDBBtn>
</Fragment>
);
}
export default ButtonPage;
Additional styles
MDBootstrap includes several predefined button styles, each serving its own semantic purpose, with a few extras thrown in for more control.
import React, { Fragment } from "react";
import { MDBBtn } from "mdbreact";
const ButtonPage = () => {
return (
<Fragment>
<MDBBtn color="elegant">Elegant</MDBBtn>
<MDBBtn color="unique">Unique</MDBBtn>
<MDBBtn color="pink">Pink</MDBBtn>
<MDBBtn color="purple">Purple</MDBBtn>
<MDBBtn color="deep-purple">Deep-purple</MDBBtn>
<MDBBtn color="indigo">Indigo</MDBBtn>
<MDBBtn color="light-blue">Light blue</MDBBtn>
<MDBBtn color="cyan">Cyan</MDBBtn>
<MDBBtn color="dark-green">Dark-green</MDBBtn>
<MDBBtn color="light-green">Light-green</MDBBtn>
<MDBBtn color="yellow">Yellow</MDBBtn>
<MDBBtn color="amber">Amber</MDBBtn>
<MDBBtn color="deep-orange">Deep-orange</MDBBtn>
<MDBBtn color="brown">Brown</MDBBtn>
<MDBBtn color="blue-grey">Blue-grey</MDBBtn>
<MDBBtn color="mdb-color">MDB</MDBBtn>
</Fragment>
);
}
export default ButtonPage;
Gradient buttons
Check our documentation about gradients.
import React, { Fragment } from "react";
import { MDBBtn } from "mdbreact";
const ButtonPage = () => {
return (
<Fragment>
<MDBBtn gradient="peach">Peach</MDBBtn>
<MDBBtn gradient="purple">Purple</MDBBtn>
<MDBBtn gradient="blue">Blue</MDBBtn>
<MDBBtn gradient="aqua">Aqua</MDBBtn>
</Fragment>
);
}
export default ButtonPage;
Outline buttons
In need of a button, but not the hefty background colors they bring? outline
property removes all
background images and colors on any button.
import React, { Fragment } from "react";
import { MDBBtn } from "mdbreact";
const ButtonPage = () => {
return (
<Fragment>
<MDBBtn outline color="primary">Primary</MDBBtn>
<MDBBtn outline>Default</MDBBtn>
<MDBBtn outline color="secondary">Secondary</MDBBtn>
<MDBBtn outline color="success">Success</MDBBtn>
<MDBBtn outline color="info">Info</MDBBtn>
<MDBBtn outline color="warning">Warning</MDBBtn>
<MDBBtn outline color="danger">Danger</MDBBtn>
</Fragment>
);
}
export default ButtonPage;
Waves effect with outline buttons
MDB automatically adds waves effect to each element with
.btn
class. However, in outline buttons, it's barely visible due to lack of background.That's why to outline buttons we add additional class
.waves-effect
to make waves darker and more intense.
Sizes
Fancy larger or smaller buttons? Add size
property for
additional sizes.
import React, { Fragment } from "react";
import { MDBBtn } from "mdbreact";
const ButtonPage = () => {
return (
<Fragment>
<MDBBtn color="primary" size="lg">Large button</MDBBtn>
<MDBBtn color="mdb-color">Normal button</MDBBtn>
<MDBBtn color="dark-green" size="sm">Small button</MDBBtn>
</Fragment>
);
}
export default ButtonPage;
Active state
Buttons will appear pressed (with a darker background, darker border, and inset shadow) when
active. You can force the same active appearance with active
prop.
import React, { Fragment } from "react";
import { MDBBtn } from "mdbreact";
const ButtonPage = () => {
return (
<Fragment>
<MDBBtn active color="primary">Active Button</MDBBtn>
<MDBBtn color="primary">Button</MDBBtn>
</Fragment>
);
}
export default ButtonPage;
Disabled state
Make buttons look inactive by adding the disabled
boolean prop to any <MDBBtn>
component.
import React, { Fragment } from "react";
import { MDBBtn } from "mdbreact";
const ButtonPage = () => {
return (
<Fragment>
<MDBBtn color="primary" disabled size="lg">Primary button</MDBBtn>
<MDBBtn color="default" disabled size="lg">Default button</MDBBtn>
</Fragment>
);
}
export default ButtonPage;
React Buttons - API
In this section you will find advanced information about the Buttons component. You will learn which modules are required in this component, what are the possibilities of configuring the component, and what events and methods you can use in working with it.
Import statement
import { MDBBtn, MDBIcon, MDBBtnFixed, MDBBtnFixedItem } from "mdbreact";
API Reference: Button Properties
The table below shows the configuration options of the MDBBtn component.
Name | Type | Default | Description | Example |
---|---|---|---|---|
action |
Boolean | false |
Adds btn-action class, works with Cards |
<MDBBtn action > |
active |
Boolean | false |
Adds active class | <MDBBtn active > |
block |
Boolean | false |
Create block level buttons | <MDBBtn block > |
circle |
Boolean | false |
Adds btn-circle class, works with stepper |
<MDBBtn circle > |
className |
String |
|
Adds custom classes | <MDBBtn className="customClass" > |
color |
String | default |
Determines button color, accepts MDB predefined color classes | <MDBBtn color="primary" > |
disabled |
Boolean | false |
Disables button from being clicked | <MDBBtn disabled > |
download |
String |
|
Adds download attribute with provided url | <MDBBtn download="https://link_to_your_file.com" > |
flat |
Boolean | false |
Adds flat effect to button - button without backgorund and borders | <MDBBtn flat > |
floating |
Boolean | false |
Adds floating effect to button | <MDBBtn floating > |
gradient |
String |
|
Adds gradient background to button, accepts MDB predefined gradients | <MDBBtn gradient="peach" > |
href |
String |
|
Adds href attribute with provided url and converts <button> tag into <a>
tag |
<MDBBtn href="..." > |
innerRef |
Object |
|
Allows to pass Ref object, which will attach to rendered button or a DOM
element |
<MDBBtn innerRef={this.buttonRef} > |
outline |
Boolean | false |
Renders button with outline, color property determines outline color |
<MDBBtn outline > |
role |
String | button |
Adds role attribute to button | <MDBBtn role="..." > |
rounded |
Boolean | false |
Adds rounded corners effect to button | <MDBBtn rounded > |
size |
String | medium |
Determines button size, available values: [sm , lg ], medium by
default |
<MDBBtn size="lg" > |
social |
String |
|
Sets background color | <MDBBtn social="fb" > |
tag |
String | button |
Changes default tag | <MDBBtn tag="a" > |
target |
String | _self |
If used as link, sets target attribute | <MDBBtn href="..." target="_blank" > |
type |
String | button |
Adds type attribute to button | <MDBBtn type="submit" > |
API Reference: ButtonFixed Properties
The table below shows the configuration options of the MDBBtnFixed component.
Name | Type | Default | Description | Example |
---|---|---|---|---|
active |
Boolean | false |
Adds active class | <MDBBtnFixed active > |
block |
Boolean | false |
Create block level buttons | <MDBBtnFixed block > |
className |
String |
|
Adds custom classes | <MDBBtnFixed className="customClass" > |
color |
String | default |
Determines button color, accepts MDB predefined color classes | <MDBBtnFixed color="primary" > |
disabled |
Boolean | false |
Disables button from being clicked | <MDBBtnFixed disabled > |
flat |
Boolean | false |
Adds flat effect to button - button without background and borders | <MDBBtnFixed flat > |
floating |
Boolean | false |
Adds floating effect to button | <MDBBtnFixed floating > |
gradient |
String |
|
Adds gradient background to button, accepts MDB predefined gradients | <MDBBtnFixed gradient="peach" > |
icon |
String |
|
Adds font-awesome icon |
<MDBBtnFixed icon="caret-right" />
|
iconBrand |
Boolean | false |
Use this property to set brand icon (fab ) |
<MDBBtnFixed icon="twitter" iconBrand />
|
iconClassName |
String |
|
Adds custom classes to icon element |
<MDBBtnFixed icon="envelope" iconClassName="customClass" />
|
iconLight |
Boolean | false |
Use this property to set light icon (fal ) |
<MDBBtnFixed icon="twitter" iconLight />
|
iconRegular |
Boolean | false |
Use this property to set regular icon (far ) |
<MDBBtnFixed icon="twitter" iconRegular />
|
iconSize |
String |
|
Sets icon size |
<MDBBtnFixed icon="pencil-alt" size="5x" />
|
innerRef |
Object |
|
Allows to pass Ref object, which will attach to rendered button or a DOM
element |
<MDBBtnFixed innerRef={this.buttonRef} > |
outline |
Boolean | false |
Renders button with outline, color property determines outline color |
<MDBBtnFixed outline > |
role |
String | button |
Adds role attribute to button | <MDBBtnFixed role="..." > |
rounded |
Boolean | false |
Adds rounded corners effect to button | <MDBBtnFixed rounded > |
size |
String | medium |
Determines button size, available values: [sm , lg ], medium by
default |
<MDBBtnFixed size="lg" > |
topSection |
String | # |
Sets url to your top section | <MDBBtnFixed topSection="#introduction" > |
type |
String | button |
Adds type attribute to button | <MDBBtnFixed type="submit" > |
API Reference: ButtonFixedItem Properties
The table below shows the configuration options of the MDBBtnFixedItem component.
Name | Type | Default | Description | Example |
---|---|---|---|---|
active |
Boolean | false |
Adds active class | <MDBBtnFixedItem active > |
block |
Boolean | false |
Create block level buttons | <MDBBtnFixedItem block > |
buttonStyle |
String |
|
Adds custom styling (component requires that because it is nested into list) | <MDBBtnFixedItem buttonStyle={{ border-color: "black" }} > |
className |
String |
|
Adds custom classes | <MDBBtnFixedItem className="customClass" > |
color |
String | default |
Determines button color, accepts MDB predefined color classes | <MDBBtnFixedItem color="primary" > |
disabled |
Boolean | false |
Disables button from being clicked | <MDBBtnFixedItem disabled > |
flat |
Boolean | false |
Adds flat effect to button - button without background and borders | <MDBBtnFixedItem flat > |
floating |
Boolean | false |
Adds floating effect to button | <MDBBtnFixedItem floating > |
gradient |
String |
|
Adds gradient background to button, accepts MDB predefined gradients | <MDBBtnFixedItem gradient="peach" > |
icon |
String |
|
Adds font-awesome icon |
<MDBBtnFixedItem icon="caret-right" />
|
iconBrand |
Boolean | false |
Use this property to set brand icon (fab ) |
<MDBBtnFixedItem icon="twitter" iconBrand />
|
iconClassName |
String |
|
Adds custom classes to icon element |
<MDBBtnFixedItem icon="envelope" iconClassName="customClass" />
|
iconLight |
Boolean | false |
Use this property to set light icon (fal ) |
<MDBBtnFixedItem icon="twitter" iconLight />
|
iconRegular |
Boolean | false |
Use this property to set regular icon (far ) |
<MDBBtnFixedItem icon="twitter" iconRegular />
|
iconSize |
String |
|
Sets icon size |
<MDBBtnFixedItem icon="pencil-alt" size="5x" />
|
innerRef |
Object |
|
Allows to pass Ref object, which will attach to rendered button or a DOM
element |
<MDBBtnFixedItem innerRef={this.buttonRef} > |
outline |
Boolean | false |
Renders button with outline, color property determines outline color |
<MDBBtnFixedItem outline > |
role |
String | button |
Adds role attribute to button | <MDBBtnFixedItem role="..." > |
rounded |
Boolean | false |
Adds rounded corners effect to button | <MDBBtnFixedItem rounded > |
size |
String | medium |
Determines button size, available values: [sm , lg ], medium by
default |
<MDBBtnFixedItem size="lg" > |
type |
String | button |
Adds type attribute to button | <MDBBtnFixedItem type="submit" > |