Skip to content

ComponentsMessaging

SourceSource

Invite

The server invite card a link unfurls into inside a message.

The server invite card a link unfurls into inside a message. Compose it from the exported registry parts so local content and behaviour stay in the application while the visual contract stays token-driven.

Root class newt-invite
import { Button } from "@/registry/bases/newt/ui/button"
import {
  Invite,
  InviteBody,
  InviteCount,
  InviteCounts,
  InviteEyebrow,
  InviteIcon,
  InviteInfo,
  InviteName,
} from "@/registry/bases/newt/ui/invite"

/* Inline so the demo never reaches out to the network for a placeholder. */
const SERVER_ICON =
  "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Crect width='48' height='48' rx='12' fill='%235865f2'/%3E%3C/svg%3E"

export default function InviteDemo() {
  return (
    <Invite>
      <InviteEyebrow>You&apos;ve been invited to join a server</InviteEyebrow>
      <InviteBody>
        <InviteIcon src={SERVER_ICON} />
        <InviteInfo>
          <InviteName href="#">Newt Community</InviteName>
          <InviteCounts>
            <InviteCount online>1,024 Online</InviteCount>
            <InviteCount>8,192 Members</InviteCount>
          </InviteCounts>
        </InviteInfo>
        <Button variant="success">Join</Button>
      </InviteBody>
    </Invite>
  )
}
<script setup lang="ts">
import { Button } from "~~/registry/bases/newt/ui/button"
import {
  Invite,
  InviteBody,
  InviteCount,
  InviteCounts,
  InviteEyebrow,
  InviteIcon,
  InviteInfo,
  InviteName,
} from "~~/registry/bases/newt/ui/invite"

/* Inline so the demo never reaches out to the network for a placeholder. */
const SERVER_ICON =
  "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Crect width='48' height='48' rx='12' fill='%235865f2'/%3E%3C/svg%3E"
</script>

<template>
  <Invite>
    <InviteEyebrow>You've been invited to join a server</InviteEyebrow>
    <InviteBody>
      <InviteIcon :src="SERVER_ICON" />
      <InviteInfo>
        <InviteName href="#">Newt Community</InviteName>
        <InviteCounts>
          <InviteCount online>1,024 Online</InviteCount>
          <InviteCount>8,192 Members</InviteCount>
        </InviteCounts>
      </InviteInfo>
      <Button variant="success">Join</Button>
    </InviteBody>
  </Invite>
</template>

Installation

npx newtui@latest add invitenpx shadcn@latest add @newtui/invitenpx shadcn-vue@latest add @newtui/invitepnpm dlx newtui@latest add invitepnpm dlx shadcn@latest add @newtui/invitepnpm dlx shadcn-vue@latest add @newtui/inviteyarn dlx newtui@latest add inviteyarn dlx shadcn@latest add @newtui/inviteyarn dlx shadcn-vue@latest add @newtui/invitebunx newtui@latest add invitebunx shadcn@latest add @newtui/invitebunx shadcn-vue@latest add @newtui/invitedeno run -A npm:newtui@latest add invitedeno run -A npm:shadcn@latest add @newtui/invitedeno run -A npm:shadcn-vue@latest add @newtui/invitevlx newtui@latest add invitevlx shadcn@latest add @newtui/invitevlx shadcn-vue@latest add @newtui/invitevp dlx newtui@latest add invitevp dlx shadcn@latest add @newtui/invitevp dlx shadcn-vue@latest add @newtui/invitenubx newtui@latest add invitenubx shadcn@latest add @newtui/invitenubx shadcn-vue@latest add @newtui/invitenlx newtui@latest add invitenlx shadcn@latest add @newtui/invitenlx shadcn-vue@latest add @newtui/inviteupx newtui@latest add inviteupx shadcn@latest add @newtui/inviteupx shadcn-vue@latest add @newtui/invite

The shadcn CLI needs the @newtui registry in your components.json. Set it up.

Add the components it builds on

Copy the source into your project

import * as React from "react"

import { cn } from "@/lib/utils"

/* The server-invite card a link unfurls into inside a message. */
const Invite = React.forwardRef<
  HTMLDivElement,
  React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn(
      "max-w-[432px] rounded-[var(--newt-radius-md)] bg-newt-bg-surface px-4 pb-4 pt-2 text-newt-text-primary",
      className
    )}
    {...props}
  />
))
Invite.displayName = "Invite"

