Buttons
React Bootstrap 5 Buttons component
Use MDB custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.
Note: Read the API tab to find all available options and advanced customization
Basic example
import React from 'react';
import { MDBBtn } from 'mdb-react-ui-kit';
export default function App() {
return (
<MDBBtn>Button</MDBBtn>
);
}
Disable text wrapping
If you don’t want the button text to wrap, you can add the
.text-nowrap className to the button. In Sass, you can set
$btn-white-space: nowrap to disable text wrapping for each button.
Colors
MDB includes several predefined button styles, each serving its own semantic purpose, with a few extras thrown in for more control.
import React from 'react';
import { MDBBtn } from 'mdb-react-ui-kit';
export default function App() {
return (
<>
<MDBBtn>Primary</MDBBtn>
<MDBBtn className='mx-2' color='secondary'>
Secondary
</MDBBtn>
<MDBBtn color='success'>Success</MDBBtn>
<MDBBtn className='mx-2' color='danger'>
Danger
</MDBBtn>
<MDBBtn color='warning'>Warning</MDBBtn>
<MDBBtn className='mx-2' color='info'>
Info
</MDBBtn>
<MDBBtn className='text-dark' color='light'>
Light
</MDBBtn>
<MDBBtn className='mx-2' color='dark'>
Dark
</MDBBtn>
<MDBBtn color='link'>Link</MDBBtn>
</>
);
}
Conveying meaning to assistive technologies:
Using color to add meaning only provides a visual indication, which will not be conveyed to
users of assistive technologies – such as screen readers. Ensure that information denoted by
the color is either obvious from the content itself (e.g. the visible text), or is included
through alternative means, such as additional text hidden with the
.visually-hidden className.
Outline
In need of a button, but not the hefty background colors they bring? Add outline property to remove all background images and
colors on any button.
import React from 'react';
import { MDBBtn } from 'mdb-react-ui-kit';
export default function App() {
return (
<>
<MDBBtn outline>Primary</MDBBtn>
<MDBBtn outline className='mx-2' color='secondary'>
Secondary
</MDBBtn>
<MDBBtn outline color='success'>
Success
</MDBBtn>
<MDBBtn outline className='mx-2' color='danger'>
Danger
</MDBBtn>
<MDBBtn outline color='warning'>
Warning
</MDBBtn>
<MDBBtn outline className='mx-2' color='info'>
Info
</MDBBtn>
<MDBBtn outline color='light'>
Light
</MDBBtn>
<MDBBtn outline className='mx-2' color='dark'>
Dark
</MDBBtn>
<MDBBtn outline color='link'>
Link
</MDBBtn>
</>
);
}
Some of the button styles use a relatively light foreground color, and should only be used on a dark background in order to have sufficient contrast.
Rounded
Add rounded property to make the button rounded.
import React from 'react';
import { MDBBtn } from 'mdb-react-ui-kit';
export default function App() {
return (
<>
<MDBBtn rounded>Primary</MDBBtn>
<MDBBtn rounded className='mx-2' color='secondary'>
Secondary
</MDBBtn>
<MDBBtn rounded color='success'>
Success
</MDBBtn>
<MDBBtn rounded className='mx-2' color='danger'>
Danger
</MDBBtn>
<MDBBtn rounded color='warning'>
Warning
</MDBBtn>
<MDBBtn rounded className='mx-2' color='info'>
Info
</MDBBtn>
<MDBBtn rounded className='text-dark' color='light'>
Light
</MDBBtn>
<MDBBtn rounded className='mx-2' color='dark'>
Dark
</MDBBtn>
<MDBBtn rounded color='link'>
Link
</MDBBtn>
</>
);
}
Rounded outline
You can use outline and rounded together to make the
button outline and rounded at the same time.
import React from 'react';
import { MDBBtn } from 'mdb-react-ui-kit';
export default function App() {
return (
<>
<MDBBtn outline rounded>
Primary
</MDBBtn>
<MDBBtn outline rounded className='mx-2' color='secondary'>
Secondary
</MDBBtn>
<MDBBtn outline rounded color='success'>
Success
</MDBBtn>
<MDBBtn outline rounded className='mx-2' color='danger'>
Danger
</MDBBtn>
<MDBBtn outline rounded color='warning'>
Warning
</MDBBtn>
<MDBBtn outline rounded className='mx-2' color='info'>
Info
</MDBBtn>
<MDBBtn outline rounded color='light'>
Light
</MDBBtn>
<MDBBtn outline rounded className='mx-2' color='dark'>
Dark
</MDBBtn>
<MDBBtn outline rounded color='link'>
Link
</MDBBtn>
</>
);
}
Floating
Use floating property to make a circle button.
To make it works properly you have to put an icon inside. The text will not fit in. You can find hundreds of available icons in our icons docs.
import React from 'react';
import { MDBBtn, MDBIcon } from 'mdb-react-ui-kit';
export default function App() {
return (
<MDBBtn floating tag='a'>
<MDBIcon fas icon='download' />
</MDBBtn>
);
}
You can apply almost all the same classes and attributes to the floating buttons as to the regular buttons - colors, sizes, outline, etc.
import React from 'react';
import { MDBBtn, MDBIcon } from 'mdb-react-ui-kit';
export default function App() {
return (
<>
<MDBBtn floating size='lg' tag='a'>
<MDBIcon fab icon='facebook-f' />
</MDBBtn>
<MDBBtn className='mx-2' tag='a' color='success' outline floating>
<MDBIcon fas icon='star' />
</MDBBtn>
<MDBBtn color='danger' tag='a' floating>
<MDBIcon fas icon='magic' />
</MDBBtn>
<MDBBtn className='ms-2' tag='a' color='dark' floating>
<MDBIcon fab icon='apple' />
</MDBBtn>
</>
);
}
Sizes
Fancy larger or smaller buttons? Add size='lg' or size='sm' property for
additional sizes.
import React from 'react';
import { MDBBtn } from 'mdb-react-ui-kit';
export default function App() {
return (
<>
<MDBBtn size='sm'>Button</MDBBtn>
<MDBBtn className='mx-2'>Button</MDBBtn>
<MDBBtn size='lg'>Button</MDBBtn>
<>
);
}
Active state
Add active property to make the button look pressed.
import React from 'react';
import { MDBBtn } from 'mdb-react-ui-kit';
export default function App() {
return (
<>
<MDBBtn size='lg' className='me-2' active>
Button
</MDBBtn>
<MDBBtn size='lg' tag='a' href='#' color='secondary' active>
Link
</MDBBtn>
</>
);
}
Disabled state
Make buttons look inactive by adding the disabled boolean property to any
<MDBBtn> component. Disabled buttons have
pointer-events: none applied to, preventing hover and active states from
triggering.
import React from 'react';
import { MDBBtn } from 'mdb-react-ui-kit';
export default function App() {
return (
<>
<MDBBtn className='me-2' disabled size='lg'>
Primary button
</MDBBtn>
<MDBBtn color='secondary' disabled size='lg'>
Button
</MDBBtn>
<>
);
}
Disabled buttons using the <a> element behave a bit different:
-
<a>s don’t support thedisabledattribute, sodisabledproperty will add the.disabledclassName to make it visually appear disabled. -
Some future-friendly styles are included to disable all
pointer-eventson anchor buttons. In browsers which support that property, you won’t see the disabled cursor at all. -
Disabled buttons should include the
aria-disabled="true"attribute to indicate the state of the element to assistive technologies.
import React from 'react';
import { MDBBtn } from 'mdb-react-ui-kit';
export default function App() {
return (
<>
<MDBBtn className='me-2' tag='a' href='#' disabled size='lg' tabIndex='-1' aria-disabled>
Primary link
</MDBBtn>
<MDBBtn tag='a' href='#' color='secondary' disabled size='lg' tabIndex='-1' aria-disabled>
Link
</MDBBtn>
</>
);
}
Link functionality caveat:
The .disabled className uses pointer-events: none to try to disable the
link functionality of <a>s, but that CSS property is not yet standardized.
In addition, even in browsers that do support pointer-events: none, keyboard
navigation remains unaffected, meaning that sighted keyboard users and users of assistive
technologies will still be able to activate these links. So to be safe, add a
tabindex="-1" attribute on these links (to prevent them from receiving keyboard
focus) and use custom JavaScript to disable their functionality.
Toggle states
Add toggle property to toggle a button’s active state. If
you’re pre-toggling a button, you must manually add the active property.
import React from 'react';
import { MDBBtn } from 'mdb-react-ui-kit';
export default function App() {
return (
<>
<MDBBtn toggle>Toggle button</MDBBtn>
<MDBBtn className='mx-2' toggle active>
Active toggle button
</MDBBtn>
<MDBBtn toggle disabled>
Disabled toggle button
</MDBBtn>
</>
);
}
import React from 'react';
import { MDBBtn } from 'mdb-react-ui-kit';
export default function App() {
return (
<>
<MDBBtn href='#' toggle>
Toggle link
</MDBBtn>
<MDBBtn href='#' className='mx-2' toggle active>
Active toggle link
</MDBBtn>
<MDBBtn href='#' toggle disabled>
Disabled toggle link
</MDBBtn>
</>
);
}
Buttons - API
Import
import { MDBBtn } from 'mdb-react-ui-kit';