Layout Components (Container, Row, Col)
.col-3
.col-auto - variable width content
.col-3
.col-6 .col-sm-4
.col-6 .col-sm-4
.col-sm-4
.col-sm-6 .order-sm-2 .offset-sm-1
.col-sm-12 .col-md-6 .offset-md-3
.col-sm-auto .offset-sm-1
.col-sm-auto .offset-sm-1
import React from 'react';
import { Container, Row, Col } from 'reactstrap';
const Example = (props) => {
return (
<Container>
<Row>
<Col>.col</Col>
</Row>
<Row>
<Col>.col</Col>
<Col>.col</Col>
<Col>.col</Col>
<Col>.col</Col>
</Row>
<Row>
<Col xs="3">.col-3</Col>
<Col xs="auto">.col-auto - variable width content</Col>
<Col xs="3">.col-3</Col>
</Row>
<Row>
<Col xs="6">.col-6</Col>
<Col xs="6">.col-6</Col>
</Row>
<Row>
<Col xs="6" sm="4">.col-6 .col-sm-4</Col>
<Col xs="6" sm="4">.col-6 .col-sm-4</Col>
<Col sm="4">.col-sm-4</Col>
</Row>
<Row>
<Col sm={{ size: 6, order: 2, offset: 1 }}>.col-sm-6 .order-sm-2 .offset-sm-1</Col>
</Row>
<Row>
<Col sm="12" md={{ size: 6, offset: 3 }}>.col-sm-12 .col-md-6 .offset-md-3</Col>
</Row>
<Row>
<Col sm={{ size: 'auto', offset: 1 }}>.col-sm-auto .offset-sm-1</Col>
<Col sm={{ size: 'auto', offset: 1 }}>.col-sm-auto .offset-sm-1</Col>
</Row>
</Container>
);
}
export default Example;
Container Properties
Container.propTypes = {
fluid: PropTypes.oneOfType([PropTypes.bool, PropTypes.string])
// applies .container-fluid class if bool or .container-{breakpoint} if string
}
Row Properties
Row.propTypes = {
noGutters: PropTypes.bool,
// see https://reactstrap.github.io/components/form Form Grid with Form Row
form: PropTypes.bool,
xs: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
sm: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
md: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
lg: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
xl: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
}
Col Properties
const stringOrNumberProp = PropTypes.oneOfType([PropTypes.number, PropTypes.string]);
const columnProps = PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool,
PropTypes.shape({
size: PropTypes.oneOfType([PropTypes.bool, PropTypes.number, PropTypes.string]),
// example size values:
// 12 || "12" => col-12 or col-`width`-12
// auto => col-auto or col-`width`-auto
// true => col or col-`width`
order: stringOrNumberProp,
offset: stringOrNumberProp
})
]);
Col.propTypes = {
xs: columnProps,
sm: columnProps,
md: columnProps,
lg: columnProps,
xl: columnProps,
// override the predefined width (the ones above) with your own custom widths.
// see https://github.com/reactstrap/reactstrap/issues/297#issuecomment-273556116
widths: PropTypes.array,
}
Container
.container
.container-sm
.container-md
.container-lg
.container-xl
.container-fluid
import React from 'react';
import { Container } from 'reactstrap';
const Example = (props) => {
return (
<>
<Container className="themed-container">.container</Container>
<Container className="themed-container" fluid="sm">.container-sm</Container>
<Container className="themed-container" fluid="md">.container-md</Container>
<Container className="themed-container" fluid="lg">.container-lg</Container>
<Container className="themed-container" fluid="xl">.container-xl</Container>
<Container className="themed-container" fluid={true}>.container-fluid</Container>
</>
);
}
export default Example;
Row Columns
import React from 'react';
import { Container, Row, Col } from 'reactstrap';
const Example = (props) => {
return (
<Container>
<Row xs="2">
<Col>Column</Col>
<Col>Column</Col>
<Col>Column</Col>
<Col>Column</Col>
</Row>
<Row xs="3">
<Col>Column</Col>
<Col>Column</Col>
<Col>Column</Col>
<Col>Column</Col>
</Row>
<Row xs="4">
<Col>Column</Col>
<Col>Column</Col>
<Col>Column</Col>
<Col>Column</Col>
</Row>
<Row xs="4">
<Col>Column</Col>
<Col>Column</Col>
<Col xs="6">Column</Col>
<Col>Column</Col>
</Row>
<Row xs="1" sm="2" md="4">
<Col>Column</Col>
<Col>Column</Col>
<Col>Column</Col>
<Col>Column</Col>
</Row>
</Container>
);
}
export default Example;