diff --git a/angular/src/directives/proxies.ts b/angular/src/directives/proxies.ts index 4040c478fb..7b5b83aedd 100644 --- a/angular/src/directives/proxies.ts +++ b/angular/src/directives/proxies.ts @@ -156,8 +156,8 @@ export class IonCheckbox { } export declare interface IonChip extends Components.IonChip { } -@ProxyCmp({ inputs: ["color", "mode", "outline"] }) -@Component({ selector: "ion-chip", changeDetection: ChangeDetectionStrategy.OnPush, template: "", inputs: ["color", "mode", "outline"] }) +@ProxyCmp({ inputs: ["color", "disabled", "mode", "outline"] }) +@Component({ selector: "ion-chip", changeDetection: ChangeDetectionStrategy.OnPush, template: "", inputs: ["color", "disabled", "mode", "outline"] }) export class IonChip { protected el: HTMLElement; constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) { diff --git a/core/api.txt b/core/api.txt index 8c559cd3da..783f3143a3 100644 --- a/core/api.txt +++ b/core/api.txt @@ -248,6 +248,7 @@ ion-checkbox,part,mark ion-chip,shadow ion-chip,prop,color,string | undefined,undefined,false,false +ion-chip,prop,disabled,boolean,false,false,false ion-chip,prop,mode,"ios" | "md",undefined,false,false ion-chip,prop,outline,boolean,false,false,false ion-chip,css-prop,--background diff --git a/core/src/components.d.ts b/core/src/components.d.ts index ec0a9e28a0..d8a3264efb 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -403,6 +403,10 @@ export namespace Components { * The color to use from your application's color palette. Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. For more information on colors, see [theming](/docs/theming/basics). */ "color"?: Color; + /** + * If `true`, the user cannot interact with the chip. + */ + "disabled": boolean; /** * The mode determines which platform styles to use. */ @@ -3726,6 +3730,10 @@ declare namespace LocalJSX { * The color to use from your application's color palette. Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. For more information on colors, see [theming](/docs/theming/basics). */ "color"?: Color; + /** + * If `true`, the user cannot interact with the chip. + */ + "disabled"?: boolean; /** * The mode determines which platform styles to use. */ diff --git a/core/src/components/chip/chip.scss b/core/src/components/chip/chip.scss index 4aa59c6dcd..322c211a96 100644 --- a/core/src/components/chip/chip.scss +++ b/core/src/components/chip/chip.scss @@ -37,6 +37,11 @@ box-sizing: border-box; } +:host(.chip-disabled) { + cursor: default; + opacity: .4; + pointer-events: none; +} // Chip Colors // --------------------------------------------- diff --git a/core/src/components/chip/chip.tsx b/core/src/components/chip/chip.tsx index e1ec3a1dba..c4b46b3a7e 100644 --- a/core/src/components/chip/chip.tsx +++ b/core/src/components/chip/chip.tsx @@ -28,14 +28,21 @@ export class Chip implements ComponentInterface { */ @Prop() outline = false; + /** + * If `true`, the user cannot interact with the chip. + */ + @Prop() disabled = false; + render() { const mode = getIonMode(this); return ( diff --git a/core/src/components/chip/readme.md b/core/src/components/chip/readme.md index e260406a5e..0890658c2f 100644 --- a/core/src/components/chip/readme.md +++ b/core/src/components/chip/readme.md @@ -7,7 +7,7 @@ Chips represent complex entities in small blocks, such as a contact. A chip can ## Usage -### Angular / javascript +### Angular ```html @@ -22,6 +22,60 @@ Chips represent complex entities in small blocks, such as a contact. A chip can Secondary w/ Dark label + + Disabled Chip + + + + + Default + + + + + Default + + + + Button Chip + + + + + + Icon Chip + + + + + + + + Avatar Chip + + +``` + + +### Javascript + +```html + + Default + + + + Secondary Label + + + + Secondary w/ Dark label + + + + Disabled Chip + + Default @@ -81,6 +135,10 @@ export const ChipExamples: React.FC = () => { Secondary w/ Dark label + + Disabled Chip + + Default @@ -191,6 +249,10 @@ export class ChipExample { Secondary w/ Dark label + + Disabled Chip + + Default @@ -240,11 +302,12 @@ export default defineComponent({ ## Properties -| Property | Attribute | Description | Type | Default | -| --------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ----------- | -| `color` | `color` | The color to use from your application's color palette. Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. For more information on colors, see [theming](/docs/theming/basics). | `string \| undefined` | `undefined` | -| `mode` | `mode` | The mode determines which platform styles to use. | `"ios" \| "md"` | `undefined` | -| `outline` | `outline` | Display an outline style button. | `boolean` | `false` | +| Property | Attribute | Description | Type | Default | +| ---------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ----------- | +| `color` | `color` | The color to use from your application's color palette. Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. For more information on colors, see [theming](/docs/theming/basics). | `string \| undefined` | `undefined` | +| `disabled` | `disabled` | If `true`, the user cannot interact with the chip. | `boolean` | `false` | +| `mode` | `mode` | The mode determines which platform styles to use. | `"ios" \| "md"` | `undefined` | +| `outline` | `outline` | Display an outline style button. | `boolean` | `false` | ## CSS Custom Properties diff --git a/core/src/components/chip/test/states/index.html b/core/src/components/chip/test/states/index.html index fedb0f98bf..4c7f015dae 100644 --- a/core/src/components/chip/test/states/index.html +++ b/core/src/components/chip/test/states/index.html @@ -17,6 +17,7 @@

Default

+

Default @@ -195,6 +196,26 @@

+

Disabled

+ +

+ + Disabled + + + Disabled Outline + + + + Disabled Secondary with Icon + + + + Disabled Outline with Icon and Avatar + + +

+

Custom

@@ -246,11 +267,6 @@ padding-left: 8px; } - ion-chip { - display: inline-block !important; - vertical-align: middle; - } - .wide { --background: #d1f3ff; --background-hover: #add8e6; diff --git a/core/src/components/chip/usage/angular.md b/core/src/components/chip/usage/angular.md index 361eda3f72..48f6e11bb3 100644 --- a/core/src/components/chip/usage/angular.md +++ b/core/src/components/chip/usage/angular.md @@ -11,6 +11,10 @@ Secondary w/ Dark label
+ + Disabled Chip + + Default diff --git a/core/src/components/chip/usage/javascript.md b/core/src/components/chip/usage/javascript.md index 361eda3f72..0a0d5ba2c3 100644 --- a/core/src/components/chip/usage/javascript.md +++ b/core/src/components/chip/usage/javascript.md @@ -11,6 +11,10 @@ Secondary w/ Dark label + + Disabled Chip + + Default diff --git a/core/src/components/chip/usage/react.md b/core/src/components/chip/usage/react.md index 17c460df63..9d049bbc72 100644 --- a/core/src/components/chip/usage/react.md +++ b/core/src/components/chip/usage/react.md @@ -24,6 +24,10 @@ export const ChipExamples: React.FC = () => { Secondary w/ Dark label + + Disabled Chip + + Default @@ -57,4 +61,4 @@ export const ChipExamples: React.FC = () => { ); }; -``` \ No newline at end of file +``` diff --git a/core/src/components/chip/usage/vue.md b/core/src/components/chip/usage/vue.md index ed906aa3c4..a6f6f2783d 100644 --- a/core/src/components/chip/usage/vue.md +++ b/core/src/components/chip/usage/vue.md @@ -12,6 +12,10 @@ Secondary w/ Dark label + + Disabled Chip + + Default diff --git a/packages/vue/src/proxies.ts b/packages/vue/src/proxies.ts index 510c79ae0c..21204687e0 100644 --- a/packages/vue/src/proxies.ts +++ b/packages/vue/src/proxies.ts @@ -109,7 +109,8 @@ export const IonCheckbox = /*@__PURE__*/ defineContainer('ion-c export const IonChip = /*@__PURE__*/ defineContainer('ion-chip', [ 'color', - 'outline' + 'outline', + 'disabled' ]);