Skip to content
Blocks

Team Management

A working team management with illustrative data and frontend interactions.

Open ↗

Make it yours.

Install the editable source and its dependencies into your React + Tailwind project.

Scroll horizontally for long lines
pnpm dlx shadcn@4.0.8 add http://localhost:3000/r/team-management.json

Use it

Scroll horizontally for long lines
"use client";
import {TeamManagement} from '@/components/jez-ui/blocks/team-management';

export default function Example(){

return <><TeamManagement/></>;
}

Props & types

Scroll horizontally for long lines
{ className?: string }

Source

View 5 source files

registry/blocks/team-management.tsx

Scroll horizontally for long lines
"use client";
import * as React from "react";
import { cn } from "../ui/utils";
import { Input } from "../ui/input";
import { Button } from "../ui/button";
import { useDemoState } from "./demo-state";
const initial = [
  { email: "alex@example.com", role: "Owner" },
  { email: "sam@example.com", role: "Editor" },
];
export function TeamManagement({ className }: { className?: string }) {
  const [team, setTeam, reset] = useDemoState("team", initial);
  const [email, setEmail] = React.useState("");
  const [status, setStatus] = React.useState("");
  return (
    <section
      className={cn(
        "grid gap-5 rounded-xl border border-border p-6",
        className,
      )}
    >
      <div>
        <h2 className="text-lg font-semibold">
          Team members{" "}
          <span className="ml-1 text-sm text-muted-foreground">
            {team.length}
          </span>
        </h2>
        <p className="mt-1 text-sm text-muted-foreground">
          Manage who has access to this workspace.
        </p>
      </div>
      <form
        className="flex gap-2"
        onSubmit={(e) => {
          e.preventDefault();
          if (team.some((t) => t.email === email)) {
            setStatus("This person is already on the team.");
            return;
          }
          setTeam((t) => [...t, { email, role: "Invited" }]);
          setEmail("");
          setStatus("Added to the demo. No invitation email was sent.");
        }}
      >
        <Input
          type="email"
          required
          aria-label="Invite email"
          value={email}
          onChange={(e) => setEmail(e.target.value)}
          placeholder="teammate@example.com"
        />
        <Button type="submit">Invite</Button>
      </form>
      {team.map((t) => (
        <div
          key={t.email}
          className="flex flex-wrap items-center justify-between gap-3 border-b border-border py-3 text-sm"
        >
          <span className="flex min-w-0 items-center gap-3">
            <span className="grid size-9 shrink-0 place-items-center rounded-full bg-muted text-xs font-medium">
              {t.email.slice(0, 2).toUpperCase()}
            </span>
            <span className="min-w-0">
              <span className="block truncate font-medium">
                {t.email.split("@")[0]}
              </span>
              <span className="text-xs text-muted-foreground">{t.email}</span>
            </span>
          </span>
          <select
            disabled={t.role === "Owner"}
            aria-label={`Role for ${t.email}`}
            value={t.role}
            onChange={(e) =>
              setTeam((v) =>
                v.map((x) =>
                  x.email === t.email ? { ...x, role: e.target.value } : x,
                ),
              )
            }
            className="rounded-lg border border-border bg-background px-3 py-2 text-xs"
          >
            {["Owner", "Editor", "Viewer", "Invited"].map((r) => (
              <option key={r}>{r}</option>
            ))}
          </select>
        </div>
      ))}
      {status && (
        <p role="status" className="text-sm">
          {status}
        </p>
      )}
      <Button variant="ghost" className="justify-self-start" onClick={reset}>
        Reset demo
      </Button>
    </section>
  );
}

registry/ui/utils.ts

Scroll horizontally for long lines
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...values: ClassValue[]) {
  return twMerge(clsx(values));
}

registry/ui/input.tsx

