<SignUpButton />
The SignUpButton component triggers the sign-up (registration) flow when clicked. It automatically handles loading state, error handling, and supports custom UI via render props or direct children. You can customize its behavior and appearance using the preferences prop, including i18n overrides.
Usageβ
You can use the SignUpButton in two main ways: as a simple button or with render props for more control over the UI and behavior.
Basic Usageβ
Use SignUpButton as a simple button to trigger sign-up.
import { SignUpButton } from '@asgardeo/react'
function LandingPage() {
return <SignUpButton />
}
export default LandingPage
You can simply use the SignUpButton component without any children <SignUpButton /> to render a default button with the text "Sign Up".
Propsβ
The SignUpButton component accepts all props from BaseSignUpButton, plus:
| Prop | Type | Required | Description |
|---|---|---|---|
children | ReactNode or function | β | Render prop function or ReactNode for button content |
preferences | Preferences | β | Customization options for i18n, theming, etc. |
onClick | function | β | Callback after sign-up is triggered |
redirectUrl | string | β | URL to redirect to after sign-up |
mode | 'redirect' | 'modal' | β | Sign-up mode |
className | string | β | CSS class name |
style | CSSProperties | β | Inline styles |
disabled | boolean | β | Disable the button |
Customizationβ
The SignUpButton component is designed for easy customization to fit your application's design system.
CSS Classes and Stylingβ
You can use the className prop to apply custom CSS classes to the button.
import { SignUpButton } from '@asgardeo/react'
function LandingPage() {
return (
<SignUpButton className="custom-sign-up-button">
Sign Up
</SignUpButton>
)
}
export default LandingPage
Default CSS Classesβ
The button includes a default vendor-prefixed class for targeting:
.asgardeo-sign-up-buttonβ Main sign-up button element
CSS Custom Properties (CSS Variables)β
You can theme the button and other SDK components using CSS variables:
:root {
--asgardeo-primary-color: #007bff;
--asgardeo-primary-hover: #0056b3;
--asgardeo-border-radius: 8px;
--asgardeo-font-family: 'Inter', sans-serif;
--asgardeo-button-padding: 12px 24px;
}
Internationalization (i18n)β
Override button text and translations using the preferences prop:
import { SignUpButton } from '@asgardeo/react'
function LandingPage() {
return (
<SignUpButton
preferences={{
i18n: {
language: 'fr-FR',
fallbackLanguage: 'en-US',
bundles: {
'fr-FR': {
translations: {
'elements.buttons.signUp': 'Inscription personnalisΓ©e'
}
}
}
}
}}
>
Sign Up
</SignUpButton>
)
}
export default LandingPage
Render Props for Custom UIβ
You can customize the button UI and behavior using render props. This allows you to access the signUp function and isLoading state directly, giving you the flexibility to use any library like Tailwind CSS, Shadcn UI, Material-UI, etc.
import { SignUpButton } from '@asgardeo/react'
function LandingPage() {
return (
<SignUpButton>
{({ signUp, isLoading }) => (
<button
onClick={signUp}
disabled={isLoading}
className="px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700 transition disabled:opacity-50 flex items-center gap-2"
>
<svg
className="w-4 h-4"
fill="none"
stroke="currentColor"
strokeWidth={2}
viewBox="0 0 24 24"
>
<path d="M12 4v16m8-8H4" />
</svg>
{isLoading ? 'Signing up...' : 'Sign Up'}
</button>
)}
</SignUpButton>
)
}
export default LandingPage
Error Handlingβ
If sign-up fails, an AsgardeoRuntimeError is thrown with a descriptive message.