第三方登录按钮
24 个提供商以及定制品牌的登录按钮。品牌命名将其徽标、颜色和可访问标签一起提供,因此它们的堆叠不会分散。默认情况下呈现一个按钮,或者在给定 href 时呈现一个锚点,因为 OAuth 启动是一个导航。
CLI 将组件源(及其内部依赖项)复制到您的项目中并安装任何所需的 npm 包。
npx boardui@latest add social-button使用共享 UI 包或自定义导入别名? 配置您的安装路径 在运行 CLI 之前。复制粘贴示例使用默认导入。
品牌
所有 24 个徽标均随组件内联提供,因此安装不会提取任何图标包。全彩标记来自 SVG Logos (CC0),单色字形来自 Simple Icons (CC0),Simple Icons 不再使用 Bootstrap Icons (MIT) 的四个品牌。亚马逊上游没有全彩标记,所以根据 white 它又回到了带有品牌色彩的字形。
type SocialBrand = | "google" | "apple" | "github" | "gitlab" | "microsoft" | "x" | "facebook" | "linkedin" | "discord" | "slack" | "figma" | "notion" | "dropbox" | "spotify" | "twitch" | "reddit" | "tiktok" | "instagram" | "telegram" | "whatsapp" | "amazon" | "bitbucket" | "auth0" | "okta" | "custom";外观
colorful 是默认值:品牌自己的颜色与主按钮具有相同的渐变和阴影配方,因此它读取为 BoardUI 控件而不是粘贴的小部件。 black 是高对比度实体中的相同形状。 white 被概述,并且是唯一一个显示每个提供者的真实多色标记的,因为在饱和填充上,艺术品将与背景形成对比。对于多个提供商的堆栈,更喜欢 white:一列竞争品牌填充使得没有任何一个选项可读。
{/* Colorful: the brand colour in the primary Button's gradient (default) */}<SocialButton brand="google" appearance="colorful" />
{/* Black: the same shape in high-contrast solid */}<SocialButton brand="google" appearance="black" />
{/* White: outlined, and the one that shows the real multi-colour mark */}<SocialButton brand="google" appearance="white" />尺寸
medium (36 像素)和 small(32px) 是基本按钮自身的大小,包括像素、半径和字形大小,因此它们位于按钮旁边的表单中,节奏中没有半步。两者都有固定的宽度(300px 和 250px),因此一列提供者自行排列; fullWidth 将其放回容器中。
<SocialButton brand="slack" size="medium" /> {/* 36px, like Button medium */}<SocialButton brand="slack" size="small" /> {/* 32px, like Button small */}
{/* Drop the fixed width when the container should decide */}<SocialButton brand="slack" fullWidth />仅图标
仅显示徽标的方形按钮,用于电子邮件字段下的一行替代项。品牌名称移至 aria-label,因此控件仍然会自行声明。
<SocialButton brand="google" appearance="white" iconOnly /><SocialButton brand="apple" appearance="white" iconOnly /><SocialButton brand="github" appearance="white" iconOnly />
{/* The brand name stays as the accessible name when the label is hidden */}定制品牌
对于非内置的身份提供者,通过 brand="custom" 与一个 config。仅 图标 需要: label 默认为 SSO 和 颜色 至黑色。
import { RiShieldKeyholeLine } from "@remixicon/react";
<SocialButton brand="custom" config={{ icon: <RiShieldKeyholeLine className="size-5" />, label: "Okta SSO", color: "#0f172a", }}/>
{/* label defaults to "SSO" and color to black */}<SocialButton brand="custom" config={{ icon: <RiShieldKeyholeLine className="size-5" /> }} />标签
默认标签是 继续<Brand>。让子内容说些别的东西,因为注册屏幕和登录屏幕通常需要不同的措辞。
<SocialButton brand="google" /> {/* Continue with Google */}<SocialButton brand="google">Sign up with Google</SocialButton><SocialButton brand="google">Log in</SocialButton>按钮和链接
路过 href 呈现锚点而不是按钮。大多数 OAuth 流程都是从导航到提供商 URL 开始的,锚点免费提供正确的语义、中键单击和键盘行为。
{/* An OAuth start is a navigation, so pass href and get an anchor */}<SocialButton brand="github" href="/api/auth/github" />
{/* Otherwise it is a button */}<SocialButton brand="github" onClick={() => signIn("github")} />商标
这些徽标是其各自所有者的商标,包含在此处,以便您可以构建登录屏幕。一些提供商发布了其登录按钮的规则,包括颜色、空白空间和措辞,尤其是谷歌和苹果,因此在交付生产登录之前请检查这些规则。