Coder Social home page Coder Social logo

Tabs about reactstrap HOT 3 CLOSED

reactstrap avatar reactstrap commented on May 9, 2024
Tabs

from reactstrap.

Comments (3)

eddywashere avatar eddywashere commented on May 9, 2024 2

Currently I've been getting by without tab specific components by using Nav and determining active content via route or other method.

<div>
  <Nav tabs>
    <NavItem>
      <NavLink href="/1">Link</NavLink>
    </NavItem>
    <NavItem>
      <NavLink href="/2">Another Link</NavLink>
    </NavItem>
  </Nav>
 {this.props.children || activeContent}
</div>

Eventually I'd see a more controlled example with Tab helpers: TabContent and TabPane. A toggle method would update state to reflect active tab. TabContent would pass that through to TabPane. Here's a rough example:

class Example extends React.Component {
  constructor(props) {
    super(props);

    this.toggle = this.toggle.bind(this);
    this.state = {
      activeTab: '1'
    };
  }

  toggle(tab) {
    if (this.state.activeTab !== tab) {
      this.setState({
        activeTab: tab
      });
    }
  }

  render() {
    return (
      <div>
        <Nav tabs>
          <NavItem>
            <NavLink onClick={() => {this.toggle('1')}}>Link</NavLink>
          </NavItem>
          <NavItem>
            <NavLink onClick={() => {this.toggle('2')}}>Another Link</NavLink>
          </NavItem>
        </Nav>
        <TabContent activeTab={this.state.activeTab}>
          <TabPane name="1">
            <p>tab content</p>
          </TabPane>
          <TabPane name="2">
            <p>tab content</p>
          </TabPane>
        </TabContent>
      </div>
    );
  }
}

from reactstrap.

ajainarayanan avatar ajainarayanan commented on May 9, 2024

@eddywashere Is there a semantic example you are following in implementing this component? Can you give an example to show how this component will eventually be used?

from reactstrap.

eddywashere avatar eddywashere commented on May 9, 2024

Shipped in 3.1.0

from reactstrap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.