@lukasrosario/account-ui
Version:
Base Account UI Components
139 lines (106 loc) • 3.11 kB
Markdown
This guide covers how to use Base Account UI components in Preact applications.
```bash
npm install @base-org/account-ui
```
```tsx
import { SignInWithBaseButton } from '@base-org/account-ui/preact';
function App() {
return (
<SignInWithBaseButton
onClick={() => console.log('Sign in clicked!')}
align="center"
variant="solid"
colorScheme="light"
/>
);
}
```
```tsx
import { SignInWithBaseButton } from '@base-org/account-ui/preact';
function VariantExamples() {
return (
<div>
{/* Solid variant */}
<SignInWithBaseButton
onClick={() => console.log('Solid clicked')}
variant="solid"
colorScheme="light"
/>
{/* Transparent variant */}
<SignInWithBaseButton
onClick={() => console.log('Transparent clicked')}
variant="transparent"
colorScheme="dark"
/>
{/* Left aligned */}
<SignInWithBaseButton
onClick={() => console.log('Left aligned clicked')}
align="left"
variant="solid"
/>
</div>
);
}
```
```tsx
import { BasePayButton } from '@base-org/account-ui/preact';
function App() {
return (
<BasePayButton
onClick={() => console.log('Pay with Base clicked!')}
colorScheme="light"
/>
);
}
```
```tsx
import { BasePayButton } from '@base-org/account-ui/preact';
function ColorSchemeExamples() {
return (
<div>
{/* Light mode */}
<BasePayButton
onClick={() => console.log('Light mode clicked')}
colorScheme="light"
/>
{/* Dark mode */}
<BasePayButton
onClick={() => console.log('Dark mode clicked')}
colorScheme="dark"
/>
{/* System theme (adapts to user's preference) */}
<BasePayButton
onClick={() => console.log('System theme clicked')}
colorScheme="system"
/>
</div>
);
}
```
Preact applications work out of the box with this package. This package uses Preact as the base implementation, so it has the smallest bundle size for Preact applications.
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `align` | `'left' \| 'center'` | `'center'` | Button alignment |
| `variant` | `'solid' \| 'transparent'` | `'solid'` | Button style variant |
| `colorScheme` | `'light' \| 'dark' \| 'system'` | `'system'` | Color theme |
| `onClick` | `() => void` | `undefined` | Click handler |
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `colorScheme` | `'light' \| 'dark' \| 'system'` | `'system'` | Color theme |
| `onClick` | `() => void` | `undefined` | Click handler |
Since this package uses Preact as the base implementation, Preact applications get the most optimized bundle size.