diff --git a/core/api.txt b/core/api.txt index 48aab763be..439a457556 100644 --- a/core/api.txt +++ b/core/api.txt @@ -2065,6 +2065,7 @@ ion-select,prop,okText,string,'OK',false,false ion-select,prop,placeholder,string | undefined,undefined,false,false ion-select,prop,selectedText,null | string | undefined,undefined,false,false ion-select,prop,shape,"rectangular" | "round" | "soft" | undefined,undefined,false,false +ion-select,prop,size,"large" | "medium" | "small" | undefined,undefined,false,false ion-select,prop,theme,"ios" | "md" | "ionic",undefined,false,false ion-select,prop,toggleIcon,string | undefined,undefined,false,false ion-select,prop,value,any,undefined,false,false diff --git a/core/src/components.d.ts b/core/src/components.d.ts index 63eab17e53..4a7bf06f0e 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -3283,6 +3283,10 @@ export namespace Components { * Set to `"soft"` for a select with slightly rounded corners, `"round"` for a select with fully rounded corners, or `"rectangular"` for a select without rounded corners. Defaults to `"round"` for the `"ionic"` theme, undefined for all other themes. */ "shape"?: 'soft' | 'round' | 'rectangular'; + /** + * The size of the select. If "large" it will increase the height of the select, while "small" and "medium" provide progressively smaller heights. Defaults to `"medium"` for the ionic theme, and undefined for all other themes. + */ + "size"?: 'small' | 'medium' | 'large'; /** * The theme determines the visual appearance of the component. */ @@ -8707,6 +8711,10 @@ declare namespace LocalJSX { * Set to `"soft"` for a select with slightly rounded corners, `"round"` for a select with fully rounded corners, or `"rectangular"` for a select without rounded corners. Defaults to `"round"` for the `"ionic"` theme, undefined for all other themes. */ "shape"?: 'soft' | 'round' | 'rectangular'; + /** + * The size of the select. If "large" it will increase the height of the select, while "small" and "medium" provide progressively smaller heights. Defaults to `"medium"` for the ionic theme, and undefined for all other themes. + */ + "size"?: 'small' | 'medium' | 'large'; /** * The theme determines the visual appearance of the component. */ diff --git a/core/src/components/select/select.ionic.scss b/core/src/components/select/select.ionic.scss index e366075055..f134779d58 100644 --- a/core/src/components/select/select.ionic.scss +++ b/core/src/components/select/select.ionic.scss @@ -84,8 +84,6 @@ position: relative; - height: globals.$ion-scale-1200; - background: var(--background); box-sizing: border-box; @@ -197,3 +195,18 @@ :host(.select-shape-rectangular) { --border-radius: #{globals.$ion-border-radius-0}; } + +// Sizes +// ---------------------------------------------------------------- + +:host(.select-size-small) .select-wrapper-inner { + height: globals.$ion-scale-1000; +} + +:host(.select-size-medium) .select-wrapper-inner { + height: globals.$ion-scale-1200; +} + +:host(.select-size-large) .select-wrapper-inner { + height: globals.$ion-scale-1400; +} diff --git a/core/src/components/select/select.tsx b/core/src/components/select/select.tsx index 209f65f70a..302d764c0f 100644 --- a/core/src/components/select/select.tsx +++ b/core/src/components/select/select.tsx @@ -204,6 +204,14 @@ export class Select implements ComponentInterface { */ @Prop({ mutable: true }) value?: any | null; + /** + * The size of the select. If "large" it will increase the height of the select, while + * "small" and "medium" provide progressively smaller heights. + * + * Defaults to `"medium"` for the ionic theme, and undefined for all other themes. + */ + @Prop() size?: 'small' | 'medium' | 'large'; + /** * Emitted when the value has changed. * @@ -820,6 +828,22 @@ export class Select implements ComponentInterface { this.ionBlur.emit(); }; + private getSize(): string | undefined { + const theme = getIonTheme(this); + const { size } = this; + + // TODO(ROU-11370): Remove theme check when sizes are defined for all themes. + if (theme !== 'ionic') { + return undefined; + } + + if (size === undefined) { + return 'medium'; + } + + return size; + } + private renderLabel() { const { label } = this; @@ -1071,6 +1095,7 @@ export class Select implements ComponentInterface { const justifyEnabled = !hasFloatingOrStackedLabel && justify !== undefined; const rtl = isRTL(el) ? 'rtl' : 'ltr'; const inItem = hostContext('ion-item', this.el); + const size = this.getSize(); const shouldRenderHighlight = theme === 'md' && fill !== 'outline' && !inItem; const hasValue = this.hasValue(); @@ -1117,6 +1142,7 @@ export class Select implements ComponentInterface { [`select-justify-${justify}`]: justifyEnabled, [`select-shape-${shape}`]: shape !== undefined, [`select-label-placement-${labelPlacement}`]: true, + [`select-size-${size}`]: size !== undefined, })} >