Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2181,6 +2181,7 @@ ion-tab-bar,prop,mode,"ios" | "md",undefined,false,false
ion-tab-bar,prop,selectedTab,string | undefined,undefined,false,false
ion-tab-bar,prop,theme,"ios" | "md" | "ionic",undefined,false,false
ion-tab-bar,prop,translucent,boolean,false,false,false
ion-tab-bar,prop,width,"auto" | undefined,undefined,false,false
ion-tab-bar,css-prop,--background,ionic
ion-tab-bar,css-prop,--background,ios
ion-tab-bar,css-prop,--background,md
Expand Down
8 changes: 8 additions & 0 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3427,6 +3427,10 @@ export namespace Components {
* If `true`, the tab bar will be translucent. Only applies when the theme is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
"translucent": boolean;
/**
* The width of the tab bar. Defaults to full width. `auto` will display a size based on the items inside the tab bar. Only available for `"ionic"` theme.
*/
"width"?: 'auto';
}
interface IonTabButton {
/**
Expand Down Expand Up @@ -8783,6 +8787,10 @@ declare namespace LocalJSX {
* If `true`, the tab bar will be translucent. Only applies when the theme is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
"translucent"?: boolean;
/**
* The width of the tab bar. Defaults to full width. `auto` will display a size based on the items inside the tab bar. Only available for `"ionic"` theme.
*/
"width"?: 'auto';
}
interface IonTabButton {
/**
Expand Down
2 changes: 2 additions & 0 deletions core/src/components/tab-bar/tab-bar.common.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use "../../themes/mixins" as mixins;

:host {
/**
* @prop --background: Background of the tab bar
Expand Down
29 changes: 29 additions & 0 deletions core/src/components/tab-bar/tab-bar.ionic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,32 @@
// TODO(ROU-10853): replace this value with a layer token
z-index: 10;
}

:host([slot="fixed"]) {
@include globals.margin(null, auto);

bottom: 16px;

width: fit-content;
height: fit-content;

box-shadow: #{globals.$ionic-elevation-200};
}

:host(.tab-bar-width-auto) {
position: absolute;

align-self: center;

width: fit-content;

contain: content;
}

:host([slot="top"].tab-bar-width-auto) {
top: 16px;
}

:host([slot="bottom"].tab-bar-width-auto) {
bottom: 16px;
}
11 changes: 10 additions & 1 deletion core/src/components/tab-bar/tab-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ export class TabBar implements ComponentInterface {
*/
@Prop({ reflect: true }) color?: Color;

/**
* The width of the tab bar. Defaults to full width.
* `auto` will display a size based on the items inside the tab bar.
* Only available for `"ionic"` theme.
*/
@Prop() width?: 'auto';

/**
* The selected tab component
*/
Expand Down Expand Up @@ -97,9 +104,10 @@ export class TabBar implements ComponentInterface {
}

render() {
const { color, translucent, keyboardVisible } = this;
const { color, translucent, keyboardVisible, width } = this;
const theme = getIonTheme(this);
const shouldHide = keyboardVisible && this.el.getAttribute('slot') !== 'top';
console.log('width', width);

return (
<Host
Expand All @@ -109,6 +117,7 @@ export class TabBar implements ComponentInterface {
[theme]: true,
'tab-bar-translucent': translucent,
'tab-bar-hidden': shouldHide,
[`tab-bar-width-${width}`]: width !== undefined,
})}
>
<slot></slot>
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/src/directives/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2178,14 +2178,14 @@ export declare interface IonTab extends Components.IonTab {}


@ProxyCmp({
inputs: ['color', 'mode', 'selectedTab', 'theme', 'translucent']
inputs: ['color', 'mode', 'selectedTab', 'theme', 'translucent', 'width']
})
@Component({
selector: 'ion-tab-bar',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['color', 'mode', 'selectedTab', 'theme', 'translucent'],
inputs: ['color', 'mode', 'selectedTab', 'theme', 'translucent', 'width'],
})
export class IonTabBar {
protected el: HTMLElement;
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/standalone/src/directives/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1972,14 +1972,14 @@ export declare interface IonTab extends Components.IonTab {}

@ProxyCmp({
defineCustomElementFn: defineIonTabBar,
inputs: ['color', 'mode', 'selectedTab', 'theme', 'translucent']
inputs: ['color', 'mode', 'selectedTab', 'theme', 'translucent', 'width']
})
@Component({
selector: 'ion-tab-bar',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['color', 'mode', 'selectedTab', 'theme', 'translucent'],
inputs: ['color', 'mode', 'selectedTab', 'theme', 'translucent', 'width'],
standalone: true
})
export class IonTabBar {
Expand Down
Loading