const InviteEyebrow = React.forwardRef<
  HTMLSpanElement,
  React.HTMLAttributes<HTMLSpanElement>
>(({ className, ...props }, ref) => (
  <span
    ref={ref}
    className={cn(
      "text-[12px] font-extrabold uppercase tracking-[0.02em] text-newt-text-muted",
      className
    )}
    {...props}
  />
))
InviteEyebrow.displayName = "InviteEyebrow"

const InviteBody = React.forwardRef<
  HTMLDivElement,
  React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn("mt-2 flex items-center gap-4", className)}
    {...props}
  />
))
InviteBody.displayName = "InviteBody"

/*
 * The props of the element or component `as` names, so a custom image
 * component's own props type-check.
 */
export type InviteIconProps<E extends React.ElementType = "img"> = {
  /**
   * The image element or component to render. Defaults to `img`; pass your
   * framework's image component for optimised sources.
   */
  as?: E
} & Omit<React.ComponentPropsWithRef<E>, "as">

type InviteIconComponent = {
  <E extends React.ElementType = "img">(
    props: InviteIconProps<E>
  ): React.ReactNode
  displayName?: string
}

/*
 * SAFETY: `forwardRef` drops the generic signature. The render hands every
 * prop it does not set itself to `as` unchanged, so the props of `as` are
 * the props the part receives.
 */
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- see SAFETY
const InviteIcon = React.forwardRef<HTMLImageElement, InviteIconProps>(
  ({ as: Tag = "img", className, alt = "", ...props }, ref) => (
    <Tag
      ref={ref}
      alt={alt}
      aria-hidden={alt === "" ? true : undefined}
      className={cn(
        "h-12 w-12 shrink-0 rounded-[var(--newt-radius-md)] object-cover",
        className
      )}
      {...props}
    />
  )
) as InviteIconComponent
InviteIcon.displayName = "InviteIcon"

const InviteInfo = React.forwardRef<
  HTMLDivElement,
  React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
  <div ref={ref} className={cn("min-w-0 flex-1", className)} {...props} />
))
InviteInfo.displayName = "InviteInfo"

/*
 * The props of the element or component `as` names, so a router link's own
 * props, such as `to`, type-check.
 */
export type InviteNameProps<E extends React.ElementType = "a"> = {
  /**
   * The element or component to render. Defaults to `a`; pass a router link
   * component to keep client navigation.
   */
  as?: E
} & Omit<React.ComponentPropsWithRef<E>, "as">

type InviteNameComponent = {
  <E extends React.ElementType = "a">(
    props: InviteNameProps<E>
  ): React.ReactNode
  displayName?: string
}

/*
 * SAFETY: `forwardRef` drops the generic signature. The render hands every
 * prop it does not set itself to `as` unchanged, so the props of `as` are
 * the props the part receives.
 */
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- see SAFETY
const InviteName = React.forwardRef<HTMLAnchorElement, InviteNameProps>(
  ({ as: Tag = "a", className, ...props }, ref) => (
    <Tag
      ref={ref}
      className={cn(
        "block truncate font-bold text-newt-text-primary no-underline hover:underline",
        className
      )}
      {...props}
    />
  )
) as InviteNameComponent
InviteName.displayName = "InviteName"

const InviteCounts = React.forwardRef<
  HTMLDivElement,
  React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn(
      "mt-0.5 flex items-center gap-3 text-sm text-newt-text-muted",
      className
    )}
    {...props}
  />
))
InviteCounts.displayName = "InviteCounts"

export interface InviteCountProps extends React.HTMLAttributes<HTMLSpanElement> {
  /** Green dot for the online count, muted for the member total. */
  online?: boolean
}

const InviteCount = React.forwardRef<HTMLSpanElement, InviteCountProps>(
  ({ className, online = false, children, ...props }, ref) => (
    <span
      ref={ref}
      className={cn("inline-flex items-center gap-1.5", className)}
      {...props}
    >
      <span
        aria-hidden="true"
        className={cn(
          "h-2 w-2 shrink-0 rounded-full",
          online ? "bg-newt-online" : "bg-newt-offline"
        )}
      />
      {children}
    </span>
  )
)
InviteCount.displayName = "InviteCount"

