react-togglr

1.1.1 • Public • Published

react-togglr

React library for building declarative toggle components

Example

const UserProfileDropdown = ({ avatarUrl, name }) => (
  <Toggle
    render={({ on, toggle }) => (
      <div className="UserProfileDropdown">
        <img className="UserProfileDropdown-avatar" src={avatarUrl} />
        <span className="UserProfileDropdown-name" onClick={toggle}>
          {name}{' '}
          <img
            src={arrow}
            className={`UserProfileDropdown-arrow ${on
              ? 'UserProfileDropdown-arrow--on'
              : ''} `}
          />
        </span>
        {on ? <Menu /> : null}
      </div>
    )}
    onToggle={({ on }) => console.log(`${on ? 'ON' : 'OFF'}`)}
  />
);

Built With

Authors

  • Vicent Gozalbes - Initial work - vigosan

License

This project is licensed under the MIT License - see the LICENSE.md file for details

/react-togglr/

    Package Sidebar

    Install

    npm i react-togglr

    Weekly Downloads

    329

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    43.3 kB

    Total Files

    7

    Last publish

    Collaborators

    • vigosan
    • manel.romero
    • jacarui
    • borcha91
    • cabargues
    • botijo.it
    • flywire.tech
    • luisbelloch
    • chip2910
    • alberto.ramirez
    • imsolar
    • jramosba
    • sandra.gomez
    • eduardo.simon