Skip to content

Commit e8dea7a

Browse files
feat(module:segmented): now supports segmented with icon only (#8368)
* feat(module:segmented): now supports segmented with icon only * feat(module:segmented): now supports segmented with icon only
1 parent 18b898e commit e8dea7a

3 files changed

Lines changed: 39 additions & 3 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
order: 11
3+
title:
4+
zh-CN: 只设置图标
5+
en-US: With Icon only
6+
---
7+
8+
## zh-CN
9+
10+
在 Segmented Item 选项中只设置 Icon。
11+
12+
## en-US
13+
14+
Set `icon` without `label` for Segmented Item.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Component } from '@angular/core';
2+
3+
import { NzSegmentedOptions } from 'ng-zorro-antd/segmented';
4+
5+
@Component({
6+
selector: 'nz-demo-segmented-with-icon-only',
7+
template: `<nz-segmented [nzOptions]="options"></nz-segmented>`
8+
})
9+
export class NzDemoSegmentedWithIconOnlyComponent {
10+
options: NzSegmentedOptions = [
11+
{ value: 'List', icon: 'bars' },
12+
{ value: 'Kanban', icon: 'appstore' }
13+
];
14+
}

‎components/segmented/types.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@
33
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
44
*/
55

6-
export interface NzSegmentedOption {
7-
label: string;
6+
export type NzSegmentedOption = {
87
value: string | number;
98
useTemplate?: boolean;
10-
icon?: string;
119
disabled?: boolean;
1210
className?: string;
11+
} & (NzSegmentedWithLabel | NzSegmentedWithIcon);
12+
13+
export interface NzSegmentedWithLabel {
14+
label: string;
15+
icon?: string;
16+
}
17+
18+
export interface NzSegmentedWithIcon {
19+
icon: string;
20+
label?: string;
1321
}
1422

1523
export type NzSegmentedOptions = Array<NzSegmentedOption | string | number>;

0 commit comments

Comments
 (0)