1
- # rc-segmented 🐾
1
+ # rc-segmented
2
2
3
3
[ ![ 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 ]
4
4
17
17
[ bundlephobia-url ] : https://bundlephobia.com/result?p=rc-segmented
18
18
[ bundlephobia-image ] : https://badgen.net/bundlephobia/minzip/rc-segmented
19
19
20
- Pretty segmented react component used in [ ant.design ] ( https://ant.design ) and [ antv.vision ] ( https://antv.vision ) .
20
+ React Segmented Control .
21
21
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 )
23
23
24
24
## Live Demo
25
25
@@ -32,65 +32,40 @@ https://react-component.github.io/segmented/
32
32
## Usage
33
33
34
34
``` js
35
- import segmented from ' rc-segmented' ;
35
+ import Segmented from ' rc-segmented' ;
36
36
import ' rc-segmented/assets/index.css' ; // import 'rc-segmented/asssets/index.less';
37
37
import { render } from ' react-dom' ;
38
38
39
39
render (
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 )}
53
43
/ > ,
54
44
mountNode,
55
45
);
56
46
```
57
47
58
48
## API
59
49
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 |
94
69
95
70
## Development
96
71
0 commit comments