1- # rc-segmented 🐾
1+ # rc-segmented
22
33[ ![ NPM version] [ npm-image ]] [ npm-url ] [ ![ npm download] [ download-image ]] [ download-url ] [ ![ dumi] ( https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square )] ( https://github.com/umijs/dumi ) [ ![ build status] [ github-actions-image ]] [ github-actions-url ] [ ![ Codecov] [ codecov-image ]] [ codecov-url ] [ ![ Dependencies] [ david-image ]] ( david-url ) [ ![ DevDependencies] [ david-dev-image ]] [ david-dev-url ] [ ![ bundle size] [ bundlephobia-image ]] [ bundlephobia-url ]
44
1717[ bundlephobia-url ] : https://bundlephobia.com/result?p=rc-segmented
1818[ bundlephobia-image ] : https://badgen.net/bundlephobia/minzip/rc-segmented
1919
20- Pretty segmented react component used in [ ant.design ] ( https://ant.design ) and [ antv.vision ] ( https://antv.vision ) .
20+ React Segmented Control .
2121
22- ![ ] ( https://gw.alipayobjects.com/zos/antfincdn/z4ie3X8x6u/1cb23945-ec67-45a3-b521-f8da62e12255.png )
22+ ![ ] ( https://gw.alipayobjects.com/mdn/rms_50855f/afts/img/A*bmGGQpnWs0oAAAAAAAAAAAAAARQnAQ )
2323
2424## Live Demo
2525
@@ -32,65 +32,40 @@ https://react-component.github.io/segmented/
3232## Usage
3333
3434``` js
35- import segmented from ' rc-segmented' ;
35+ import Segmented from ' rc-segmented' ;
3636import ' rc-segmented/assets/index.css' ; // import 'rc-segmented/asssets/index.less';
3737import { render } from ' react-dom' ;
3838
3939render (
40- < segmented
41- columns= {[
42- {
43- icon: (
44- < img src= " https://gw.alipayobjects.com/zos/rmsportal/XuVpGqBFxXplzvLjJBZB.svg" / >
45- ),
46- title: ' 语雀' ,
47- url: ' https://yuque.com' ,
48- description: ' 知识创作与分享工具' ,
49- openExternal: true ,
50- },
51- ]}
52- bottom= " Made with ❤️ by AFX"
40+ < Segmented
41+ options= {[' Antd' , ' Antv' , ' Egg.js' ]}
42+ onChange= {(e ) => handleValueChange (e .target .value )}
5343 / > ,
5444 mountNode,
5545);
5646```
5747
5848## API
5949
60- | Property | Type | Default | Description |
61- | ---------------- | --------------------------------- | -------------- | ------------------------------------------- |
62- | prefixCls | string | rc-segmented | |
63- | className | string | '' | additional class name of segmented |
64- | style | React.CSSProperties | | style properties of segmented |
65- | columns | [ Column] ( #Column ) Array | [ ] | columns data inside segmented |
66- | bottom | ReactNode | | extra bottom area beneath segmented columns |
67- | theme | 'light' \| 'dark' | 'dark' | preset theme of segmented |
68- | backgroundColor | string | '#000 ' | background color of segmented |
69- | columnLayout | 'space-around' or 'space-between' | 'space-around' | justify-content value of columns element |
70- | maxColumnsPerRow | number | - | max count of columns for each row |
71-
72- ### Column
73-
74- | Property | Type | Default | Description |
75- | --------- | -------------------------- | ------- | ---------------------------------- |
76- | icon | ReactNode | | icon that before column title |
77- | title | ReactNode | | title of column |
78- | items | [ Item] ( #Column-Item ) Array | [ ] | items data inside each column |
79- | className | string | '' | additional class name of segmented |
80- | style | React.CSSProperties | | style properties of segmented |
81-
82- ### Column Item
83-
84- | Property | Type | Default | Description |
85- | ------------- | ------------------- | ------- | ------------------------------------------------------- |
86- | icon | ReactNode | | icon that before column title |
87- | title | ReactNode | | title of column |
88- | description | ReactNode | | description of column, come after title |
89- | url | string | | link url of item title |
90- | openExternal | boolean | false | link target would be ` _blank ` if ` openExternal ` is ture |
91- | className | string | '' | additional class name of segmented |
92- | style | React.CSSProperties | | style properties of segmented |
93- | LinkComponent | React.ReactType | 'a' | the link element to render item |
50+ | Property | Type | Default | Description |
51+ | ------------ | -------------------------------------------------------------- | ------------ | ---------------------------------- |
52+ | prefixCls | string | rc-segmented | |
53+ | className | string | '' | additional class name of segmented |
54+ | style | React.CSSProperties | | style properties of segmented |
55+ | options | Array<string \| number \| [ SegmentedOption] ( #SegmentedOption ) > | [ ] | options for choices |
56+ | value | string \| number | | value of segmented |
57+ | defaultValue | string \| number | | defaultValue of segmented |
58+ | onChange | (e: any) => void | | defaultValue of segmented |
59+ | disabled | boolean | false | disabled status of segmented |
60+
61+ ### SegmentedOption
62+
63+ | Property | Type | Default | Description |
64+ | --------- | --------- | ------- | ----------------------------------------- | ------------------------- |
65+ | label | ReactNode | | label of segmented option |
66+ | value | string | number | | value of segmented option |
67+ | className | string | '' | additional class name of segmented option |
68+ | disabled | boolean | false | disabled status of segmented option |
9469
9570## Development
9671
0 commit comments