Scroll horizontally for long lines
"use client";
import * as React from "react";
import { cn } from "./utils";
export function Input({ className, ...props }: React.ComponentProps<"input">) {
  return (
    <input
      className={cn(
        "block h-10 w-full min-w-0 rounded-lg border border-border bg-background px-3 text-sm leading-normal shadow-[0_1px_2px_#00000004] transition-[border-color,box-shadow] placeholder:text-muted-foreground/75 hover:border-foreground/25 focus:border-primary focus:outline-none focus:ring-3 focus:ring-primary/10 aria-invalid:border-danger aria-invalid:ring-danger/10 disabled:cursor-not-allowed disabled:bg-muted/50 disabled:opacity-50",
        className,
      )}
      {...props}
    />
  );
}

registry/ui/button.tsx

Scroll horizontally for long lines
"use client";
import * as React from "react";
import { Slot } from "radix-ui";
import { LoaderCircle } from "lucide-react";
import { cn } from "./utils";
export type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
  variant?: "primary" | "secondary" | "outline" | "ghost" | "danger";
  size?: "sm" | "md" | "lg";
  loading?: boolean;
  asChild?: boolean;
};
export function Button({
  variant = "primary",
  size = "md",
  loading,
  asChild,
  className,
  children,
  disabled,
  ...props
}: ButtonProps) {
  const Comp = asChild ? Slot.Root : "button";
  return (
    <Comp
      type={asChild ? undefined : "button"}
      disabled={asChild ? undefined : disabled || loading}
      aria-disabled={disabled || loading || undefined}
      aria-busy={loading || undefined}
      className={cn(
        "relative inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-lg border border-transparent text-sm font-medium leading-none transition-[background-color,border-color,box-shadow,transform] duration-150 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-[.98] disabled:pointer-events-none disabled:opacity-45 aria-disabled:pointer-events-none [&_svg]:shrink-0",
        {
          "bg-primary text-primary-foreground shadow-[inset_0_1px_0_#ffffff26,0_1px_2px_#00000012] hover:bg-primary/90":
            variant === "primary",
          "border-border/60 bg-muted text-foreground hover:bg-muted/70":
            variant === "secondary",
          "border-border bg-background text-foreground shadow-sm hover:bg-muted/60":
            variant === "outline",
          "text-muted-foreground hover:bg-muted hover:text-foreground":
            variant === "ghost",
          "bg-danger text-danger-foreground hover:bg-danger/90":
            variant === "danger",
        },
        {
          "h-8 px-3 text-xs": size === "sm",
          "h-10 px-4": size === "md",
          "h-12 px-6": size === "lg",
        },
        className,
      )}
      {...props}
    >
      {asChild ? (
        children
      ) : (
        <>
          <span
            className={cn(
              "inline-flex min-w-0 flex-1 items-center justify-center gap-2",
              loading && "invisible",
            )}
          >
            {children}
          </span>
          {loading && (
            <LoaderCircle
              aria-hidden="true"
              className="absolute size-4 animate-spin motion-reduce:animate-none"
            />
          )}
        </>
      )}
    </Comp>
  );
}

registry/blocks/demo-state.ts

Scroll horizontally for long lines
"use client";
import { useState, useEffect, useCallback } from "react";
export function useDemoState<T>(key: string, initial: T) {
  const [state, setState] = useState(initial);
  const [loaded, setLoaded] = useState(false);
  useEffect(() => {
    try {
      const raw = localStorage.getItem("jez-demo:" + key);
      if (raw) setState(JSON.parse(raw));
    } catch {}
    setLoaded(true);
  }, [key]);
  useEffect(() => {
    if (loaded)
      try {
        localStorage.setItem("jez-demo:" + key, JSON.stringify(state));
      } catch {}
  }, [key, state, loaded]);
  const reset = useCallback(() => setState(initial), [initial]);
  return [state, setState, reset] as const;
}

Dependencies

clsx@2.1.1 · tailwind-merge@3.5.0 · radix-ui@1.6.7 · lucide-react@0.577.0

Accessibility & behaviour

Provide meaningful labels and preserve keyboard focus styles. Check contrast when customising theme colours.

Read the accessibility and performance guide →