# Tabs

**Tabs make it easy to explore and switch between different views.**

Tabs organize and allow navigation between groups of content that are related and at the same level of hierarchy.

## Tabs

![](/files/-MAgIJMrllxj5aJvi82N)

```powershell
New-UDTabs -Tabs {
    New-UDTab -Text 'Item One' -Content { New-UDTypography -Text 'Item One' -Variant 'h2' }
    New-UDTab -Text 'Item Two' -Content { New-UDTypography -Text 'Item Two' -Variant 'h2' }
    New-UDTab -Text 'Item Three' -Content { New-UDTypography -Text 'Item Three' -Variant 'h2' }
}
```

## Vertical Tabs

![](/files/-MAgIR6blXjAG7vBiFhl)

```powershell
New-UDTabs -Tabs {
    New-UDTab -Text 'Item One' -Content { New-UDTypography -Text 'Item One' -Variant 'h2' }
    New-UDTab -Text 'Item Two' -Content { New-UDTypography -Text 'Item Two' -Variant 'h2' }
    New-UDTab -Text 'Item Three' -Content { New-UDTypography -Text 'Item Three' -Variant 'h2' }
} -Orientation vertical
```

## Dynamic Tabs

Dynamic tabs will refresh their content when they are selected. You will need to include the `-RenderOnActive` parameter to prevent all the tabs from rendering even if they are not shown.

```powershell
New-UDTabs -Tabs {
    New-UDTab -Text 'Item One' -Content { Get-Date } -Dynamic
    New-UDTab -Text 'Item Two' -Content { Get-Date } -Dynamic
    New-UDTab -Text 'Item Three' -Content { Get-Date } -Dynamic
} -RenderOnActive
```

## Icons

```powershell
New-UDTabs -Tabs {
    New-UDTab -Text 'Item One' -Content { New-UDTypography -Text 'Item One' -Variant 'h2' } -Icon (New-UDIcon -Icon Users)
    New-UDTab -Text 'Item Two' -Content { New-UDTypography -Text 'Item Two' -Variant 'h2' } -Icon (New-UDIcon -Icon Desktop)
    New-UDTab -Text 'Item Three' -Content { New-UDTypography -Text 'Item Three' -Variant 'h2' } -Icon (New-UDIcon -Icon Exclamation)
}
```

## Selecting a tab based on a hash fragment

This allows for selecting a tab based on a `#tab1` hash in the URL to link to a specific tab.&#x20;

```powershell
$Tabs = @(
    New-UDTab -Text 'Tab1' -Id 'tab1' -Content {
        "Tab 1" 
    }  
    New-UDTab -Text 'Tab2' -Id 'tab2' -Content {
        "Tab 2" 
    }  
    New-UDTab -Text 'Tab3' -Id 'tab3' -Content {
        "Tab 3" 
    } 
)

$hash = Invoke-UDJavaScript "window.location.hash"
$SelectedTabIndex = 0

if ($hash -ne $null)
{
    for ($i=0; $i -lt $tabs.Length; $i++){
        if ($tabs[$i].id -eq $hash.TrimStart('#'))
        {
            $SelectedTabIndex = $i
        }
    }
}

New-UDTabs -Tabs {
    $Tabs
}  -SelectedTabIndex $SelectedTabIndex
```

## API

* [New-UDTabs](https://github.com/ironmansoftware/universal-docs/blob/v4/cmdlets/New-UDTabs.txt)
* [New-UDTab](https://github.com/ironmansoftware/universal-docs/blob/v4/cmdlets/New-UDTab.txt)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.powershelluniversal.com/v4-beta/userinterfaces/components/navigation/tabs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
