Skip to content

🐿 A React accordion library as small as an acorn

Notifications You must be signed in to change notification settings

maxrolon/accornion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Accornion

A React accordion library as small as an acorn (~1kb gzipped)

js-standard-style

Usage

The open state of each Accordion is handled outside of the accordion itself (via the 'open' prop). See usage below!

import Accordion from 'accornion'

class App extends React.Component {
  constructor (props) {
    super(props)

    this.state = {
      open: false
    }
  }

  toggle (open) {
    if (open && !this.state.open) {
      this.setState({
        open: true
      })
    } else if (!open && this.state.open) {
      this.setState({
        open: false
      })
    }
  }

  render () {
    return (
      <div>
        <button onClick={e => this.toggle(!this.state.open)}>Accordion Header</button>
        <Accordion 
          open={this.state.open}
          duration=400
          easing='ease-in-out'>
          <ul>
            <li></li>
            <li></li>
            <li></li>
          </ul>
        </Accordion>
      </div>
    )
  }
}

MIT License

About

🐿 A React accordion library as small as an acorn

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published