<Popover>
are toggleable overlays for displaying small overlays on demand.
The <Popover>
component requires you to provide a trigger with <PopoverTrigger>
that will handle the opening/closing of the overlay, as well as the content for the overlay through <PopoverBody />
.
Usage
import { Popover } from 'nr1'
Examples
Basic
<Popover> <PopoverTrigger>Trigger</PopoverTrigger> <PopoverBody> <BlockText>Body</BlockText> </PopoverBody></Popover>
Button as trigger
<Popover> <PopoverTrigger> <Button>Trigger</Button> </PopoverTrigger> <PopoverBody> <BlockText>Body</BlockText> </PopoverBody></Popover>
TextField as trigger
<Popover> <PopoverTrigger> <TextField /> </PopoverTrigger> <PopoverBody> <BlockText>Body</BlockText> </PopoverBody></Popover>
With PopoverFooter
<Popover> <PopoverTrigger> <Button>Trigger</Button> </PopoverTrigger> <PopoverBody> <Card style={{ width: '250px' }}> <CardBody> <HeadingText>Heading</HeadingText> <BlockText spacingType={[ BlockText.SPACING_TYPE.MEDIUM, BlockText.SPACING_TYPE.NONE, ]} > Item content </BlockText> <BlockText>Item content</BlockText> </CardBody> </Card> <PopoverFooter style={{ textAlign: 'right' }}>Info message</PopoverFooter> </PopoverBody></Popover>
Controlled Popover
class ControlledPopover extends React.Component { constructor() { super(...arguments);
this.state = { opened: false, };
this._onChange = this._onChange.bind(this); }
_onChange(evt, opened) { this.setState({ opened }, () => console.log('controlled state', evt, this.state), ); }
render() { const { opened } = this.state;
return ( <Popover opened={opened} onChange={this._onChange}> <PopoverTrigger> <Button>Trigger</Button> </PopoverTrigger> <PopoverBody> <Card style={{ width: '250px' }}> <CardBody> <HeadingText>Heading</HeadingText> <BlockText spacingType={[ BlockText.SPACING_TYPE.MEDIUM, BlockText.SPACING_TYPE.NONE, ]} > Item content </BlockText> <BlockText>Item content</BlockText> </CardBody> </Card> <PopoverFooter style={{ textAlign: 'right' }}> Info message </PopoverFooter> </PopoverBody> </Popover> ); }}
Props
REQUIREDnode[] | This component accepts children of two types:
|
function | Callback to track when the function ( |
boolean | When true, the popover overlay will open on hover. |
boolean | When provided, |