panelui

Share

Component 1

About

Invite people by email, choose what they can do, and copy the link.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Share to your project and fits it to your theme.

Code

How Share is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

'use client';

import { useState } from 'react';
import { Share, type ShareInvitation } from '@/components/ui/panel-share';
const ROLES = [
  { value: 'viewer', label: 'Viewer', description: 'Can read and comment' },
  { value: 'editor', label: 'Editor', description: 'Can change anything' },
];

const START = [
  {
    name: 'Khalid Abdi',
    email: 'khalid@northwind.studio',
    role: 'Owner',
    src: 'https://cdn.21st.dev/assets/mirror/ed/eddf1f4dde1ee74972feda4529bc1a778e8bb53f5709efab7ce7e12319ee1e3b.jpg',
  },
  { name: 'Ines Duarte', email: 'ines@northwind.studio', role: 'editor' },
  { name: 'Sam Whitlock', email: 'sam@northwind.studio', role: 'viewer' },
];

/** "lena.ortiz@…" reads as "Lena Ortiz" until they set a name of their own. */
function nameFrom(email: string) {
  return email
    .split('@')[0]!
    .split(/[._-]+/)
    .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
    .join(' ');
}

export default function ShareOverview() {
  const [people, setPeople] = useState(START);

  const invite = ({ emails, role }: ShareInvitation) =>
    new Promise<void>((resolve) =>
      setTimeout(() => {
        setPeople((current) => [...current, ...emails.map((email) => ({ name: nameFrom(email), email, role }))]);
        resolve();
      }, 900),
    );

  return (
    <Share link="https://northwind.studio/d/spring-lookbook" onInvite={invite}>
      <Share.Trigger people={people} />
      <Share.Content title="Share “Spring lookbook”">
        <Share.Invite roles={ROLES} />
        <Share.People>
          {people.map((person) => (
            <Share.Person key={person.email} name={person.name} src={person.src} role={person.role} roles={ROLES} />
          ))}
        </Share.People>
        <Share.Footer>
          <Share.CopyLink />
          <Share.Send />
        </Share.Footer>
      </Share.Content>
    </Share>
  );
}

Dependencies

More by panelui

View all
  • Spinner

    Spinner

    8
  • Flow

    Flow

    6
  • Hex Chart

    Hex Chart

    2
  • Treemap Chart

    Treemap Chart

    1
  • Soundwave

    Soundwave

    1
  • Scatter Chart

    Scatter Chart

    1
  • Pyramid Chart

    Pyramid Chart

    1
  • Model Picker

    Model Picker

    1