# Login

> The sign-in page. A brand hero of chapters sits beside the form, which is signed "from Sosialoka".

Every Sosialoka product signs people in on the same page, which makes it the first place they see that the products are one family. The left side tells the product's story in short chapters. The right side holds the form, and the form is the same in every product.

## When to use

- Use it for sign in, sign up and password reset in a web app.
- Keep each product's own chapters, art and logo. Don't change the form layout or the footer.

_Live preview of the React and Vue versions: https://design.sosialoka.tech/patterns/login/_

## Anatomy

1. **Hero** (from `lg` up): autoplaying chapters on `brand-ground`. Each chapter has art, a title in the brand display font and one lead sentence. Progress bars and a pause button sit at the bottom.
2. **Form**: the product logo, a heading, the fields and one primary action.
3. **Footer**: "from [mark] Sosialoka" under the form.

## Rules

- **Columns:** the hero is hidden below `lg`. It takes half the page at `lg` and two thirds at `xl`.
- **One primary action:** the submit button ("Masuk"). "Forgot password" and "Sign up" are links.
- **Copy:** a chapter title is one idea in about eight words. The lead is one sentence. Write Indonesian copy with "kamu", as everywhere in Sosialoka.
- **Color:** the hero uses `brand-ground` and `brand-ground-foreground`. Token tests check that pair for 4.5:1 contrast. A chapter that sets its own `ground` must also set an `ink` that passes 4.5:1 on it.
- **Mark:** pass the Sosialoka mark as `markSrc`. Download it from [Brand](https://design.sosialoka.tech/brand/).

### Motion

| What | Duration | Easing |
| --- | --- | --- |
| A chapter on screen | `duration-chapter` (7 s) | linear progress bar |
| Next chapter rises as a sheet | `duration-sheet` (1050 ms) | `ease-in-out` |
| Title words rise one by one | 900 ms, from 420 ms + 40 ms per word | `ease-expo` |
| Lead fades in | `duration-slow` (700 ms), from 780 ms | `ease-standard` |

- The next chapter starts when the active progress bar finishes, so anything that pauses the bar holds the chapter.
- Hover or focus inside the hero holds only the chapter being read.
- The pause button and a hidden browser tab stop every animation in the hero.
- With `prefers-reduced-motion`, the movement stops but chapters still change, with a short fade.

## Props

| React | Vue | Flutter | Type | Default | Use |
| --- | --- | --- | --- | --- | --- |
| `slides` | `slides` | `_LoginHero` | `{ title, lead, art?, ground?, ink? }[]` | none | The chapters. In Vue, art comes from the `art` slot (`{ slide, index }`). |
| `logo` | `#logo` slot | widget | element | none | The product logo above the form. |
| `markSrc` | `mark-src` | `Image` | string | none | The Sosialoka mark in the footer. |
| `labels` | `labels` | `Text` | `{ hero, pause, play, chapter, from }` | English | Text for screen readers and the footer. `chapter` takes `{n}` and `{title}`. The example passes Indonesian. |
| `children` | default slot | `_LoginForm` | element | none | The form. |

## Code

**React**
```tsx
import { CheckIcon, DiscIcon, LinkIcon, PenLineIcon } from "lucide-react"
import { LoginSplit, type LoginSlide } from "@/components/blocks/login-split"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"

/** A chapter illustration: a small product card drawn with tokens. */
function Scene({ icon: Icon, title, meta }: { icon: typeof DiscIcon; title: string; meta: string }) {
  return (
    <div className="flex w-72 items-center gap-3 rounded-xl bg-card p-4 text-card-foreground shadow-lg">
      <span className="grid size-10 place-items-center rounded-lg bg-primary-soft text-primary-text">
        <Icon className="size-5" />
      </span>
      <span className="grid gap-0.5">
        <span className="text-sm font-semibold">{title}</span>
        <span className="text-xs text-muted-foreground">{meta}</span>
      </span>
    </div>
  )
}

const slides: LoginSlide[] = [
  {
    title: "Rilis musikmu ke seluruh dunia.",
    lead: "Kirim lagu ke layanan streaming dari satu tempat.",
    art: <Scene icon={DiscIcon} title="Senja di Kota" meta="Terkirim ke 32 platform" />,
  },
  {
    title: "Cover lagu favoritmu tanpa takut copyright strike.",
    lead: "Kami urus izinnya, kamu fokus berkarya.",
    art: <Scene icon={CheckIcon} title="Izin cover disetujui" meta="Kaset Pertama · 2 menit lalu" />,
  },
  {
    title: "Tanda tangan dokumen di mana saja.",
    lead: "Kirim, tanda tangani, dan simpan perjanjian secara online.",
    art: <Scene icon={PenLineIcon} title="Perjanjian rilis" meta="Ditandatangani 2 dari 2 pihak" />,
  },
  {
    title: "Semua link musikmu di satu tempat.",
    lead: "Satu halaman untuk lagu, video, dan jadwal manggungmu.",
    art: <Scene icon={LinkIcon} title="Halaman artis" meta="1.204 kunjungan minggu ini" />,
  },
]

export default function LoginSplitDemo() {
  return (
    <LoginSplit
      slides={slides}
      markSrc="/brand/sosialoka.png"
      labels={{ hero: "Sorotan produk", pause: "Jeda", play: "Putar", chapter: "Bab {n}: {title}" }}
      logo={
        <span className="flex items-center gap-2 font-semibold">
          <span className="size-7 rounded-md bg-primary" />
          Produkmu
        </span>
      }
    >
      <form className="grid gap-6" onSubmit={(e) => e.preventDefault()}>
        <div className="grid gap-1">
          <h1 className="text-2xl font-semibold">Masuk ke akunmu</h1>
          <p className="text-sm text-muted-foreground">Senang ketemu lagi.</p>
        </div>
        <div className="grid gap-2">
          <Label htmlFor="login-email">Email</Label>
          <Input id="login-email" type="email" autoComplete="email" />
        </div>
        <div className="grid gap-2">
          <div className="flex items-center justify-between">
            <Label htmlFor="login-password">Kata sandi</Label>
            <a href="#" className="text-sm text-primary-text underline-offset-4 hover:underline">
              Lupa kata sandi?
            </a>
          </div>
          <Input id="login-password" type="password" autoComplete="current-password" />
        </div>
        <Button type="submit" className="w-full">
          Masuk
        </Button>
        <p className="text-center text-sm text-muted-foreground">
          Belum punya akun?{" "}
          <a href="#" className="font-medium text-primary-text underline-offset-4 hover:underline">
            Daftar
          </a>
        </p>
      </form>
    </LoginSplit>
  )
}
```

**Vue**
```vue
<script setup lang="ts">
import { Check, Disc, Link, PenLine } from "@lucide/vue"
import { LoginSplit, type LoginSlide } from "@/components/blocks/login-split"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"

/** Each chapter's illustration: a small product card drawn with tokens. */
const scenes = [
  { icon: Disc, title: "Senja di Kota", meta: "Terkirim ke 32 platform" },
  { icon: Check, title: "Izin cover disetujui", meta: "Kaset Pertama · 2 menit lalu" },
  { icon: PenLine, title: "Perjanjian rilis", meta: "Ditandatangani 2 dari 2 pihak" },
  { icon: Link, title: "Halaman artis", meta: "1.204 kunjungan minggu ini" },
]

const slides: LoginSlide[] = [
  { title: "Rilis musikmu ke seluruh dunia.", lead: "Kirim lagu ke layanan streaming dari satu tempat." },
  { title: "Cover lagu favoritmu tanpa takut copyright strike.", lead: "Kami urus izinnya, kamu fokus berkarya." },
  { title: "Tanda tangan dokumen di mana saja.", lead: "Kirim, tanda tangani, dan simpan perjanjian secara online." },
  { title: "Semua link musikmu di satu tempat.", lead: "Satu halaman untuk lagu, video, dan jadwal manggungmu." },
]
const labels = { hero: "Sorotan produk", pause: "Jeda", play: "Putar", chapter: "Bab {n}: {title}" }
</script>

<template>
  <LoginSplit :slides="slides" mark-src="/brand/sosialoka.png" :labels="labels">
    <template #logo>
      <span class="flex items-center gap-2 font-semibold">
        <span class="size-7 rounded-md bg-primary" />
        Produkmu
      </span>
    </template>

    <template #art="{ index }">
      <div class="flex w-72 items-center gap-3 rounded-xl bg-card p-4 text-card-foreground shadow-lg">
        <span class="grid size-10 place-items-center rounded-lg bg-primary-soft text-primary-text">
          <component :is="scenes[index]!.icon" class="size-5" />
        </span>
        <span class="grid gap-0.5">
          <span class="text-sm font-semibold">{{ scenes[index]!.title }}</span>
          <span class="text-xs text-muted-foreground">{{ scenes[index]!.meta }}</span>
        </span>
      </div>
    </template>

    <form class="grid gap-6" @submit.prevent>
      <div class="grid gap-1">
        <h1 class="text-2xl font-semibold">Masuk ke akunmu</h1>
        <p class="text-sm text-muted-foreground">Senang ketemu lagi.</p>
      </div>
      <div class="grid gap-2">
        <Label for="login-email-vue">Email</Label>
        <Input id="login-email-vue" type="email" autocomplete="email" />
      </div>
      <div class="grid gap-2">
        <div class="flex items-center justify-between">
          <Label for="login-password-vue">Kata sandi</Label>
          <a href="#" class="text-sm text-primary-text underline-offset-4 hover:underline">Lupa kata sandi?</a>
        </div>
        <Input id="login-password-vue" type="password" autocomplete="current-password" />
      </div>
      <Button type="submit" class="w-full">Masuk</Button>
      <p class="text-center text-sm text-muted-foreground">
        Belum punya akun?
        <a href="#" class="font-medium text-primary-text underline-offset-4 hover:underline">Daftar</a>
      </p>
    </form>
  </LoginSplit>
</template>
```

**Flutter**
```dart
// Flutter has no registry blocks: build the login pattern from widgets with the Sosialoka theme.
// The hero sits beside the form only on wide screens (from 1024 logical px, like lg on the web);
// on phones the form stands alone. Colors come from brand-ground and brand-ground-foreground.
import 'package:flutter/widgets.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:sosialoka_ui/sosialoka_ui.dart';

class LoginSplitDemo extends StatelessWidget {
  const LoginSplitDemo({super.key, this.heroFrom = 1024, this.height = 560});

  /// The narrowest width that shows the hero.
  final double heroFrom;
  final double height;

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: height,
      child: LayoutBuilder(
        builder: (context, constraints) {
          final form = _LoginForm();
          if (constraints.maxWidth < heroFrom) return form;
          return Row(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              const Expanded(child: _LoginHero()),
              Expanded(child: form),
            ],
          );
        },
      ),
    );
  }
}

class _LoginHero extends StatelessWidget {
  const _LoginHero();

  @override
  Widget build(BuildContext context) {
    final c = context.sosialoka;
    final text = ShadTheme.of(context).textTheme;
    return ColoredBox(
      color: c.brandGround,
      child: Padding(
        padding: const EdgeInsets.all(48),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            Text('Rilis musikmu ke seluruh dunia.', style: text.h1Large.copyWith(color: c.brandGroundForeground)),
            const SizedBox(height: 16),
            Text(
              'Kirim lagu ke layanan streaming dari satu tempat.',
              style: text.large.copyWith(color: c.brandGroundForeground),
            ),
          ],
        ),
      ),
    );
  }
}

class _LoginForm extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final theme = ShadTheme.of(context);
    return Padding(
      padding: const EdgeInsets.all(24),
      child: Column(
        children: [
          Expanded(
            child: Center(
              child: ConstrainedBox(
                constraints: const BoxConstraints(maxWidth: 384),
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: [
                    Text('Masuk ke akunmu', style: theme.textTheme.h3),
                    const SizedBox(height: 24),
                    ShadInputFormField(
                      id: 'email',
                      label: const Text('Email'),
                      keyboardType: TextInputType.emailAddress,
                    ),
                    const SizedBox(height: 16),
                    ShadInputFormField(id: 'password', label: const Text('Kata sandi'), obscureText: true),
                    const SizedBox(height: 24),
                    ShadButton(onPressed: () {}, child: const Text('Masuk')),
                    ShadButton.link(onPressed: () {}, child: const Text('Lupa kata sandi?')),
                  ],
                ),
              ),
            ),
          ),
          Text('from Sosialoka', style: theme.textTheme.muted),
        ],
      ),
    );
  }
}
```

## Install

**React**
```bash
npx shadcn@latest add https://design.sosialoka.tech/r/react/login-split.json
```

**Vue**
```bash
npx shadcn-vue@latest add https://design.sosialoka.tech/r/vue/login-split.json
```

The block lands in `components/blocks/`. It brings its own keyframes, so you don't need any global CSS.

## Flutter

Flutter has no blocks. The Flutter code builds the same page from widgets. Show the hero only from 1024 logical pixels, so on phones the form stands alone. The chapter motion is optional in Flutter. A single still chapter is fine.

## Accessibility

- The hero is a carousel (`aria-roledescription="carousel"`). Each chapter bar is a button named "Bab 1: …", and the active one has `aria-current`.
- The whole title is read once. The animated words are hidden from screen readers.
- The pause button uses `aria-pressed`, and its name switches between "Pause" and "Play" (`labels.pause` and `labels.play`).
