Parameters
| Parameter | Type | Description |
|---|---|---|
props | AuthButtonProps & Omit<HTMLAttributes<HTMLDivElement>, "children"> | The props for the component. |
Returns
Element
The rendered component.
function AuthButton(props: AuthButtonProps & Omit<HTMLAttributes<HTMLDivElement>, "children">): Element;
| Parameter | Type | Description |
|---|---|---|
props | AuthButtonProps & Omit<HTMLAttributes<HTMLDivElement>, "children"> | The props for the component. |
Element
The rendered component.
// Render the AuthButton component
function App() {
return (
<CDPReactProvider config={config} theme={themeOverrides}>
<AuthButton />
</CDPReactProvider>
);
}
// Render the AuthButton component with custom components
// Define a custom placeholder
const SmallPlaceholder: AuthButtonProps["placeholder"] = props => (
<LoadingSkeleton {...props} className={`${props.className} small-placeholder`} />
);
// Define a custom sign in modal using the secondary variant and small size for the trigger button
const SmallSecondarySignInModal: AuthButtonProps["signInModal"] = props => (
<SignInModal {...props}>
<SignInModalTrigger variant="secondary" size="sm" label="Log me in" />
</SignInModal>
);
// Define a custom sign out button using the secondary variant and small size
const SmallSecondarySignOutButton: AuthButtonProps["signOutButton"] = props => (
<SignOutButton {...props} variant="secondary" size="sm">Log me out</SignOutButton>
);
function App() {
return (
<CDPReactProvider config={config} theme={themeOverrides}>
<AuthButton
placeholder={SmallPlaceholder}
signInModal={SmallSecondarySignInModal}
signOutButton={SmallSecondarySignOutButton}
/>
</CDPReactProvider>
);
}
// Render the AuthButton component with custom containers around the slot content
function App() {
return (
<CDPReactProvider config={config} theme={themeOverrides}>
<AuthButton className="auth-wrapper">
{({ isInitialized, isSignedIn, Placeholder, SignOutButton, SignInModal }) => (
<>
{!isInitialized && Placeholder}
{isInitialized && (
<div>
<p>Hello {isSignedIn ? "signed in" : "signed out"} user!</p>
{isSignedIn && <div>{SignOutButton}</div>}
{!isSignedIn && <div>{SignInModal}</div>}
</div>
)}
</>
)}
</AuthButton>
</CDPReactProvider>
);
}
Was this page helpful?