# Coveo Tab Component (CoveoTab)

The Tab component renders a widget that allows the end user to select a specific search interface.

This component attaches itself to a `div` element. It is in charge of adding an advanced expression to the outgoing query in order to refine the results.

The Tab component can also hide and show different parts of the UI. For each individual component in the UI, you can specify whether you wish to include or exclude that component when the user selects a certain Tab (see Using Components Only on Specific Tabs).

Setting a New Endpoint for a Tab:

A Tab can use a custom endpoint when performing a query. Of course, you need to make sure that the endpoint exists in the array of Coveo.SearchEndpoint.endpoints (see SearchEndpoint.endpoints).

    Coveo.SearchEndpoint.endpoints["specialEndpoint"] = new Coveo.SearchEndpoint({
        restUri : 'https://somewhere.com/rest/search'
    })

    [ ... ]

    <div class='CoveoTab' data-endpoint='specialEndpoint'></div>

## Index

### Methods

- debugInfo
- disable
- enable
- getBindings
- isElementIncludedInTab
- select
- get

### Properties

- bind
- componentOptionsModel
- componentStateModel
- disabled
- logger
- queryController
- queryStateModel
- root
- searchInterface
- ID

### Accessors

- usageAnalytics

### Component Options

- caption
- constant
- dropdownHeaderLabel
- enableDuplicateFiltering
- enableResponsiveMode
- endpoint
- expression
- icon
- id
- layout
- maximumAge
- pipeline
- sort

### Constructors

- constructor

## Methods

### debugInfo

- debugInfo(): any

- Inherited from BaseComponent.debugInfo

  - Defined in ui/Base/BaseComponent.ts :41

  Return the debug info about this component.

  #### Returns any

### disable

- disable(): void

- Inherited from BaseComponent.disable

  - Defined in ui/Base/BaseComponent.ts :52

  Disable the component. Normally this means that the component will not execute handlers for the framework events (query events, for example). Components are enabled by default on creation.

  #### Returns void

### enable

- enable(): void

- Inherited from BaseComponent.enable

  - Defined in ui/Base/BaseComponent.ts :61

  Enable the component. Normally this means that the component will execute handlers for the framework events (query events, for example). Components are enabled by default on creation.

  #### Returns void

### getBindings

- getBindings(): IComponentBindings

- Inherited from Component.getBindings

  - Defined in ui/Base/Component.ts :328

  Return the bindings, or environment, for the current component.

  #### Returns IComponentBindings

### isElementIncludedInTab

- isElementIncludedInTab(element: HTMLElement): boolean

- - Defined in ui/Tab/Tab.ts :283

  Indicates whether the HTMLElement argument is included in the Tab. Included elements are shown when the Tab is selected, whereas excluded elements are not.

  #### Parameters

  - ##### element: HTMLElement

    The HTMLElement to verify.

  #### Returns boolean

  `true` if the HTMLElement is included in the Tab; `false` if it is excluded.

### select

- select(): void

- - Defined in ui/Tab/Tab.ts :257

  Selects the current Tab.

  Also logs the `interfaceChange` event in the usage analytics with the new current Tab.options.id as metada and triggers a new query.

  #### Returns void

### Static get

- get(element: HTMLElement, componentClass?: any, noThrow?: boolean): BaseComponent

- Inherited from Component.get

  - Defined in ui/Base/Component.ts :410

  Get the bound component to the given HTMLElement. Throws an assert if the HTMLElement has no component bound, unless using the noThrow argument.
  If there is multiple component bound to the current HTMLElement, you must specify the component class.

  #### Parameters

  - ##### element: HTMLElement

    HTMLElement for which to get the bound component.

  - ##### Optional componentClass: any

    Optional component class. If the HTMLElement has multiple components bound, you must specify which one you are targeting.

  - ##### Optional noThrow: boolean

    Boolean option to tell the method to not throw on error.

  #### Returns BaseComponent

## Properties

### bind

bind: ComponentEvents

Inherited from Component.bind

- Defined in ui/Base/Component.ts :270

Allows the component to bind events and execute them only when it is enabled.

type

  {Coveo.ComponentEvents}

### componentOptionsModel

