Account
Make changes to your account here. Click save when you are done.
Password
Change your password here. After saving, you will be logged out.
package showcase
import (
"github.com/templui/templui/components/button"
"github.com/templui/templui/components/card"
"github.com/templui/templui/components/input"
"github.com/templui/templui/components/tabs"
)
templ TabsDefault() {
@tabs.Tabs(tabs.Props{
ID: "account-tabs",
}) {
@tabs.List(tabs.ListProps{
Class: "w-full max-w-xs",
}) {
@tabs.Trigger(tabs.TriggerProps{
Value: "account",
IsActive: true,
}) {
Account
}
@tabs.Trigger(tabs.TriggerProps{
Value: "password",
}) {
Password
}
}
<div class="w-full max-w-xs mt-2">
@tabs.Content(tabs.ContentProps{
Value: "account",
IsActive: true,
}) {
@AccountTab()
}
@tabs.Content(tabs.ContentProps{
Value: "password",
}) {
@PasswordTab()
}
</div>
}
}
templ AccountTab() {
@card.Card() {
@card.Header() {
@card.Title() {
Account
}
@card.Description() {
Make changes to your account here. Click save when you are done.
}
}
@card.Content() {
<div class="flex flex-col gap-4">
@input.Input(input.Props{
Type: input.TypeText,
Placeholder: "Name",
ID: "name",
Value: "John Doe",
})
@input.Input(input.Props{
Type: input.TypeEmail,
Placeholder: "Email",
ID: "email",
Value: "[email protected]",
})
</div>
}
@card.Footer() {
@button.Button() {
Save changes
}
}
}
}
templ PasswordTab() {
@card.Card() {
@card.Header() {
@card.Title() {
Password
}
@card.Description() {
Change your password here. After saving, you will be logged out.
}
}
@card.Content() {
<div class="flex flex-col gap-4">
@input.Input(input.Props{
Type: input.TypePassword,
Placeholder: "Current Password",
ID: "current_password",
})
@input.Input(input.Props{
Type: input.TypePassword,
Placeholder: "New Password",
ID: "new_password",
})
</div>
}
@card.Footer() {
@button.Button() {
Save password
}
}
}
}
Installation
templui add tabsLoad the script once in your layout:
<head>
@tabs.Script()
</head>import "github.com/templui/templui/components/tabs"Load the script once in your layout:
<head>
@tabs.Script()
</head>API Reference
Tabs
Root container for the tabs component.
| Name | Type | Default |
|---|---|---|
Unique identifier for the tabs container. Auto-generated if not provided. | | - |
Additional CSS classes to apply to the tabs container. | | - |
Additional HTML attributes to apply to the tabs container. | | - |
List
Container for tab triggers with styled background and indicator.
| Name | Type | Default |
|---|---|---|
Unique identifier for the tab list element. | | - |
Additional CSS classes to apply to the tab list. | | - |
Additional HTML attributes to apply to the tab list element. | | - |
Trigger
Individual tab button that activates corresponding content.
| Name | Type | Default |
|---|---|---|
Unique identifier for the tab trigger element. | | - |
Additional CSS classes to apply to the tab trigger. | | - |
Additional HTML attributes to apply to the tab trigger element. | | - |
Unique value that identifies this tab and its corresponding content. | | - |
Whether this tab is currently active/selected. | | |
ID of the parent tabs container. Auto-detected if not provided. | | - |
Content
Container for tab content that shows when corresponding trigger is active.
| Name | Type | Default |
|---|---|---|
Unique identifier for the tab content element. | | - |
Additional CSS classes to apply to the tab content. | | - |
Additional HTML attributes to apply to the tab content element. | | - |
Value that matches the corresponding tab trigger. | | - |
Whether this content is currently visible/active. | | |
ID of the parent tabs container. Auto-detected if not provided. | | - |
JavaScript API
// Set active tab programmatically
window.tui.tabs.setActive("tabs-id", "tab-value");