Docs
Tabs
A set of layered sections of content—known as tab panels—that are displayed one at a time.
import * as React from "react"; import { css } from "@pigment-css/react"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/components/ui/card"; import { Field, FieldLabel } from "@/components/ui/field"; import { Input } from "@/components/ui/input"; import { Stack } from "@/components/ui/stack"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; export function TabsExample(): React.JSX.Element { return ( <Tabs defaultValue="account" className={css({ width: "400px" })}> <TabsList className={css({ display: "grid", gridTemplateColumns: "repeat(2, minmax(0, 1fr))", })} > <TabsTrigger value="account">Account</TabsTrigger> <TabsTrigger value="password">Password</TabsTrigger> </TabsList> <TabsContent value="account"> <Card> <CardHeader> <CardTitle>Account</CardTitle> <CardDescription> Make changes to your account here. Click save when you're done. </CardDescription> </CardHeader> <CardContent> <Stack gap={2}> <Field> <FieldLabel>Name</FieldLabel> <Input defaultValue="John Doe" name="name" /> </Field> <Field> <FieldLabel>Username</FieldLabel> <Input defaultValue="@john.doe" name="username" /> </Field> </Stack> </CardContent> <CardFooter> <Button>Save changes</Button> </CardFooter> </Card> </TabsContent> <TabsContent value="password"> <Card> <CardHeader> <CardTitle>Password</CardTitle> <CardDescription> Change your password here. After saving, you'll be logged out. </CardDescription> </CardHeader> <CardContent> <Stack gap={2}> <Field> <FieldLabel>Current password</FieldLabel> <Input type="password" name="current" /> </Field> <Field> <FieldLabel>New password</FieldLabel> <Input type="password" name="new" /> </Field> </Stack> </CardContent> <CardFooter> <Button>Save password</Button> </CardFooter> </Card> </TabsContent> </Tabs> ); }
npx lotru@latest add ui/tabs
import { Tabs } from "@/components/ui/tabs";
<Tabs defaultValue="account"> <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> </Tabs>
Previous
Table
Next
Text
On this page