componentOptionsModel: ComponentOptionsModel

Inherited from Component.componentOptionsModel

- Defined in ui/Base/Component.ts :294

Contains the state of options for different components. Mainly used by ResultLink.

### componentStateModel

componentStateModel: ComponentStateModel

Inherited from Component.componentStateModel

- Defined in ui/Base/Component.ts :282

Contains the state of different components (enabled vs disabled). Allows to get/set values. Triggers component state event when modified. Each component can listen to those events.

### disabled

disabled: boolean

Inherited from BaseComponent.disabled

- Defined in ui/Base/BaseComponent.ts :23

A disabled component will not participate in the query, or listen to ComponentEvents.

type

  {boolean}

### logger

logger: Logger

Inherited from BaseComponent.logger

- Defined in ui/Base/BaseComponent.ts :18

Allows component to log in the dev console.

### queryController

queryController: QueryController

Inherited from Component.queryController

- Defined in ui/Base/Component.ts :286

Contains the singleton that allows to trigger queries.

### queryStateModel

queryStateModel: QueryStateModel

Inherited from Component.queryStateModel

- Defined in ui/Base/Component.ts :278

Contains the state of the query. Allows to get/set values. Trigger query state event when modified. Each component can listen to those events.

### root

root: HTMLElement

Inherited from Component.root

- Defined in ui/Base/Component.ts :274

A reference to the root HTMLElement (the SearchInterface).

### searchInterface

searchInterface: SearchInterface

Inherited from Component.searchInterface

- Defined in ui/Base/Component.ts :290

A reference to the root of every component, the SearchInterface.

### Static ID

ID: string

Inherited from BaseComponent.ID

- Defined in ui/Base/BaseComponent.ts :28

The static ID that each component needs in order to be identified.
For example, SearchButton -> static ID: SearchButton -> className: CoveoSearchButton

## Accessors

### usageAnalytics

- get (): IAnalyticsClient

- Inherited from Component.usageAnalytics

  - Defined in ui/Base/Component.ts :343

  A reference to the Analytics.client.

  #### Returns IAnalyticsClient

## Component Options

### caption

caption: string

- Defined in ui/Tab/Tab.ts :90

Specifies the caption of the Tab.

Specifying a value for this option is necessary for this component to work.

Required

  Specifying a value for this option is required for the component to work

Markup configuration example(s) :

    data-caption='foo'

### constant

constant: boolean

- Defined in ui/Tab/Tab.ts :152

Specifies whether to include the Tab.options.expression in the constant part of the query.

The index specially optimizes the constant part of the query to execute faster. However, you must be careful not to include dynamic query expressions, otherwise the cache will lose its efficiency.

Default value is `true`.

Default

  `true`

Markup configuration example(s) :

    data-constant='true'
    data-constant='false'

### dropdownHeaderLabel

dropdownHeaderLabel: string

- Defined in ui/Tab/Tab.ts :219

Specifies the label of the button that allows to show the hidden tabs when in responsive mode.

If more than one Tab in the search interface specifies a value for this option, then the framework uses the first occurrence of the option.

The default value is `"More"`.

Markup configuration example(s) :

    data-dropdown-header-label='foo'

### enableDuplicateFiltering

enableDuplicateFiltering: boolean

- Defined in ui/Tab/Tab.ts :163

Whether to filter out duplicates, so that items resembling one another only appear once in the query results.

Notes:

- Two items must be at least 85% similar to one another to be considered duplicates.
- When a pair of duplicates is found, only the higher-ranked item of the two is kept in the result set.
- Enabling this feature can make the total result count less precise, as only the requested page of query results is submitted to duplicate filtering.
- The default value for this option can be modified through the SearchInterface component.

Default

  `false`

Markup configuration example(s) :

    data-enable-duplicate-filtering='true'
    data-enable-duplicate-filtering='false'

### enableResponsiveMode

enableResponsiveMode: boolean

- Defined in ui/Tab/Tab.ts :209

Specifies whether to enable responsive mode for tabs. Responsive mode makes overflowing tabs disappear, instead making them available using a dropdown button. Responsive tabs are enabled either when tabs overflow or when the width of the search interface becomes too small.

