TenantCard

Display tenant organization information in a Material Design 3 card. Shows tenant name, slug, status badge, and member count with optional click interaction.

Installation

typescript
import { TenantCard } from '@happyvertical/smrt-tenancy/svelte';

Basic Usage

Display tenant information in a simple card.

AC
Acme Corporation
acme
svelte
<TenantCard tenant={tenant} />

With Status and Member Count

Add status badge and member count for more context.

EC
Enterprise Co active
enterprise
24 members
TI
TechStart Inc trial
techstart
5 members
svelte
<TenantCard
  tenant={tenant}
  status="active"
  memberCount={24}
/>
<TenantCard
  tenant={tenant}
  status="trial"
  memberCount={5}
/>

Interactive Cards

Make cards clickable for tenant selection or navigation.

AC
Acme Corporation
acme
15 members
TI
TechStart Inc trial
techstart
5 members
EC
Enterprise Co active
enterprise
24 members

Selected: None

svelte
<script lang="ts">
  let selectedTenant = $state<string | null>(null);
</script>

<TenantCard
  tenant={tenant}
  onclick={() => selectedTenant = tenant.id}
  selected={selectedTenant === tenant.id}
  status="active"
  memberCount={24}
/>

Status Variants

Different status badges automatically style based on tenant state.

AT
Active Tenant
acme
42 members
TT
Trial Tenant
acme
3 members
ST
Suspended Tenant
acme
18 members
IT
Inactive Tenant
acme
0 members
svelte
<TenantCard tenant={tenant} status="active" />
<TenantCard tenant={tenant} status="trial" />
<TenantCard tenant={tenant} status="suspended" />
<TenantCard tenant={tenant} status="inactive" />

Props

PropTypeDefaultDescription
tenant *Tenant-Tenant object with id, name, and slug
status string-Status badge (active, trial, suspended, etc.)
memberCount number-Number of members in the tenant
onclick () => void-Click handler for interactive cards
selected booleanfalseWhether the card is selected

TypeScript

typescript
import type { Tenant } from '@happyvertical/smrt-tenancy';

interface Props {
  tenant: Tenant;
  status?: string;
  memberCount?: number;
  onclick?: () => void;
  selected?: boolean;
}

Multi-Tenancy Integration

TenantCard works seamlessly with the smrt-tenancy module:

typescript
import { TenantsCollection } from '@happyvertical/smrt-tenancy';

// List all tenants user has access to
const tenants = await TenantsCollection.create({ db });
const userTenants = await tenants.list({
  where: {
    memberships: {
      userId: currentUser.id,
      status: 'active'
    }
  }
});

// Display in cards
{#each userTenants as tenant}
  <TenantCard
    {tenant}
    status={tenant.status}
    memberCount={tenant.memberCount}
    onclick={() => switchTenant(tenant.id)}
  />
{/each}

Use Cases

  • Tenant switcher dropdown or modal
  • Admin dashboard showing all tenants
  • Organization selector during onboarding
  • Multi-tenant workspace navigation
  • Tenant management interfaces