I have the following JSX using React-Bootstrap:
<Button bsStyle="danger pull-right" bsSize="small" onClick={() => {alert('do stuff')}}> <Glyphicon glyph="trash" /> </Button>
This does work, but it shows a warning in the console:
Warning: Failed prop type: Invalid prop
bsStyle
of valuedanger pull-right
supplied toButton
, expected one of["success","warning","danger","info","default","primary","link"]
.
What is the best way to add pull-right
to the list of styles? I'd prefer not to have any warnings in my console.
Answer: Use the text-right Classtext-right on the containing element to right align your Bootstrap buttons within a block box or grid column.
To align a component to the center or right with React Material UI, we can add a flex container with the Grid component. We add the Grid component and add the container prop to make it a flexbox container. Then we set the justify prop to flex-end to align the child components on the right side.
If you take a look at React-Bootstrap Components, you'll see that prop bsStyle
of component Button
only accepts the following values:
"success", "warning", "danger", "info", "default", "primary", "link"
based on its visual appearance as mentioned in the warning message. If you intend to use Bootstrap's pull-right
class, just use the className
attribute which will set the class of that component:
<Button className="pull-right" bsStyle="danger" bsSize="small" onClick={() => {alert('do stuff')}}> <Glyphicon glyph="trash" /> </Button>
Now that React Bootstrap uses Bootstrap 4, use float-right
, float-sm-right
, etc.:
<Button className="float-right" bsStyle="danger" bsSize="small" onClick={() => {alert('do stuff')}}> <Glyphicon glyph="trash" /> </Button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With