1.0.3 ⢠Published 2 years ago
@jswork/react-ant-status-switch v1.0.3
react-ant-status-switch
React status swicher component based on antd.
installation
yarn add @jswork/react-ant-status-switch
usage
import js
import React, { useState } from 'react'; import ReactAntStatusSwitch from '@/main'; import styled from 'styled-components'; import { Button } from 'antd'; const Container = styled.div` width: 80%; margin: 100px auto 0; p { margin-top: 10px; } `; const items = [ { value: 'default', label: 'é»č®¤ š¤”' }, { value: 'success', label: 'ęå š' }, { value: 'warning', label: 'č¦å š„ø' }, { value: 'error', label: '失蓄 š¤' }, { value: 'customize', color: '#080', label: 'čŖå®ä¹ē¶ę š¤©' } ]; export default () => { const [val, setVal] = useState('success'); return ( <Container> <p>轻轻ēē§»åęļ¼ęä¼ę¹åē¶ę껓.</p> <ReactAntStatusSwitch value={val} items={items} layout={'flat'} popoverOpts={{ placement: 'top' }} onChange={(e) => { console.log('e.', e.target.value); setVal(e.target.value); }} /> <ReactAntStatusSwitch value={val} items={items} layout={'popover'} popoverOpts={{ placement: 'top' }} onChange={(e) => { console.log('e.', e.target.value); setVal(e.target.value); }} /> <p> Current status: <strong>{val}</strong> </p> <p>Only tag status</p> <ReactAntStatusSwitch value={val} items={items} layout={'tag'} /> <p> <Button type="primary" onClick={() => setVal('success')}> Force to Set status </Button> </p> </Container> ); };
preview
license
Code released under the MIT license.