export {
  Invite,
  InviteEyebrow,
  InviteBody,
  InviteIcon,
  InviteInfo,
  InviteName,
  InviteCounts,
  InviteCount,
}
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <div
    :class="
      cn(
        'max-w-[432px] rounded-[var(--newt-radius-md)] bg-newt-bg-surface px-4 pb-4 pt-2 text-newt-text-primary',
        props.class
      )
    "
  >
    <slot />
  </div>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <span
    :class="
      cn(
        'text-[12px] font-extrabold uppercase tracking-[0.02em] text-newt-text-muted',
        props.class
      )
    "
  >
    <slot />
  </span>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <div :class="cn('mt-2 flex items-center gap-4', props.class)">
    <slot />
  </div>
</template>
<script setup lang="ts">
import type { Component, HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = withDefaults(
  defineProps<{
    class?: HTMLAttributes["class"]
    /**
     * The image element or component to render. Defaults to `img`; pass
     * `NuxtImg` or another image component for optimised sources.
     */
    as?: string | Component
    src: string
    alt?: string
  }>(),
  { as: "img", alt: "" }
)
</script>

<template>
  <component
    :is="props.as"
    :src="props.src"
    :alt="props.alt"
    :aria-hidden="props.alt === '' ? true : undefined"
    :class="
      cn(
        'h-12 w-12 shrink-0 rounded-[var(--newt-radius-md)] object-cover',
        props.class
      )
    "
  />
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <div :class="cn('min-w-0 flex-1', props.class)">
    <slot />
  </div>
</template>
<script setup lang="ts">
import type { Component, HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = withDefaults(
  defineProps<{
    class?: HTMLAttributes["class"]
    /**
     * The element or component to render. Defaults to `a`; pass `NuxtLink`
     * or `RouterLink` to keep client navigation.
     */
    as?: string | Component
  }>(),
  { as: "a" }
)
</script>

<template>
  <component
    :is="props.as"
    :class="
      cn(
        'block truncate font-bold text-newt-text-primary no-underline hover:underline',
        props.class
      )
    "
  >
    <slot />
  </component>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <div
    :class="
      cn(
        'mt-0.5 flex items-center gap-3 text-sm text-newt-text-muted',
        props.class
      )
    "
  >
    <slot />
  </div>
</template>
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = withDefaults(
  defineProps<{
    class?: HTMLAttributes["class"]
    /** Green dot for the online count, muted for the member total. */
    online?: boolean
  }>(),
  { online: false }
)
</script>

<template>
  <span :class="cn('inline-flex items-center gap-1.5', props.class)">
    <span
      aria-hidden="true"
      :class="
        cn(
          'h-2 w-2 shrink-0 rounded-full',
          props.online ? 'bg-newt-online' : 'bg-newt-offline'
        )
      "
    />
    <slot />
  </span>
</template>
export { default as Invite } from "./Invite.vue"
export { default as InviteEyebrow } from "./InviteEyebrow.vue"
export { default as InviteBody } from "./InviteBody.vue"
export { default as InviteIcon } from "./InviteIcon.vue"
export { default as InviteInfo } from "./InviteInfo.vue"
export { default as InviteName } from "./InviteName.vue"
export { default as InviteCounts } from "./InviteCounts.vue"
export { default as InviteCount } from "./InviteCount.vue"

Update the import paths

The files import @/lib/utils and sibling components through the aliases in your components.json. Point them at wherever those live in your project.

No CLI, no components.json: paste this into Claude, Cursor, Copilot or any coding assistant and it adds Invite to your React project by hand. The prompt carries the source of every file the CLI would write — this component's and those of the components it builds on — with the imports already pointed at the default aliases.

No CLI, no components.json: paste this into Claude, Cursor, Copilot or any coding assistant and it adds Invite to your Vue project by hand. The prompt carries the source of every file the CLI would write — this component's and those of the components it builds on — with the imports already pointed at the default aliases.

Usage

import { Invite } from "@/components/ui/invite"

export function Example() {
  return <Invite />
}
<script setup lang="ts">
import { Invite, InviteEyebrow, InviteBody, InviteIcon, InviteInfo, InviteName, InviteCounts, InviteCount } from "@/components/ui/invite"
</script>

<template>
  <Invite />
</template>

Examples

Pass your router’s link to InviteName and your image component to InviteIcon with as. Each part takes the props of the component you pass, such as to for a router link.

Root class newt-invite
import type { ComponentProps } from "react"

import { Button } from "@/registry/bases/newt/ui/button"
import {
  Invite,
  InviteBody,
  InviteCount,
  InviteCounts,
  InviteEyebrow,
  InviteIcon,
  InviteInfo,
  InviteName,
} from "@/registry/bases/newt/ui/invite"

/* Inline so the demo never reaches out to the network for a placeholder. */
const SERVER_ICON =
  "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Crect width='48' height='48' rx='12' fill='%235865f2'/%3E%3C/svg%3E"

/*
 * Stand-ins for your router's link and your framework's image component.
 * Each takes a prop the plain element does not have: `to` and `size`.
 */
function RouterLink({
  to,
  ...props
}: { to: string } & Omit<ComponentProps<"a">, "href">) {
  return <a href={to} {...props} />
}

function ServerImage({
  size,
  ...props
}: { size: number } & Omit<ComponentProps<"img">, "width" | "height">) {
  return <img width={size} height={size} {...props} />
}

export default function InviteRouterDemo() {
  return (
    <Invite>
      <InviteEyebrow>You&apos;ve been invited to join a server</InviteEyebrow>
      <InviteBody>
        <InviteIcon as={ServerImage} size={48} src={SERVER_ICON} />
        <InviteInfo>
          <InviteName as={RouterLink} to="#">
            Newt Builders
          </InviteName>
          <InviteCounts>
            <InviteCount online>256 Online</InviteCount>
            <InviteCount>2,048 Members</InviteCount>
          </InviteCounts>
        </InviteInfo>
        <Button variant="success">Join</Button>
      </InviteBody>
    </Invite>
  )
}
<script setup lang="ts">
import { defineComponent, h } from "vue"
import { Button } from "~~/registry/bases/newt/ui/button"
import {
  Invite,
  InviteBody,
  InviteCount,
  InviteCounts,
  InviteEyebrow,
  InviteIcon,
  InviteInfo,
  InviteName,
} from "~~/registry/bases/newt/ui/invite"

/* Inline so the demo never reaches out to the network for a placeholder. */
const SERVER_ICON =
  "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Crect width='48' height='48' rx='12' fill='%235865f2'/%3E%3C/svg%3E"

/*
 * Stand-ins for `RouterLink` and `NuxtImg`. Each takes a prop the plain
 * element does not have: `to` and `size`.
 */
const RouterLink = defineComponent({
  props: { to: { type: String, required: true } },
  setup(props, { slots }) {
    return () => h("a", { href: props.to }, slots.default?.())
  },
})

const ServerImage = defineComponent({
  props: { size: { type: Number, required: true } },
  setup(props) {
    return () => h("img", { width: props.size, height: props.size })
  },
})
</script>

<template>
  <Invite>
    <InviteEyebrow>You've been invited to join a server</InviteEyebrow>
    <InviteBody>
      <InviteIcon :as="ServerImage" :size="48" :src="SERVER_ICON" />
      <InviteInfo>
        <InviteName :as="RouterLink" to="#">Newt Builders</InviteName>
        <InviteCounts>
          <InviteCount online>256 Online</InviteCount>
          <InviteCount>2,048 Members</InviteCount>
        </InviteCounts>
      </InviteInfo>
      <Button variant="success">Join</Button>
    </InviteBody>
  </Invite>
</template>

API reference

InviteName

PropType
as?React.ElementType (React) / string | Component (Vue)

The element or component to render. Pass a router link, such as `NuxtLink` or `RouterLink`, to keep client-side navigation.

TypeReact.ElementType (React) / string | Component (Vue)
Default"a"

InviteIcon

PropType
as?React.ElementType (React) / string | Component (Vue)

The image element or component to render. Pass your framework's image component, such as `NuxtImg`, for optimised sources.

TypeReact.ElementType (React) / string | Component (Vue)
Default"img"

InviteCount

PropType
online?boolean | undefined

Green dot for the online count, muted for the member total.

Typeboolean | undefined

The registry exports Invite, InviteEyebrow, InviteBody, InviteIcon, InviteInfo, InviteName, InviteCounts, InviteCount. Parts without a table accept the native attributes for the element they render; React uses className, while Vue uses class and fallthrough attributes.

Accessibility

Use descriptive alternative text for a meaningful server image and an empty alt for a decorative one. The join action must remain a real button.

Tokens

Invite reads its colours, radii and motion from the --newt-* tokens installed with the library. Override a token and every component that reads it follows, including this one — see the token layer. In the plain HTML and CSS distribution the same component is newt-invite.

  • --newt-radius-md
  • --newt-bg-surface
  • --newt-text-primary
  • --newt-text-muted
  • --newt-radius-full
  • --newt-offline
  • --newt-online