src/components/sq-tabs/sq-tab/sq-tab.component.ts
Represents a tab component for displaying tabbed content.
Look the link about the component in original framework and the appearance
See https://css.squidit.com.br/components/tabs
Example :<sq-tab [title]="'Tab Title'" (whenOpen)="handleTabOpen()">
<!-- Content Here -->
</sq-tab>| changeDetection | ChangeDetectionStrategy.OnPush |
| selector | sq-tab |
| standalone | true |
| styleUrls | ./sq-tab.component.scss |
| templateUrl | ./sq-tab.component.html |
Properties |
Inputs |
Outputs |
Accessors |
constructor(cdr: ChangeDetectorRef)
|
||||||||
|
Creates an instance of SqTabComponent.
Parameters :
|
| active | |
Type : boolean
|
|
|
Sets or gets the active state of the tab.
If set to |
|
| borderColor | |
Type : string
|
|
Default value : 'transparent'
|
|
|
The border color of the tab. |
|
| color | |
Type : string
|
|
Default value : 'white'
|
|
|
The background color of the tab. |
|
| disabled | |
Type : boolean
|
|
|
Flag to indicate if the tab is disabled. |
|
| hideHtml | |
Type : boolean
|
|
|
Sets or gets whether the tab HTML should be hidden. Triggers change detection when updated. |
|
| loading | |
Type : boolean
|
|
|
Flag to indicate if the tab is in a loading state. |
|
| tabName | |
Type : string
|
|
Default value : ''
|
|
|
The name or identifier of the tab. |
|
| textColor | |
Type : string
|
|
Default value : 'black'
|
|
|
The text color of the tab title. |
|
| title | |
Type : string
|
|
Default value : ''
|
|
|
The title displayed on the tab. |
|
| whenOpen | |
Type : EventEmitter<void>
|
|
|
Event emitted when the tab is opened. |
|
| Private _active |
Default value : false
|
|
Internal property to track the active state of the tab. |
| Private _hideHtml |
Default value : false
|
|
Internal property to track if the tab HTML should be hidden. |
| active | ||||||
getactive()
|
||||||
setactive(value: boolean)
|
||||||
|
Sets or gets the active state of the tab.
If set to
Parameters :
Returns :
void
|
| hideHtml | ||||||
gethideHtml()
|
||||||
sethideHtml(value: boolean)
|
||||||
|
Sets or gets whether the tab HTML should be hidden. Triggers change detection when updated.
Parameters :
Returns :
void
|
import { ChangeDetectorRef } from '@angular/core';
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
/**
* Represents a tab component for displaying tabbed content.
*
* Look the link about the component in original framework and the appearance
*
* @see {@link https://css.squidit.com.br/components/tabs}
*
* @example
* <sq-tab [title]="'Tab Title'" (whenOpen)="handleTabOpen()">
* <!-- Content Here -->
* </sq-tab>
*/
@Component({
selector: 'sq-tab',
templateUrl: './sq-tab.component.html',
styleUrls: ['./sq-tab.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
})
export class SqTabComponent {
/**
* Internal property to track the active state of the tab.
*/
private _active = false;
/**
* Sets or gets the active state of the tab.
* If set to `true`, triggers change detection.
*/
@Input() set active(value: boolean) {
this._active = value;
if (value) {
this.cdr.markForCheck();
}
}
get active(): boolean {
return this._active;
}
/**
* The title displayed on the tab.
*/
@Input() title = '';
/**
* The text color of the tab title.
*/
@Input() textColor = 'black';
/**
* The background color of the tab.
*/
@Input() color = 'white';
/**
* The border color of the tab.
*/
@Input() borderColor = 'transparent';
/**
* Flag to indicate if the tab is disabled.
*/
@Input() disabled?: boolean;
/**
* Flag to indicate if the tab is in a loading state.
*/
@Input() loading?: boolean;
/**
* The name or identifier of the tab.
*/
@Input() tabName = '';
/**
* Internal property to track if the tab HTML should be hidden.
*/
private _hideHtml = false;
/**
* Sets or gets whether the tab HTML should be hidden.
* Triggers change detection when updated.
*/
@Input() set hideHtml(value: boolean) {
this._hideHtml = value;
this.cdr.markForCheck();
}
get hideHtml(): boolean {
return this._hideHtml;
}
/**
* Event emitted when the tab is opened.
*/
@Output() whenOpen: EventEmitter<void> = new EventEmitter();
/**
* Creates an instance of SqTabComponent.
* @param cdr - Angular's ChangeDetectorRef for manual change detection control.
*/
constructor(private cdr: ChangeDetectorRef) {}
}
@if (!hideHtml) {
<div [hidden]="!active" class="pane">
<ng-content></ng-content>
</div>
}
./sq-tab.component.scss
:host {
.pane {
padding: 0;
}
}