diff --git a/packages/ui-tabs/src/Tabs/README.md b/packages/ui-tabs/src/Tabs/README.md index 6028457074..0ebce5d8ba 100644 --- a/packages/ui-tabs/src/Tabs/README.md +++ b/packages/ui-tabs/src/Tabs/README.md @@ -256,6 +256,77 @@ class Example extends React.Component { render() ``` +### Support for dynamic content with active panel + +Marking one of the `` as `active` will render that panel's content in all the panels. This is useful for dynamic content rendering: the panel area can be used as a container, what routing libraries, such as React Router, can use to render their children elements into. + +```js +--- +example: true +render: false +--- +class Outlet extends React.Component { + state = { + show: false + } + + componentDidMount() { + setTimeout(() => this.setState({ show: true }), 2000) + } + + render() { + return ( +
+ + {this.state.show ? 'Hello Developer' : 'Simulating network call...'} + + {this.state.show ? lorem.paragraphs() : + } +
+ ) + } + } + + +class Example extends React.Component { + state = { + selectedIndex: 0 + } + handleTabChange = (event, { index, id }) => { + this.setState({ + selectedIndex: index + }) + } + + render() { + const { selectedIndex } = this.state + return ( + + + + + + + + + ) + } +} + +render() +``` + ### Guidelines ```js