account-switcher.tsx — ui Source File
Architecture documentation for account-switcher.tsx, a tsx file in the ui codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR ee6815f6_b4c1_7339_f891_18ca7f0c764e["account-switcher.tsx"] 1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"] ee6815f6_b4c1_7339_f891_18ca7f0c764e --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2 79081a1f_55a3_945a_fb8c_d53d6d3eab81["utils"] ee6815f6_b4c1_7339_f891_18ca7f0c764e --> 79081a1f_55a3_945a_fb8c_d53d6d3eab81 d493776b_8734_5d8d_382d_0f77f309a72b["select"] ee6815f6_b4c1_7339_f891_18ca7f0c764e --> d493776b_8734_5d8d_382d_0f77f309a72b style ee6815f6_b4c1_7339_f891_18ca7f0c764e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"use client"
import * as React from "react"
import { cn } from "@/lib/utils"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/registry/new-york/ui/select"
interface AccountSwitcherProps {
isCollapsed: boolean
accounts: {
label: string
email: string
icon: React.ReactNode
}[]
}
export function AccountSwitcher({
isCollapsed,
accounts,
}: AccountSwitcherProps) {
const [selectedAccount, setSelectedAccount] = React.useState<string>(
accounts[0].email
)
return (
<Select defaultValue={selectedAccount} onValueChange={setSelectedAccount}>
<SelectTrigger
className={cn(
"flex items-center gap-2 [&>span]:line-clamp-1 [&>span]:flex [&>span]:w-full [&>span]:items-center [&>span]:gap-1 [&>span]:truncate [&_svg]:h-4 [&_svg]:w-4 [&_svg]:shrink-0",
isCollapsed &&
"flex h-9 w-9 shrink-0 items-center justify-center p-0 [&>span]:w-auto [&>svg]:hidden"
)}
aria-label="Select account"
>
<SelectValue placeholder="Select an account">
{accounts.find((account) => account.email === selectedAccount)?.icon}
<span className={cn("ml-2", isCollapsed && "hidden")}>
{
accounts.find((account) => account.email === selectedAccount)
?.label
}
</span>
</SelectValue>
</SelectTrigger>
<SelectContent>
{accounts.map((account) => (
<SelectItem key={account.email} value={account.email}>
<div className="flex items-center gap-3 [&_svg]:h-4 [&_svg]:w-4 [&_svg]:shrink-0 [&_svg]:text-foreground">
{account.icon}
{account.email}
</div>
</SelectItem>
))}
</SelectContent>
</Select>
)
}
Domain
Subdomains
Functions
Types
Dependencies
- react
- select
- utils
Source
Frequently Asked Questions
What does account-switcher.tsx do?
account-switcher.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, UIPrimitives subdomain.
What functions are defined in account-switcher.tsx?
account-switcher.tsx defines 1 function(s): AccountSwitcher.
What does account-switcher.tsx depend on?
account-switcher.tsx imports 3 module(s): react, select, utils.
Where is account-switcher.tsx in the architecture?
account-switcher.tsx is located at deprecated/www/app/(app)/examples/mail/components/account-switcher.tsx (domain: ComponentRegistry, subdomain: UIPrimitives, directory: deprecated/www/app/(app)/examples/mail/components).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free