Clerk Organization Switcher
elements/clerk-org-switcherFreeBlock
Organization switcher dropdown with personal account, org list with role badges, and create organization option.
Install it
npx shadcn@latest add https://www.tryelements.dev/r/clerk-org-switcher.jsonSource
1"use client";23import { useCallback, useEffect, useRef, useState } from "react";45import { useOrganization, useOrganizationList, useUser } from "@clerk/nextjs";67function cn(...classes: (string | boolean | undefined)[]) {8 return classes.filter(Boolean).join(" ");9}1011function ChevronDownIcon({ className }: { className?: string }) {12 return (13 <svg14 aria-hidden="true"15 className={className}16 xmlns="http://www.w3.org/2000/svg"17 width="16"18 height="16"19 viewBox="0 0 24 24"20 fill="none"21 stroke="currentColor"22 strokeWidth="2"23 strokeLinecap="round"24 strokeLinejoin="round"25 >26 <path d="m6 9 6 6 6-6" />27 </svg>28 );29}3031function CheckIcon({ className }: { className?: string }) {32 return (33 <svg34 aria-hidden="true"35 className={className}36 xmlns="http://www.w3.org/2000/svg"37 width="16"38 height="16"39 viewBox="0 0 24 24"40 fill="none"41 stroke="currentColor"42 strokeWidth="2"43 strokeLinecap="round"44 strokeLinejoin="round"45 >46 <polyline points="20 6 9 17 4 12" />47 </svg>48 );49}5051function PlusIcon({ className }: { className?: string }) {52 return (53 <svg54 aria-hidden="true"55 className={className}56 xmlns="http://www.w3.org/2000/svg"57 width="16"58 height="16"59 viewBox="0 0 24 24"60 fill="none"61 stroke="currentColor"62 strokeWidth="2"63 strokeLinecap="round"64 strokeLinejoin="round"65 >66 <path d="M5 12h14" />67 <path d="M12 5v14" />68 </svg>69 );70}7172function UserIcon({ className }: { className?: string }) {73 return (74 <svg75 aria-hidden="true"76 className={className}77 xmlns="http://www.w3.org/2000/svg"78 width="16"79 height="16"80 viewBox="0 0 24 24"81 fill="none"82 stroke="currentColor"83 strokeWidth="2"84 strokeLinecap="round"85 strokeLinejoin="round"86 >87 <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" />88 <circle cx="12" cy="7" r="4" />89 </svg>90 );91}9293const AVATAR_COLORS = [94 "bg-violet-600",95 "bg-blue-600",96 "bg-emerald-600",97 "bg-amber-600",98 "bg-rose-600",99 "bg-cyan-600",100 "bg-fuchsia-600",101 "bg-lime-600",102];103104function getAvatarColor(id: string) {105 let hash = 0;106 for (let i = 0; i < id.length; i++) {107 hash = ((hash << 5) - hash + id.charCodeAt(i)) | 0;108 }109 return AVATAR_COLORS[Math.abs(hash) % AVATAR_COLORS.length];110}111112function getInitials(name: string) {113 return name114// … truncated
What it pulls in
npm packages
Files it writes
More from elements
All 359 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Agentic Codingagentic-coding | elements | Blocks | Free | no deps | |
| AgentMail Logoagentmail-logo | elements | Blocks | Free | no deps | |
| AI Badgeai-badge | elements | Blocks | Free | 2 deps · 2 files | |
| AI Servicesai-services | elements | Blocks | Free | no deps | |
| Astro Logoastro-logo | elements | Blocks | Free | no deps | |
| AWS All Servicesaws-all | elements | Blocks | Free | no deps | |
| AWS Analyticsaws-analytics | elements | Blocks | Free | no deps | |
| AWS Computeaws-compute | elements | Blocks | Free | no deps |
