Skip to main content

<SignInButton />

The SignInButton component initiates the sign-in 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 SignInButton in two main ways: as a simple button or with render props for more control over the UI and behavior.

Basic Usage​

Use SignInButton as a simple button to trigger sign-in.

src/App.jsx
import { SignInButton } from '@asgardeo/react'

function App() {
return <SignInButton />
}

export default App
note

You can simply use the SignInButton component without any children <SignInButton /> to render a default button with the text "Sign In".

Props​

The SignInButton component accepts all props from BaseSignInButton, plus:

PropTypeRequiredDescription
childrenReactNode or function❌Render prop function or ReactNode for button content
preferencesPreferences❌Customization options for i18n, theming, etc.
onClickfunction❌Callback after sign-in is triggered

Customization​

The SignInButton 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.

src/App.jsx
import { SignInButton } from '@asgardeo/react'

function App() {
return (
<SignInButton className="custom-sign-in-button">
Sign In
</SignInButton>
)
}

export default App

Default CSS Classes​

The button includes a default vendor-prefixed class for targeting:

  • .asgardeo-sign-in-button – Main sign-in button element

CSS Custom Properties (CSS Variables)​

You can theme the button and other SDK components using CSS variables:

index.css
: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:

src/App.jsx
import { SignInButton } from '@asgardeo/react'

function App() {
return (
<SignInButton
preferences={{
i18n: {
language: 'fr-FR',
fallbackLanguage: 'en-US',
bundles: {
'fr-FR': {
translations: {
'elements.buttons.signIn': 'Connexion personnalisΓ©e'
}
}
}
}
}}
>
Sign In
</SignInButton>
)
}

export default App

Render Props for Custom UI​

You can customize the button UI and behavior using render props. This allows you to access the signIn function and isLoading state directly, giving you the flexibility to use any library like Tailwind CSS, Shadcn UI, Material-UI, etc.

src/App.jsx
import { SignInButton } from '@asgardeo/react'

function App() {
return (
<SignInButton>
{({ signIn, isLoading }) => (
<button
onClick={signIn}
disabled={isLoading}
className="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-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="M16 17l5-5m0 0l-5-5m5 5H9" />
<path d="M19 12a7 7 0 11-14 0 7 7 0 0114 0z" />
</svg>
{isLoading ? 'Signing in...' : 'Sign In'}
</button>
)}
</SignInButton>
)
}

export default App

Error Handling​

If sign-in fails, an AsgardeoRuntimeError is thrown with a descriptive message.

Β© 2026 Thunder. All rights reserved.
Terms & ConditionsPrivacy Policy