<Alert color="primary">This is a primary alert </Alert>
<Alert color="primary">
<h4 className="alert-heading">Well done!</h4>
<a href="#" className="alert-link">an example link</a>.
</Alert>
有关闭x按钮
<Alert color="info" isOpen={this.state.visible} toggle={this.onDismiss}>
I am an alert and I can be dismissed!
</Alert>
推荐写法【简洁】
<UncontrolledAlert color="info"> I can be dismissed!</UncontrolledAlert>
过渡动画 fade
<Alert color="primary" toggle={this.onDismiss} fade={false}>
I can be dismissed without animating!
</Alert>
颜色 尺寸 块结构 显示颜色区域outline
<Button outline color="primary" size="lg" block>primary</Button>
<Button outline color="primary" size="sm" block>primary</Button>
Active State
<Button color="secondary" size="lg" active>Link</Button>
Disabled State
<Button color="secondary" size="lg" disabled>Button</Button>
Radio Buttons 和Checkbox Buttons 控制ative状态
<Button color="primary" onClick={() => this.onRadioBtnClick(1)} active={this.state.rSelected === 1}>One</Button>
<Button color="primary" onClick={() => this.onCheckboxBtnClick(1)} active={this.state.cSelected.includes(1)}>One</Button>
Close icon x 关闭按钮图标,一般和card 结合使用
<Button close />
<CardGroup>
<Card>
<CardBody>
<CardTitle>
<Button close />
</CardTitle>
<CardText>Default close icon</CardText>
</CardBody>
</Card>
</CardGroup>
Card
card 内部可以实现完整布局
import { Card, CardImg, CardText, CardBody,
CardTitle, CardSubtitle, Button } from 'reactstrap';
<div>
<Card>
<CardImg top width="100%" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=318%C3%97180&w=318&h=180" alt="Card image cap" />
<CardBody>
<CardTitle>Card title</CardTitle>
<CardSubtitle>Card subtitle</CardSubtitle>
<CardText>Some quick example text to build on the card title and make up the bulk of the card's content.</CardText>
<Button>Button</Button>
</CardBody>
</Card>
</div>
card 的身体布局
<div>
<Card body>
<CardTitle>Special Title Treatment</CardTitle>
<CardText>With supporting text below as a natural lead-in to additional content.</CardText>
<Button>Go somewhere</Button>
</Card>
</div>
card 的头/尾 身体布局
<div>
<Card>
<CardHeader>Header</CardHeader>
<CardBody>
<CardTitle>Special Title Treatment</CardTitle>
<CardText>With supporting text below as a natural lead-in to additional content.</CardText>
<Button>Go somewhere</Button>
</CardBody>
<CardFooter>Footer</CardFooter>
</Card>
</div>
图片
<CardImg top width="100%" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=318%C3%97180&w=318&h=180" alt="Card image cap" />
Background variants 背景色
<Card body inverse style={{ backgroundColor: '#333', borderColor: '#333' }}>
<CardTitle>Special Title Treatment</CardTitle>
<CardText>With supporting text below as a natural lead-in to additional content.</CardText>
<Button>Button</Button>
</Card>
<Card body inverse color="primary">
<CardTitle>Special Title Treatment</CardTitle>
<CardText>With supporting text below as a natural lead-in to additional content.</CardText>
<Button color="secondary">Button</Button>
</Card>
Groups 组
<CardGroup>
<Card>
<CardImg top width="100%" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=256%C3%97180&w=256&h=180" alt="Card image cap" />
<CardBody>
<CardTitle>Card title</CardTitle>
<CardSubtitle>Card subtitle</CardSubtitle>
<CardText>This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</CardText>
<Button>Button</Button>
</CardBody>
</Card>
</CardGroup>
平板化DecK
<CardDeck>
<Card>
<CardImg top width="100%" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=256%C3%97180&w=256&h=180" alt="Card image cap" />
<CardBody>
<CardTitle>Card title</CardTitle>
<CardSubtitle>Card subtitle</CardSubtitle>
<CardText>This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</CardText>
<Button>Button</Button>
</CardBody>
</Card>
</CardDeck>
<div>
<Jumbotron>
<h1 className="display-3">Hello, world!</h1>
<p className="lead">This is a simple hero unit, a simple Jumbotron-style component for calling extra attention to featured content or information.</p>
<hr className="my-2" />
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
<p className="lead">
<Button color="primary">Learn More</Button>
</p>
</Jumbotron>
</div>
<ListGroup>/<ListGroup flush>
<ListGroupItem color="success">Cras justo odio</ListGroupItem>
<ListGroupItem color="warning">Dapibus ac facilisis in</ListGroupItem>
<ListGroupItem className="justify-content-between">Cras justo odio <Badge pill>14</Badge></ListGroupItem>
<ListGroupItem disabled tag="a" href="#">Cras justo odio</ListGroupItem>
<ListGroupItem tag="a" href="#">Dapibus ac facilisis in</ListGroupItem>
<ListGroupItem active tag="a" href="#" action>Cras justo odio</ListGroupItem>
<ListGroupItem tag="a" href="#" action>Dapibus ac facilisis in</ListGroupItem>
<ListGroupItem active>
<ListGroupItemHeading>List group item heading</ListGroupItemHeading>
<ListGroupItemText>
Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
</ListGroupItemText>
</ListGroupItem>
</ListGroup>
Media object 加载图片及添加描述,类似购物card
import { Media } from 'reactstrap';
<Media>
<Media left href="#">
<Media object data-src="holder.js/64x64" alt="Generic placeholder image" />
</Media>
<Media body>
<Media heading>
Media heading
</Media>
Cras sit amet nibh libero, in gravida nulla.
<Media>
<Media left href="#">
<Media object data-src="holder.js/64x64" alt="Generic placeholder image" />
</Media>
<Media body>
<Media heading>
Nested media heading
</Media>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</Media>
</Media>
</Media>
</Media>
设置点击按钮在按钮旁边显示小的弹窗 显示信息 ,placement可以设置方向top/left/right/bottom
target 可以设置点击目标对象
<div>
<Button id="Popover1" type="button">
Launch Popover
</Button>
<Popover placement="bottom" isOpen={this.state.popoverOpen} target="Popover1" toggle={this.toggle}>
<PopoverHeader>Popover Title</PopoverHeader>
<PopoverBody>Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.</PopoverBody>
</Popover>
设置触发
// space separated list of triggers (e.g. "click hover focus")
trigger: PropTypes.string,
<Button id="PopoverLegacy" type="button">
Launch Popover (Legacy)
</Button>
<UncontrolledPopover trigger="focus" placement="bottom" target="PopoverFocus">
<PopoverHeader>Focus Trigger</PopoverHeader>
<PopoverBody>Focusing on the trigging element makes this popover appear. Blurring (clicking away) makes it disappear. You cannot select this text as the popover will disappear when you try.</PopoverBody>
</UncontrolledPopover>
</div>
placement: PropTypes.oneOf([
'auto', 'auto-start', 'auto-end',
'top', 'top-start', 'top-end',
'right', 'right-start', 'right-end',
'bottom', 'bottom-start', 'bottom-end',
'left', 'left-start', 'left-end',
]),
Progress 进度条显示
可以设置进度条中显示为动态滚动条纹效果animated 静态条纹striped
多个显示在一个中关键字 multi
color 设置进度条颜色
在多个进度条中 需要关键字 bar
<div className="text-center">463 of 500</div>进度条上面的内容
<Progress value="463" max={500} />
<Progress bar color="success" value="35">Wow!进度条中显示内容</Progress>
<div className="text-center">With Labels</div>
<Progress multi> 多个内容在一个进度条中显示,分为多段,效果像断点续传
<Progress bar value="15">Meh 关键字 bar</Progress>
<Progress bar striped color="success" value="35">Wow!</Progress>
<Progress bar animated color="warning" value="25">25%</Progress>
<Progress bar color="danger" value="25">LOOK OUT!!</Progress>
</Progress>
Toast.propTypes = {
className: PropTypes.string,
color: PropTypes.string, // default: 'success'
isOpen: PropTypes.bool, // default: true
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
// Controls the transition of the toast fading in and out
// See Fade for more details
transition: PropTypes.shape(Fade.propTypes),
}
添加了 toggle={this.toggle}在头部会有x关闭按钮
<div>
<Button color="primary" onClick={this.toggle}>{this.props.buttonLabel}</Button>
<Toast isOpen={this.state.show}>
<ToastHeader toggle={this.toggle}>Toast title</ToastHeader>
<ToastBody>
Lorem ipsum dolor sit amet
</ToastBody>
</Toast>
默认为显示 isOpen为true
<Toast>
<ToastHeader icon={<Spinner size="sm" />}>
Reactstrap
</ToastHeader>
<ToastBody>
This is a toast with a custom icon — check it out!
</ToastBody>
</Toast>
</div>
Tooltips 工具提示文本信息与Popovers 相似
可设置提示位置,是否显示,target 为触发显示的目标的Id,鼠标移动到目标 提示信息显示。propovers需要点击触发。
<div>
<p>Sometimes you need to allow users to select text within a <span style={{textDecoration: "underline", color:"blue"}} href="#" id="DisabledAutoHideExample">tooltip</span>.</p>
<Tooltip placement="top" isOpen={this.state.tooltipOpen} autohide={false} target="DisabledAutoHideExample" toggle={this.toggle}>
Try to select this text!
</Tooltip>
推荐使用
<p>Somewhere in here is a <span style={{textDecoration: "underline", color:"blue"}} href="#" id="UncontrolledTooltipExample">tooltip</span>.</p>
<UncontrolledTooltip placement="right" target="UncontrolledTooltipExample">
Hello world!
</UncontrolledTooltip>
</div>