Disabling responsive mode for one Tab also disables it for all tabs. Therefore, you only need to set this option to `false` on one Tab to disable responsive mode.

Default value is `true`.

Default

  `true`

Available since

  October 2016 Release (v1.1550.5)

Markup configuration example(s) :

    data-enable-responsive-mode='true'
    data-enable-responsive-mode='false'

### endpoint

endpoint: SearchEndpoint

- Defined in ui/Tab/Tab.ts :115

Specifies the SearchEndpoint to point to when performing queries from within the Tab.

By default, the Tab uses the "default" endpoint.

### expression

expression: string

- Defined in ui/Tab/Tab.ts :108

Specifies an advanced expression or filter that the Tab should add to any outgoing query.

Example:

`@objecttype==Message`

Default value is `undefined` and the Tab applies no additional expression or filter to the query.

Markup configuration example(s) :

    data-expression='foo'

### icon

icon: string

- Defined in ui/Tab/Tab.ts :97

Specifies an icon to use for the Tab.

deprecated

  This options is mostly kept for legacy reasons. If possible, you should avoid using it.

Markup configuration example(s) :

    data-icon='foo'

### id

id: string

- Defined in ui/Tab/Tab.ts :83

Specifies a unique ID for the Tab.

Specifying a value for this option is necessary for this component to work.

Required

  Specifying a value for this option is required for the component to work

Markup configuration example(s) :

    data-id='foo'

### layout

layout: "list" | "card" | "table"

- Defined in ui/Tab/Tab.ts :142

Specifies the default layout to display when the user selects the Tab (see ResultList.options.layout and {@link ResultLayout}).

See the ValidLayout type for the list of possible values.

If not specified, it will default to 'list'.

See also Result Layouts.

Default value is `undefined` and the component selects the first available layout.

### maximumAge

maximumAge: number

- Defined in ui/Tab/Tab.ts :195

Specifies the maximum age (in milliseconds) that cached query results can have to still be usable as results instead of performing a new query on the index from within the Tab. The cache is located in the Coveo Search API (which resides between the index and the search interface).

If cached results that are older than the age you specify in this option are available, a new query will be performed on the index anyhow.

On high-volume public web sites, specifying a higher value for this option can greatly improve query response time at the cost of result freshness.

Note:

> It is also possible to set a maximum cache age for the entire SearchInterface rather than for a single Tab (see SearchInterface.options.maximumAge).

Default value is `undefined` and the Coveo Search API determines the maximum cache age. This is typically equivalent to 30 minutes (see maximumAge).

Markup configuration example(s) :

    data-maximum-age='10'

### pipeline

pipeline: string

- Defined in ui/Tab/Tab.ts :174

Specifies the name of the query pipeline to use for the queries when the Tab is selected.

You can specify a value for this option if your index is in a Coveo Cloud organization in which pipelines have been created (see Adding and Managing Query Pipelines).

Default value is `undefined`, which means that pipeline selection conditions defined in the Coveo Cloud organization apply.

Markup configuration example(s) :

    data-pipeline='foo'

### sort

sort: string

- Defined in ui/Tab/Tab.ts :128

Specifies the default sort criteria to use when selecting the Tab. A Sort component with the same parameter needs to be present in the search interface in order for this option to function properly.

Examples:

- `data-sort='relevancy'`
- `data-sort='date descending'`

Default value is `undefined` and the normal Sort component behavior applies.

Markup configuration example(s) :

    data-sort='foo'

## Constructors

### constructor

- new Tab(element: HTMLElement, options?: ITabOptions, bindings?: IComponentBindings): Tab

- Overwrites Component.constructor

  - Defined in ui/Tab/Tab.ts :220

  Creates a new Tab. Binds on buildingQuery event as well as an event on click of the element.

  #### Parameters

  - ##### element: HTMLElement

    The HTMLElement on which to instantiate the component. Normally a `div`.

  - ##### Optional options: ITabOptions

    The options for the Tab component.

  - ##### Optional bindings: IComponentBindings

    The bindings that the component requires to function normally. If not set, these will be automatically resolved (with a slower execution time).

  #### Returns Tab