RizzyUI

Tabs

A set of layered sections of content—known as tab panels—that are displayed one at a time.

Demo

The main demo showcases a common use case for tabs: organizing user settings into "Account" and "Password" sections within a card.

Source
                        <EditForm Model="_demoModel">
                            <DataAnnotationsValidator />
                            <RzInitialValidator />
	                        <RzTabs DefaultValue="account">
		                        <TabsList>
			                        <TabsTrigger Value="account">Account</TabsTrigger>
			                        <TabsTrigger Value="password">Password</TabsTrigger>
		                        </TabsList>
		                        <TabsContent Value="account">
			                        <RzCard>
				                        <CardHeader>
					                        <CardTitle>Account</CardTitle>
					                        <CardDescription>
						                        Make changes to your account here. Click save when you're done.
					                        </CardDescription>
				                        </CardHeader>
				                        <CardContent>
                                            <RzFieldSet>
                                                <RzFieldGroup>
                                                    <Field>
                                                        <FieldLabel For="@(() => _demoModel.Name)" />
                                                        <RzInputText For="@(() => _demoModel.Name)" />
                                                        <FieldError><RzValidationMessage For="@(() => _demoModel.Name)" /></FieldError>
                                                    </Field>
                                                    <Field>
                                                        <FieldLabel For="@(() => _demoModel.Username)" />
                                                        <RzInputText For="@(() => _demoModel.Username)" />
                                                        <FieldError><RzValidationMessage For="@(() => _demoModel.Username)" /></FieldError>
                                                    </Field>
                                                </RzFieldGroup>
                                            </RzFieldSet>
				                        </CardContent>
				                        <CardFooter>
					                        <RzButton>Save changes</RzButton>
				                        </CardFooter>
			                        </RzCard>
		                        </TabsContent>
		                        <TabsContent Value="password">
			                        <RzCard>
				                        <CardHeader>
					                        <CardTitle>Password</CardTitle>
					                        <CardDescription>
						                        Change your password here. After saving, you'll be logged out.
					                        </CardDescription>
				                        </CardHeader>
				                        <CardContent>
                                            <RzFieldSet>
                                                <RzFieldGroup>
                                                    <Field>
                                                        <FieldLabel For="@(() => _demoModel.CurrentPassword)" />
                                                        <RzInputText For="@(() => _demoModel.CurrentPassword)" Role="
" />
                                                        <FieldError><RzValidationMessage For="@(() => _demoModel.CurrentPassword)" /></FieldError>
                                                    </Field>
                                                    <Field>
                                                        <FieldLabel For="@(() => _demoModel.NewPassword)" />
                                                        <RzInputText For="@(() => _demoModel.NewPassword)" Role="
" />
                                                        <FieldError><RzValidationMessage For="@(() => _demoModel.NewPassword)" /></FieldError>
                                                    </Field>
                                                </RzFieldGroup>
                                            </RzFieldSet>
				                        </CardContent>
				                        <CardFooter>
					                        <RzButton>Save password</RzButton>
				                        </CardFooter>
			                        </RzCard>
		                        </TabsContent>
	                        </RzTabs>
                        </EditForm>

Usage

Here is the basic structure for creating a set of tabs.

Source
<RzTabs DefaultValue="account" class="w-[400px]">
  <TabsList>
    <TabsTrigger Value="account">Account</TabsTrigger>
    <TabsTrigger Value="password">Password</TabsTrigger>
  </TabsList>
  <TabsContent Value="account">Make changes to your account here.</TabsContent>
  <TabsContent Value="password">Change your password here.</TabsContent>
</RzTabs>

Component Parameters

The following tables summarize the main parameters for each component in the Tabs family.

RzTabs

PropertyTypeDefaultDescription
DefaultValuestring?First tabThe value of the tab that should be active on initial render.
ChildContentRenderFragmentRequiredThe content, which should include a TabsList and TabsContent components.

TabsList

PropertyTypeDefaultDescription
ChildContentRenderFragmentRequiredThe content, which should be a series of TabsTrigger components.
AriaLabelstring?"Tabs"The accessible name for the tab list.
OrientationOrientationHorizontalThe orientation of the tab list, affecting keyboard navigation.

TabsTrigger

PropertyTypeDefaultDescription
ValuestringRequiredA unique value that associates the trigger with a TabsContent.
DisabledboolfalseIf true, the trigger is disabled and cannot be selected.
AsChildboolfalseMerges behavior into a single child element instead of rendering a button.

TabsContent

PropertyTypeDefaultDescription
ValuestringRequiredA unique value that associates the content with a TabsTrigger.

Alpine API

This page uses the rzTabs Alpine x-data component.

MethodParametersDescription
refreshTriggersRefreshes trigger registrations and selected state handling.