Siteplane UI

Social Button

Sign in with Google, Facebook, Apple, X, Figma or Dribbble on a button that shows the provider's logo, in its brand color or neutral.

Markdown
"use client";

import { SocialButton } from "@/siteplane/components/social-button";

export default function Example() {
  return (
    <div className="flex w-full max-w-sm flex-col gap-3">
      <SocialButton social="google">Sign in with Google</SocialButton>
      <SocialButton social="facebook">Sign in with Facebook</SocialButton>
      <SocialButton social="apple">Sign in with Apple</SocialButton>
    </div>
  );
}

Installation

pnpm dlx shadcn@4.18.0 add @siteplane/social-button

Complete the one-time setup first. Registry JSON lists source files and dependencies.

Usage

import { SocialButton } from "@/siteplane/components/social-button";

<SocialButton social="google">Sign in with Google</SocialButton>;

Providers and themes

social picks the provider: google, facebook, apple, x, figma or dribbble. theme sets how it shows:

  • brand, the default, fills the button with the provider’s color and a white logo: blue for Facebook, pink for Dribbble and black for Apple, X and Figma, in light and dark themes. The Figma logo keeps its colors on black, and Google’s button stays neutral with its colored logo.
  • color is the default button with the logo in its full colors. The Apple and X logos take the text color.
  • gray is the default button with the logo in a muted gray, for a page where brand colors would compete, such as beside an email form.
"use client";

import { SocialButton } from "@/siteplane/components/social-button";

export default function Example() {
  return (
    <div className="flex w-full flex-wrap justify-center gap-6">
      <div className="flex w-full max-w-xs flex-col gap-3">
        <SocialButton social="google" theme="color">
          Sign in with Google
        </SocialButton>
        <SocialButton social="facebook" theme="color">
          Sign in with Facebook
        </SocialButton>
        <SocialButton social="apple" theme="color">
          Sign in with Apple
        </SocialButton>
      </div>
      <div className="flex w-full max-w-xs flex-col gap-3">
        <SocialButton social="google" theme="gray">
          Sign in with Google
        </SocialButton>
        <SocialButton social="facebook" theme="gray">
          Sign in with Facebook
        </SocialButton>
        <SocialButton social="apple" theme="gray">
          Sign in with Apple
        </SocialButton>
      </div>
    </div>
  );
}

In a column, as above, every button takes the full width of the column and centers its logo and label.

Icon only

Without children, the button shows the logo alone in a square of its size. In a grid, width="full" lets each of these buttons fill its cell and keeps its height. Screen readers hear “Sign in with” and the provider, such as “Sign in with Google”. Set aria-label when the button does something else, such as “Sign up with Google”.

"use client";

import { SocialButton } from "@/siteplane/components/social-button";

const providers = [
  "google",
  "facebook",
  "apple",
  "x",
  "figma",
  "dribbble",
] as const;

export default function Example() {
  return (
    <div className="flex flex-col gap-3">
      {(["brand", "color", "gray"] as const).map((theme) => (
        <div className="flex flex-wrap gap-3" key={theme}>
          {providers.map((social) => (
            <SocialButton key={social} social={social} theme={theme} />
          ))}
        </div>
      ))}
    </div>
  );
}

Sizes

Omit size to use the control size from SiteplaneUIProvider (sm without a provider), so the button is as high as a Button or a field beside it. sm and md are 36 and 40 px high with a 14 px label and a 16 px logo, lg and xl 44 and 48 px with a 16 px label and a 20 px logo. An icon button is the square of its size.

Start the sign-in

SocialButton starts no sign-in by itself. Call your authentication library in onClick, or render a link to your sign-in route with render:

<SocialButton render={<a href="/auth/google" />} social="google">
  Sign in with Google
</SocialButton>

Keyboard focus, hover, press and disabled work as on Button. Disable the button while a sign-in is pending.

API reference

Component properties
PropTypeDefaultDescription
SocialButton.social"google" | "facebook" | "apple" | "x" | "figma" | "dribbble"requiredThe provider, which picks the logo and the brand color.
SocialButton.theme"brand" | "color" | "gray""brand"brand fills the button with the provider’s color, color shows the full-color logo on the default button, gray shows a muted logo.
SocialButton.size"sm" | "md" | "lg" | "xl"provider / smsm and md are 36 and 40 px high with a 16 px logo, lg and xl 44 and 48 px with a 20 px logo.
SocialButton.childrenReactNodeunsetThe label after the logo. Without one, the button shows the logo alone in a square.
SocialButton.aria-labelstring“Sign in with” and the providerThe name of a button that shows the logo alone.

SocialButtonProps extends the Button props except variant, size, shape, profile, profileTone, multiline and loading, and accepts a ref. disabled, width, className, onClick and render work as on Button. The root carries data-social and data-social-theme. The types SocialButtonProvider, SocialButtonTheme and SocialButtonSize are exported.

Read the installed source.

Usage notes

Provider names and logos are trademarks of their owners. Check each provider’s branding rules before you ship, for the wording of the label, such as Sign in with or Continue with, and for the look they allow on your background.

Offer the same providers on the sign-in and the sign-up page, in the same order.