A set of React components for Bootstrap 4.
The Container
, Row
and Col
components help you put together a grid.
Container
Props:
fluid
(boolean) - true for a container which fills its parent, or false (or omitted) for a fixed-width container
Row
No extra props.
Col
Props:
xs
,sm
,md
,lg
,xl
(integer) - the width at various breakpointsalign
('start'
,'end'
,'center'
,'baseline'
or'stretch'
) - flex alignment
Example
const MyGrid = (props) => (
<Container fluid>
<Row>
<Col xs={12} md={6}>1</Col>
<Col xs={12} md={6}>2</Col>
</Row>
</Container>
);
Navbar
Props:
bsStyle
('light'
or'inverse'
)
NavbarBrand
No extra props.
Example
const MyNavbar = (props) => (
<Navbar>
</Navbar>
);
PasswordMeter
Shows a strength bar with 5 segments. As score
increases, the length of the bar increases, and the colour changes from red to green through yellow.
Props:
strength
(0
,1
,2
,3
,4
) - the strength of the passwordfeedback
(string) - an optional feedback message, e.g., 'too short'
ZxcvbnMeter
This renders the PasswordMeter
component above, calculating score
and feedback
by using the zxcvbn
library.
Props:
password
(string) - the password to analyse
FormGroup
Renders a form group, i.e., input element, label, help text, error messages, etc.
Props:
type
(string) - input type, any of the standard<input>
types plus'textarea'
id
(string) - the input IDlabel
(string) - the form control labeloptional
(boolean) - unless true, the label will be bold with a red star afterhelp
(string) - small, muted help text after the form controlvalue
(any) - the value for the controloptionValue
(any) - fortype='radio'
; ifvalue===optionValue
, the control will be checkedvalid
(boolean) - if validation has passed; if false, the control and label will be highlighted in rederrors
(string[]) - an array of error messages for validationonChange
(function) - passed to the input controlshowStrength
(boolean) - if true, aZxcvbnMeter
will be shown underneath the controlinline
(boolean) - if true, addsform-check-inline
triggerKey(key?: string)
Decorator which triggers the click event on an element when the specified key is pressed. The key can either be specified as an argument to the decorator or as the prop triggerKey
.
ClickTarget
Renders one of <a>
, <button>
, <Link>
(from react-router-dom
) or <div>
, depending on supplied props.
Props:
href
(string) - supply to get ana
linkonClick
(function) - supply to get abutton
to
(string) - supply to get aLink
triggerKey
- fortriggerKey
decorator above
If none of the above are specified, defaults to a div
.
Button
As above, but adds bootstrap button styling.
Props:
- all
ClickTarget
props bsStyle
- ('primary'
,'success'
,'info'
,'warning'
,'danger'
, or'default'
) - the style of the buttonsubmit
- true if the button is to be a submit buttonfab
- true to make the button a Floating Action Button
Badge
Props:
bsStyle
('primary'
,'success'
,'info'
,'warning'
,'danger'
, or'default'
) - the style of the badgepill
(boolean) - true to make the badge a pill
Icon
Render a Font Awesome icon.
Props:
fa
(string, one of the Font Awesome icon names) - the icon to render