### Example Template
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/addon-doc/components/example/example.template.html
The template for the example component, demonstrating conditional rendering and loops.
```HTML
@if (heading()) {
### {{ heading() }}
@if (description()) {
{{ text }}
} }
@if (processor() | tuiDocExampleGetTabs: defaultTab(); as all) { @let tabs = preview() ? all : all.slice(1); @if (tabs.length) {
@for (tab of tabs; track tab) { {{ text }} } @if (processor() | tuiMapper: visible) { @if (codeEditor?.content; as content) { {{ editContent }} } @else { Edit on {{ codeEditor?.name }} } } @if (fullscreenEnabled && preview()) { Fullscreen }
} @for (tab of tabs; track tab) {
@if (!$index && preview()) {
}
@let code = processor()[tab] || '';
@for (action of codeActions; track action) { {{ text }} }
} @empty {
}
```
--------------------------------
### Input Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/navigation/examples/3/index.html
Illustrates a project creation input section.
```html
@if (current === 'input') {Projects
Create
-------------------- }
```
--------------------------------
### Installation
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/addon-doc/README.md
Install the necessary Taiga UI packages for your project, including the core libraries and the addon for documentation.
```APIDOC
## Installation
Install main packages:
```bash
npm i @taiga-ui/cdk @taiga-ui/core @taiga-ui/kit
```
Install doc:
```bash
npm i @taiga-ui/addon-doc
```
```
--------------------------------
### Install Taiga UI Packages
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/addon-doc/README.md
Installs the core Taiga UI packages and the addon-doc package required for documentation.
```bash
npm i @taiga-ui/{cdk,core,kit}
npm i @taiga-ui/addon-doc
```
--------------------------------
### Card Medium Loop Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/card-medium/index.html
Demonstrates iterating over examples to render cards. Ensure to multiply by `--tui-font-scale` for mobile font scaling if customizing size.
```html
@for (example of examples; track example) { }
```
--------------------------------
### Basic Input Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/navigation/examples/3/index.html
Shows a basic input scenario with a research and development platform description.
```html
@if (current === 'basic') {
Research and Development Platform
Here you can initiate and participate in the review of package objects. Each object have up to 3 groups of reviewers, with one response required from each type, and any other participant can change both positive.
Alex Inkin Edited 6 minutes ago Private
Button Button More
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
}
```
--------------------------------
### Basic Pin Usage
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/pin/index.html
Demonstrates the basic structure of a Pin component within a loop. This example shows how to iterate over a collection of examples to render pins.
```HTML
Pin Example
@for (example of examples; track example) {
}
```
--------------------------------
### Amount Pipe Examples
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/pipes/amount/examples/1/index.html
Examples of using the Amount pipe with different currencies and options.
```html
1. {{ 10728.9 | tuiAmount }}
2. {{ 10728.9 | tuiAmount: 'RUB' }}
3. {{ 10728.9 | tuiAmount: 'EUR' }}
4. {{ 10728.9 | tuiAmount: 'USD' }}
5. {{ 10728.9 | tuiAmount: 'GBP' }}
6. {{ -12345.1 | tuiAmount: 'USD' : 'start' }}
7. {{ 100 | tuiAmount: '£' : 'start' : 'force-negative' }}
8. {{ 200 | tuiAmount: 'AED' : 'start' }}
```
--------------------------------
### Basic InputCardGroup Usage
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/input-card-group/index.html
Demonstrates the basic structure for iterating through examples of the InputCardGroup component. This snippet shows how to loop through a collection of examples.
```html
<%@ for (const example of examples) { %>
<% } %>
```
--------------------------------
### Card Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/navigation/examples/3/index.html
Demonstrates a card component for code repositories with a personal and development plan.
```html
@if (current === 'card') { Code Repositories Taiga UI
Personal and Development Plan Here you can initiate and participate in the review of package objects. Each object have up to 3 groups of reviewers, with one response required from each type, and any other participant can change both positive
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
}
```
--------------------------------
### Line Days Chart Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/line-days-chart/index.html
Demonstrates the basic usage of the Line Days Chart component. It iterates through examples and displays dots on the chart for hover information. The Y-axis range and pixel scale are set to 1:1, starting from the beginning of the Y-axis. Includes options for smoothing and custom stringification for axis hints.
```html
@for (example of examples; track example) { } show dots on chart content of hint for hover. It has `$implicit` in context with a tuple `[TuiDay, number]` axis Y range, pixel scale is 1:1 start of Y axis smoothing factor from 0 to 99 array of data function to stringify a value number to a string in axis X hint function to stringify a value number to a string in axis Y hint
```
--------------------------------
### Install Taiga UI
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/app/getting-started/index.html
Use this command to add the Taiga UI library to your project and automatically configure it.
```bash
npm i @taiga-ui/core --save
npm i @taiga-ui/cdk --save
```
--------------------------------
### Content Projection Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/thumbnail-card/index.html
Shows how to project content into the Thumbnail Card component, such as an image.
```html
@for (example of examples; track example) { }
{{ contentProjection }}
```
--------------------------------
### Install @taiga-ui/cdk using npm
Source: https://github.com/taiga-family/taiga-ui/wiki/Home
This snippet shows the command to install the @taiga-ui/cdk package using npm. This is the first step to using the core functionalities provided by Taiga UI's CDK.
```bash
npm i @taiga-ui/cdk
```
--------------------------------
### Get Payment System from Card Number (TypeScript)
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/utils/miscellaneous/examples/import/component.md
This snippet demonstrates how to import and use the getPaymentSystem function from the @taiga-ui/kit library. It takes a card number as input and returns information about the associated payment system. Ensure the @taiga-ui/kit package is installed as a dependency.
```TypeScript
import {getPaymentSystem} from '@taiga-ui/kit';
// ...
const cardNumber = '1234567890123456'; // Example card number
paymentSystem = getPaymentSystem(cardNumber);
// ...
console.log(paymentSystem);
```
--------------------------------
### Confirm Dialog Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/confirm/examples/import/service.md
Demonstrates how to open a confirmation dialog using TuiDialogService and TUI_CONFIRM.
```APIDOC
## Confirm Dialog Usage
### Description
This example shows how to trigger a confirmation dialog with custom text and button labels using the `TuiDialogService` and the `TUI_CONFIRM` component.
### Method
`dialogs.open()`
### Endpoint
N/A (Client-side component)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
`TUI_CONFIRM` component with configuration options:
- **label** (string) - Required - The main title of the dialog.
- **data** (object) - Required - Data object for the dialog content:
- **content** (string) - Required - The main message to display.
- **yes** (string) - Required - Text for the confirmation button.
- **no** (string) - Required - Text for the cancel button.
### Request Example
```typescript
this.dialogs
.open(TUI_CONFIRM, {
label: 'Are you sure?',
data: {
content: 'This action has consequences',
yes: 'Whatever...',
no: 'Oops!',
},
})
.subscribe((response) => {
// Handle response (true for yes, false for no)
});
```
### Response
#### Success Response (Dialog closed with user input)
- **response** (boolean) - `true` if the user clicks 'yes', `false` if the user clicks 'no'.
#### Response Example
```json
{
"response": true
}
```
#### Error Handling
- If the dialog is closed without user interaction (e.g., by pressing Escape), the observable might complete without emitting a value or emit `undefined` depending on the dialog configuration.
```
--------------------------------
### Segmented Component Examples
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/segmented/index.html
Demonstrates various configurations of the Segmented component, including different sizes, width adjustments, custom content, and disabled states. Use these examples to understand how to integrate and customize the component for navigation or state management.
```html
@for (example of ['Sizes', 'Width', 'Customization', 'Content', 'Disabled']) {
}
```
--------------------------------
### Tabbed Content Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/navigation/examples/3/index.html
Shows a structure with tabs and dynamically generated content.
```html
First tab Second tab Third tab Button Button
@for (\_ of '-'.repeat(10); track $index) {
Some random content A subtitle
------------------------------
}
```
--------------------------------
### Separate Toggles Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/data-list/examples/3/index.html
This example demonstrates the use of separate toggle switches for independent options, labeled 'First' and 'Second'.
```html
Separate toggles
Open First Second
```
--------------------------------
### Basic Date Picker Usage
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/date-picker/examples/4/index.html
Illustrates the fundamental setup for a Date Picker component.
```html
```
--------------------------------
### Working with objects
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/input-chip/examples/4/index.html
This example illustrates how to use the input chip with an array of objects, displaying a specific property of each object.
```HTML
user.name"
> user.name"
>
```
--------------------------------
### Block Status Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/block-status/index.html
Demonstrates the usage of the Block Status component with a card view size for desktop.
```html
@for (example of examples; track example) {
}
Title
Description Action enable border radius and padding for card view size (for desktop only)
```
--------------------------------
### Install Taiga UI dependencies
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/kit/README.md
Command to install the core Taiga UI packages including CDK, core, and kit. This is the standard installation method for Angular applications using Taiga UI.
```bash
npm i @taiga-ui/{cdk,core,kit}
```
--------------------------------
### Lazy Loading Routes Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/AGENTS.md
Example of how to configure lazy-loaded routes using standalone components.
```typescript
export const routes: Routes = [
{
path: 'feature',
loadComponent: async () => (await import('./feature/feature.component')).FeatureComponent,
},
];
```
--------------------------------
### Install Taiga UI Core Packages
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/experimental/README.md
Installs the essential base packages for Taiga UI, including CDK and core functionalities. These are foundational for using other Taiga UI libraries.
```bash
npm i @taiga-ui/cdk @taiga-ui/core
```
--------------------------------
### FloatingContainer Examples
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/floating-container/index.html
Demonstrates various use cases for the FloatingContainer, including scroll-based appearance, use within dialogs, and custom content.
```HTML
Any kind of content can be placed inside. Use `animation: none` to prevent pop-in animation.
```
```HTML
Main actionSecondary action
```
```HTML
Text block can be used together with a single button.
```
```HTML
Overlay color can be customized.
```
```HTML
Using Slides to crossfade a button.Another slide content
```
```HTML
Appearing on scroll and toggling of secondary action.
Toggle
```
```HTML
Using inside a SheetDialog
```
--------------------------------
### Install Taiga UI Core Packages
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/addon-charts/README.md
Installs the essential base packages for Taiga UI, including CDK and core functionalities. These are prerequisites for using other Taiga UI addons.
```bash
npm i @taiga-ui/{cdk,core}
```
--------------------------------
### Conditional Rendering Examples
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/addon-commerce/components/input-card-group/input-card-group.template.html
Demonstrates conditional rendering based on different content states. Use these for showing or hiding elements based on specific conditions.
```html
@if (content()) {
}
```
```html
@if (hasCleaner()) { }
```
```html
@if (dropdown.content()) { }
```
--------------------------------
### Minimalistic Table Usage
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/table/index.html
The most basic example of how to implement the TUI table component.
```html
```
--------------------------------
### Iterating Over Key-Value Variants in Header
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/header/examples/4/index.html
This example shows how to iterate over key-value pairs to dynamically render header content. It's useful for displaying dynamic data or configurations.
```html
@for (item of variants | keyvalue; track $index) {
{{ item.key }}
--------------
{{ item.value }}
Some description text
}
```
--------------------------------
### Taiga UI Label Usage Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/label/index.html
Demonstrates the basic usage of the Label component in Taiga UI. It shows how to associate a label with a form element using the provided syntax. This example utilizes Angular's template syntax.
```html
```
--------------------------------
### Currency Exchange Rate Display (Taiga UI)
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/data-list/examples/5/index.html
This example shows how to display currency exchange rates for Dollar and Euro against Ruble. It uses template variables to present the conversion values.
```HTML
Dol - {{ dollar }}, Eur - {{ euro }}
```
--------------------------------
### Minimal Carousel Implementation
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/carousel/index.html
Use this for a basic carousel setup with defined limits. Ensure to define the template for items and context for the index.
```html
@for (example of examples; track example) {
@switch ($index) {
@case (0) { Minimal implementation with limits. }
@case (1) { Infinite loop with seamless transitions. }
@case (2) { Scrolling to the next slide after timeout. }
@case (3) { Carousel automatically transitions height of the container. }
@case (4) { Multiple items per slide. }
}
}
min index
max index
current index
define template for items.
Context `$implicit` is index of item in scroller.
```
--------------------------------
### Install Taiga UI Experimental Package
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/experimental/README.md
Installs the experimental package for Taiga UI, which contains new versions of components. This package can be used independently or with other Taiga UI libraries.
```bash
npm i @taiga-ui/experimental
```
--------------------------------
### Taiga UI Bottom Actions Element Loop
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/action-bar/index.html
This snippet demonstrates the basic structure for iterating over examples within the Taiga UI framework. It is used to render dynamic content based on a collection of examples.
```HTML
@for (example of examples; track example) { }
```
--------------------------------
### Install Taiga UI CDK via NPM
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/cdk/README.md
This command installs the @taiga-ui/cdk package into your Angular project. It is a prerequisite for using the low-level tools and abstractions provided by the library.
```bash
npm i @taiga-ui/cdk
```
--------------------------------
### Basic Empty Loader
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/notification-middle/index.html
Displays a basic empty loader. No specific setup is required beyond including the component.
```html
@for (example of examples; track example) { @switch ($index) { @case (0) { Basic empty loader. } @case (1) { Changing content and adding text to the card. } @case (2) { Dynamically updating content and closing with timeout. Don't forget Animated directive! } @case (3) { Design specs require notification to be shown for a minimum of 600ms to prevent visual flickering for short requests. } } }
```
--------------------------------
### Basic Table Structure
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/table/examples/2/index.html
Demonstrates the basic structure for defining table columns and rows, including conditional rendering and loops.
```html
@for (chip of item.items; track chip) {
{{ chip }}
}
+ {{ item.items.length - number - 1 }}
{{ item.progress }}ms
Edit
More
}
```
--------------------------------
### Basic Form Layout with CSS Grid
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/navigation/examples/1/index.html
Illustrates using CSS Grid for layout within a sidebar. This example shows a simple registration form structure.
```css
Use CSS grid to position
----------------------------------------
}
```
--------------------------------
### Initialize Taiga UI Core in Angular
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/app/getting-started/examples/main-standalone.md
This snippet demonstrates how to import and use the `provideTaiga` function to set up the Taiga UI core module within an Angular application's bootstrap process. It's essential for enabling Taiga UI components and services. Ensure `@taiga-ui/core` is installed as a dependency.
```typescript
import {provideTaiga} from '@taiga-ui/core';
// ...
bootstrapApplication(App, {
providers: [
provideTaiga(),
//...
],
}).catch(console.error);
```
--------------------------------
### Basic TuiRoot Setup with Content Projection in Angular
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/customization/portals/examples/setup/insert-host.md
This snippet shows the basic structure of the TuiRoot component within an Angular application. It demonstrates how to use ng-container with ngProjectAs to project content into specific slots, such as 'tuiOverContent', allowing for custom portal host implementations.
```html
```
--------------------------------
### Basic Dropdown Hover Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/directives/dropdown-hover/examples/3/index.html
Demonstrates the basic usage of the Dropdown Hover directive. This is typically used for simple dropdown menus.
```HTML
Dropdown
Content!
```
--------------------------------
### Tabs with Buttons
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/tabs/index.html
Example of rendering buttons within tabs. The content of each button is displayed directly.
```HTML
{{ button }}
```
--------------------------------
### Increase Node.js Memory Limit
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/info/migration-guide/troubleshooting/index.html
Example of how to increase the memory limit for the Node.js process to overcome heap limit allocation failures during migration.
```bash
export NODE_OPTIONS=--max-old-space-size=4096
nx migrate --run-migrations --force
```
--------------------------------
### Template for a Documentation Page
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/addon-doc/README.md
Renders a documentation page using Taiga UI components, including headers, package info, tabs for content, code examples, and API tables.
```html
This would be the content of a first tab
Some input description
```
--------------------------------
### Create a Documentation Component
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/addon-doc/README.md
Defines an Angular component for a documentation page, including importing files as strings for code examples and defining component inputs.
```typescript
// ..
@Component({
selector: 'first-doc-page',
templateUrl: './super.component.html',
imports: [TuiAddonDoc],
})
export class DocPage {
// Keys would be used as tabs for code example
readonly example = {
// import a file as a string
TypeScript: import('./examples/1/index.ts?raw', {with: {loader: 'text'}}),
HTML: import('./examples/1/index.html', {with: {loader: 'text'}}),
LESS: '.box { color: red }',
};
readonly inputVariants = ['input 1', 'input 2'];
}
```
--------------------------------
### Implement Height Transition Wrapper in Angular
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/elastic-container/index.html
Demonstrates how to use the wrapper component within an Angular template. It iterates over a collection of examples using the @for control flow block.
```html
@for (example of examples; track example) {
{{ example.content }}
}
```
--------------------------------
### Code Snippet Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/addon-doc/components/code/index.html
This is an example of a code snippet.
```html
@if (filename()) {
{{ filename() }}
} @for (content of processor(); track content) {
@if (lineNumbers()) {
`{{isServer ? content : ''}}`
} @else {
`{{isServer ? content : ''}}`
}
{{ copyText() }}
}
```
--------------------------------
### Configure Taiga UI MCP Server with npx
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/info/ai-support/snippets/installation.md
This configuration defines how to run the Taiga UI MCP server using npx. It specifies the command to execute and the necessary arguments, including the source URL for LLM data. This setup is crucial for initializing the Taiga UI development environment with the correct data sources.
```json
{
"mcpServers": {
"taigaUi": {
"command": "npx",
"args": [
"@taiga-ui/mcp@latest",
"--source-url=https://taiga-ui.dev/llms-full.txt"
]
}
}
}
```
--------------------------------
### Simple Buttons with Preset Sizes
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/button/index.html
Demonstrates basic button usage with predefined size options. Ensure text labels are provided for accessibility, especially when using icon buttons.
```html
```
--------------------------------
### Basic Iteration Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/app-bar/examples/5/index.html
Demonstrates a basic iteration pattern using Angular's @for loop. This snippet is intended for general UI element generation.
```typescript
@for (_ of '-'.repeat(7); track $index) {
Title
Description
}
```
--------------------------------
### Import Taiga UI Styles and Define Base Layout
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/app/stackblitz/project-files/src/styles.less.md
Include the core theme and font files, then apply global styles to the application container and header elements.
```less
@import '@taiga-ui/styles/taiga-ui-theme.less';
@import '@taiga-ui/styles/taiga-ui-fonts.less';
app {
display: block;
padding: 1.5rem;
height: 100%;
box-sizing: border-box;
font-size: 16px;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid var(--tui-border-normal);
padding-left: 20px;
font: var(--tui-typography-body-s);
color: var(--tui-text-primary);
background: var(--tui-background-base-alt);
}
```
--------------------------------
### Setup Jest Environment Polyfills and Mocks
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/info/testing/jest/examples/setup-jest.md
This snippet includes essential polyfills and custom mocks for browser events like AnimationEvent, TransitionEvent, and DragEvent. These are crucial for ensuring that tests run reliably in a Node.js environment without a full browser DOM.
```typescript
import '@taiga-ui/jest-config/polyfill'; // included setupZoneTestEnv
// make custom mocks
(window as any).AnimationEvent = {};
(window as any).TransitionEvent = {};
(window as any).DragEvent = class {};
```
--------------------------------
### Install Taiga UI via Angular CLI
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/taiga-schematics/README.md
Uses the Angular CLI to add Taiga UI to an existing project. This command automatically configures the necessary dependencies and project settings.
```bash
ng add taiga-ui
```
--------------------------------
### Creating Documentation Pages
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/addon-doc/README.md
Demonstrates how to create a documentation page component using `TuiDocPage` and `TuiDocExample`, including API table definition.
```APIDOC
5. Create pages.
_Component:_
```ts
// ..
@Component({
selector: 'first-doc-page',
templateUrl: './super.component.html',
imports: [TuiAddonDoc],
})
export class DocPage {
// Keys would be used as tabs for code example
readonly example = {
// import a file as a string
TypeScript: import('./examples/1/index.ts?raw', {with: {loader: 'text'}}),
HTML: import('./examples/1/index.html', {with: {loader: 'text'}}),
LESS: '.box { color: red }',
};
readonly inputVariants = ['input 1', 'input 2'];
}
```
> You can use any tool to import a file as a string. For example, you can use:
>
> - [Esbuild loaders](https://angular.dev/tools/cli/build-system-migration#file-extension-loader-customization)
> (recommended)
> - [Webpack Asset Modules](https://webpack.js.org/guides/asset-modules)
_Template:_
```html
This would be the content of a first tab
Some input description
```
```
--------------------------------
### Basic App Bar with 7 Items
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/app-bar/examples/7/index.html
Demonstrates a simple App Bar structure with a loop generating 7 items. Suitable for basic navigation or lists.
```html
@for (\_ of '-'.repeat(7); track $index) {
Title
Description
}
```
--------------------------------
### Dropdown Context Menu Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/directives/dropdown-context/examples/2/index.html
This snippet shows how to implement a context menu for table rows using the Dropdown Context directive. It iterates through columns, row data, menu items, and additional options to build the menu structure.
```HTML
Dropdown Context Example
@for (column of tableColumns; track column) {
{{ column }}
}
@for (rowInfo of tableData; track rowInfo.character) {
```
--------------------------------
### Nested Dropdown Hover Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/directives/dropdown-hover/examples/3/index.html
Shows an example of a nested dropdown hover structure. This enables dropdowns within dropdowns for complex navigation or selection.
```HTML
Nested dropdown hover
Nested content!
```
--------------------------------
### Mobile Calendar Template Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/addon-mobile/components/mobile-calendar/mobile-calendar.template.html
An example of the mobile calendar template structure, including conditional rendering and loops for days and months.
```html
@if (chooseDayOrRangeTexts?.(); as texts) {
{{ closeWord() }} {{ cancelWord() }}
@let text = multi() ? texts[2] : texts[1]; {{ single() ? texts[0] : text }}
---------------------------------------------------------------------------------
{{ doneWord() }}
}
{{ index }}
@for (day of unorderedWeekDays$ | tuiOrderWeekDays | async; track day) {
{{ day }}
}
{{ monthNames()[month.month] }}
---------------------------------
```
--------------------------------
### Obfuscate strings using tuiObfuscate pipe
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/pipes/obfuscate/examples/1/index.html
Demonstrates how to use the tuiObfuscate pipe in Angular templates. The first example uses the default masking, while the second example allows for a custom mask character.
```html
{{ '+7(900)500-40-20' | tuiObfuscate }}
{{ '2200 4400' | tuiObfuscate: '#' }}
```
--------------------------------
### Dynamic Columns with Structural Directives
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/table/index.html
Demonstrates how to use structural directives for creating dynamic table columns.
```html
{{ column.label }}
{{ row.name }}
{{ row.age }}
```
--------------------------------
### Customize Progress Circle Direction and Start Point with CSS Transform
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/progress-circle/index.html
Use the CSS `transform` property to customize the direction and starting point of the progress circle. This allows for advanced visual effects and control over the animation.
```html
```
--------------------------------
### Iterate and Render Single Icon with @for
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/chip/examples/2/index.html
Shows how to loop through a 'sizes' collection and render a single icon for each element. 'track size' optimizes rendering.
```HTML
@for (size of sizes; track size) { Single icon }
```
--------------------------------
### Using Appearance Directive
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/directives/appearance/index.html
Demonstrates the basic usage of the Appearance directive for visual presets. Use the `appearance` selector when the host component already exposes it via `hostDirectives`.
```html
```
--------------------------------
### Install SSR Support for Taiga UI
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/app/getting-started/index.html
If you intend to use Server-Side Rendering (SSR) with Taiga UI, install the `@ng-web-apis/universal` package. This package provides advanced mocks and tools for extracting user agent and location information from server-side requests.
```typescript
@for (example of examples; track example) { @switch ($index) { @case (5) { If you want to use SSR with Taiga UI you need to install `@ng-web-apis/universal` package. It has advanced mocks and tools to extract user agent and location info from server side requests. } } }
```
--------------------------------
### File Component States and Content
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/file/examples/5/index.html
Demonstrates the File component with different states like progress, loader, error, and button, along with associated content and images.
```HTML
@for (item of states; track $index) { {{ item }} } @for (orientation of orientations; track $index) {
@switch (state()) {
@case ('progress') { }
@case ('loader') { }
@case ('error') { }
@case ('button') { Retry }
}
file.png
@switch (state()) {
@case ('normal') {
5 MB
}
@case ('error') {
Over 30 MB
}
@case ('button') {
Not uploaded
}
@default {
Uploading...
}
}
}
```
--------------------------------
### Install Taiga UI Charts Addon
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/addon-charts/README.md
Installs the specific addon package for Taiga UI charts. This package provides various charting and graph components to enhance data visualization in Angular applications.
```bash
npm i @taiga-ui/addon-charts
```
--------------------------------
### Hint Directive Usage
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/directives/hint/index.html
Demonstrates the basic usage of the `*tuiHint` directive. Ensure it's nested within a `tuiHint` directive for correct dependency injection.
```html
@for (example of examples; track example) { @if ($index === 1) {
Make sure `*tuiHint` directive is nested inside `tuiHint` directive so that dependency injection works properly
} }
```
--------------------------------
### Install Taiga UI Table dependencies
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/addon-table/README.md
Commands to install the required base packages and the specific table addon package for Taiga UI using npm. These packages are necessary to enable table functionality in an Angular project.
```bash
npm i @taiga-ui/{cdk,core}
npm i @taiga-ui/addon-table
```
--------------------------------
### Configuring Highlight Options
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/directives/highlight/index.html
Explains how to customize the highlight color using the `TUI_HIGHLIGHT_OPTIONS` token and the `tuiHighlightOptionsProvider` function.
```APIDOC
## Configuring Highlight Color
### Description
Customize the default highlight color using the `TUI_HIGHLIGHT_OPTIONS` injection token. This is achieved by providing a new value for the `highlightColor` property.
### Method
Configuration via Injection Token
### Endpoint
N/A (Client-side configuration)
### Parameters
#### `TUI_HIGHLIGHT_OPTIONS` Token
- **highlightColor** (string) - Optional - The desired color for the text highlight. Defaults to a predefined color if not specified.
### Usage
Use the `tuiHighlightOptionsProvider` function in your Angular module or component to provide a custom value for `TUI_HIGHLIGHT_OPTIONS`.
### Request Example
```typescript
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TuiHighlightModule, tuiHighlightOptionsProvider } from '@taiga-ui/kit';
@NgModule({
imports: [
CommonModule,
TuiHighlightModule
],
providers: [
tuiHighlightOptionsProvider({
highlightColor: 'yellow'
})
]
})
export class AppModule {}
```
### Response
N/A
#### Success Response (N/A)
N/A
#### Response Example
N/A
```
--------------------------------
### Iterate and Render Duo Icon with @for
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/chip/examples/2/index.html
Illustrates iterating over 'sizes' and rendering a 'Duo icon' for each item. The 'track size' directive is used for performance.
```HTML
@for (size of sizes; track size) { Duo icon }
```
--------------------------------
### Basic String Input
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/input/index.html
Demonstrates the fundamental usage of the Input component for basic string values.
```HTML
@for (example of examples; track example) { @switch ($index) { @case (0) { Basic string value input. } @case (1) { You can change states of the component manually or it can follow state of a form control when Angular form directives are applied to it. } @case (2) { For more complex dropdown controls it is recommended to use dedicated components, such as Select or ComboBox } @case (3) { An example of a password textfield with an interactive icon to toggle the input type. } @case (4) { If you need to perform some additional actions or logging when user clicks cleaner button. } @case (5) {
We recommends using [Maskito](https://maskito.dev) for input masking. **Maskito** is supported by Taiga Family team and it is already peer-dependency of `@taiga-ui/kit` library.
This example demonstrates how to use built-in [Number](https://maskito.dev/kit/number) mask with postfix and augment it by several **Maskito** plugins.
} @case (6) { On mobile, especially when font scaling is enabled for accessibility, you have limited space and might want to make sure the entire label is visible when the user fills it in. You can enable wrapping so it can wrap onto multiple lines. } } }
@if (textfield.size !== 's') {
I am a label
}
text value (alternatively use reactive forms) grayed out guiding text
```
--------------------------------
### Complex Expandable Table Sections
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/table/index.html
Provides examples of more complex expandable section implementations in tables.
```html
{{ row.name }}
```
--------------------------------
### Basic Usage
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/addon-doc/README.md
Integrate the `TuiDocMain` component into your application's template and configure highlight.js for code syntax highlighting.
```APIDOC
## How to use
1. Include `TuiDocMain` in your App imports and use in your template:
```html
You can add content here, it will be shown below navigation in the sidebar
```
2. Configure languages to highlight in your root providers:
```typescript
import {Component} from '@angular/core';
import {TuiDocMain} from '@taiga-ui/addon-doc';
import {provideHighlightOptions} from 'ngx-highlightjs';
import {App} from './app.component';
@Component({
imports: [TuiDocMain],
providers: [
provideHighlightOptions({
coreLibraryLoader: () => import('highlight.js/lib/core' as string),
lineNumbersLoader: () => import('ngx-highlightjs/line-numbers' as string), // Optional, only if you want the line numbers
languages: {
typescript: () => import('highlight.js/lib/languages/typescript' as string),
less: () => import('highlight.js/lib/languages/less' as string),
xml: () => import('highlight.js/lib/languages/xml' as string),
},
}),
],
})
export class App {}
```
```
--------------------------------
### InputDateTime with Size Not 's'
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/input-date-time/index.html
Example demonstrating the 'Choose date' label when the textfield size is not 's'.
```HTML
```
--------------------------------
### Iterate over file lists and loading state
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/input-files/examples/3/index.html
Use these loops to display lists of files and the loading state. Ensure the loading state is conditional based on the environment.
```html
@for (file of files; track file) { } @for (file of rejectedFiles; track file) { } @if (loadingFile && !isE2E) { }
```
--------------------------------
### Dark Mode Usage
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/customization/dark-mode/usage.md
Example of how to use the TUI_DARK_MODE service to control dark mode.
```typescript
import {inject} from '@angular/core';
import {TUI_DARK_MODE} from '@taiga-ui/core';
@Component({
// ...
})
export class MyComponent {
protected readonly darkMode = inject(TUI_DARK_MODE);
enable(): void {
// Set explicitly
this.darkMode.set(true);
}
toggle(): void {
this.darkMode.update((dark) => !dark);
}
resetToSystem(): void {
// Reset to system preference (prefers-color-scheme)
this.darkMode.reset();
}
}
```
--------------------------------
### Configure Jest for Taiga UI
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/info/testing/jest/examples/jest-config-custom.md
Defines the Jest configuration using the Angular preset and a custom setup file.
```ts
import type {Config} from 'jest';
const config: Config = {
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['/setup-jest.ts'],
};
export default config;
```
--------------------------------
### File Component with Various Content Types
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/file/examples/1/index.html
Demonstrates rendering the File component with different content types including icon, button, progress, loader, image, and error states.
```HTML
@for (item of content; track $index) {
@switch (item) {
@case ('icon') { }
@case ('button') { Retry }
@case ('progress') { }
@case ('loader') { }
@case ('image') {  }
@case ('error') { }
}
}
```
--------------------------------
### Basic InputColor Usage
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/input-color/index.html
Demonstrates the fundamental structure of the InputColor component, combining a text field with color input and Maskito integration.
```html
Choose color
@for (example of examples; track example) {
Choose color
}
@if (textfieldDoc.size !== 's') {
Choose color
}
```
--------------------------------
### Updating Signal State
Source: https://github.com/taiga-family/taiga-ui/blob/main/CLAUDE.md
Example of updating a signal's state in response to user interaction.
```typescript
count.update(value => value + 1)
```
--------------------------------
### Iterate and Render Text with @for
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/chip/examples/2/index.html
Demonstrates iterating over a collection 'sizes' and rendering text for each item. The 'track size' ensures efficient updates.
```HTML
@for (size of sizes; track size) { Text }
```
--------------------------------
### Chat Messages Shrink Wrap Example
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/shrink-wrap/index.html
Ensures chat messages only span as wide as they have to. This is a common use case for the shrink wrap directive.
```html
Chat message content here
```
--------------------------------
### Basic Input Phone International
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/input-phone-international/index.html
A basic example of using the InputPhoneInternational component. It allows users to input phone numbers in an international format.
```html
```
--------------------------------
### Basic Table Usage
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/table/examples/10/index.html
Displays a table with data using basic configuration. Suitable for standard data presentation.
```html
@for (item of basicData; track item) { }
```
```html
{{ basicData.length }} Developers (basic usage)
```
```html
{{ basicData | tuiMapper: getSumBalance | tuiFormatNumber }}
```
```html
{{ item.firstName }}
```
```html
{{ item.lastName }}
```
```html
{{ item.role }}
```
```html
{{ item.balance | tuiFormatNumber }}
```
--------------------------------
### Conditional Rendering with @if
Source: https://github.com/taiga-family/taiga-ui/blob/main/projects/demo/src/pages/components/thumbnail-card/examples/5/index.html
Use the @if directive for conditional rendering within templates. This example shows how to conditionally render content based on a card's prefix.
```html
@for (state of statuses; track state) { {{ state }} }
Card number @if (card.startsWith('1234')) { }
```