项目作者: afeiship

项目描述 :
Collapse for react.
高级语言: JavaScript
项目地址: git://github.com/afeiship/react-collapse.git
创建时间: 2020-09-10T02:14:03Z
项目社区:https://github.com/afeiship/react-collapse

开源协议:MIT License

下载


react-collapse

Collapse for react.

@jswork/react-collapse"">version
license
size
@jswork/react-collapse"">download

installation

  1. npm install -S @jswork/react-collapse

usage

  1. import css

    1. @import "~@jswork/react-collapse/dist/style.css";
    2. // or use sass
    3. @import "~@jswork/react-collapse/dist/style.scss";
  2. import js

    1. import ReactCollapse from '@jswork/react-collapse';
    2. import './index.css';
    3. import '@jswork/react-collapse/dist/style.scss';
    4. import { useEffect, useState } from 'react';
    5. function App() {
    6. const [val, setVal] = useState(false);
    7. useEffect(() => {
    8. setTimeout(() => {
    9. setVal(true);
    10. }, 3000);
    11. }, []);
    12. return (
    13. <div className="m-10 p-4 shadow bg-gray-100 text-gray-800 hover:shadow-md transition-all">
    14. <div className="badge badge-warning absolute right-0 top-0 m-4">
    15. Build Time: {BUILD_TIME}
    16. </div>
    17. <h1>react-collapse</h1>
    18. <div className="y-2">
    19. <button className="btn btn-primary btn-sm w-full" onClick={() => setVal(!val)}>Toggle - {String(val)}</button>
    20. <div className="y-3">
    21. <ReactCollapse
    22. value={val}
    23. onChange={e => console.log('value: ', e)}
    24. >
    25. <div className="p-5 rounded-md rounded-t-none bg-green-100">
    26. <img width="200" src="https://pic.rmb.bdstatic.com/7f7a8d7b247d3aa430010f10a5765239.jpeg"
    27. alt="placeholder" />
    28. </div>
    29. </ReactCollapse>
    30. </div>
    31. </div>
    32. </div>
    33. );
    34. }
    35. export default App;

preview

license

Code released under the MIT license.