Sign up

A sign-up form: name, email and a new password with its strength meter, the terms, and two "continue with" buttons. Server validation lands under each field and, when there is more than one problem, in a summary at the top that links to each; once the account exists, the same view says "check your inbox".

Sign up, light and dark

Sign up on a phone, light and dark

A block, not a component: copy the view below into your app. It assumes the base layout, which loads Alpine and the package's script.

What it shows

  • The form: autocomplete on every field (name, email, new-password), the password's Show button (reveal) and the strength meter under it.

  • One error: the message under its field, which is marked invalid and described by it. The name and email come back as typed; the password does not, as Laravel never flashes it.

  • Several errors: a danger alert at the top that takes focus when the page opens and lists each problem as a link to its field.

    Sign up with four errors, light and dark

  • Check your inbox: after the account is made, the same view with $sentTo says where the link went and offers to send it again, with a success alert once it has.

    Check your inbox, light and dark

  • Continue with: Harbor ID and Quayside stand for your identity providers. They are buttons with words, not logos: the words are what a screen reader and a translator need, and a logo can be added in the slot next to them.

Built from

  • Panel: the card
  • Input: name, email, and the password with reveal
  • Password strength: the meter
  • Checkbox: the terms
  • Alert: the error summary and "we sent a new link"
  • Button: Create account, the providers, Send the link again
  • Link: the error summary's links, Sign in, and the legal links
  • Divider: "Or continue with", and above Send the link again
  • Icon: the brand mark and the envelope

The markup

resources/views/auth/sign-up.blade.php

{{--
    Sign up, and the "check your inbox" panel Laravel's email verification
    notice shows the new account: $sentTo is its address.
--}}
<x-layouts.base :title="isset($sentTo) ? 'Check your inbox' : 'Create your account'">
    <div class="flex min-h-dvh flex-col items-center px-4 py-10 sm:py-16">
        <header class="mb-8 flex items-center gap-2.5">
            <span class="flex size-9 items-center justify-center rounded-control bg-surface-inverse text-on-inverse">
                <x-ds::icon name="cube-transparent" size="5" />
            </span>
            <span class="text-title text-fg">Pebblework</span>
        </header>

        <main class="w-full max-w-md">
            <x-ds::panel body="plain">
                @isset($sentTo)
                    <span class="flex size-10 items-center justify-center rounded-control bg-success-tint text-on-success-tint">
                        <x-ds::icon name="envelope" size="5" />
                    </span>
                    <h1 class="mt-4 text-heading text-fg">Check your inbox</h1>
                    <p class="mt-1 text-body text-fg-muted">
                        We sent a link to <strong class="font-medium text-fg">{{ $sentTo }}</strong>.
                        Open it to finish creating your account. It works for 60 minutes.
                    </p>

                    @if (session('status') === 'verification-link-sent')
                        <x-ds::alert tone="success" class="mt-5">We sent a new link. The one before it no longer works.</x-ds::alert>
                    @endif

                    <x-ds::divider class="mt-6 mb-5" />

                    <form method="POST" action="{{ route('verification.send') }}">
                        @csrf
                        <p class="text-body text-fg-muted">Nothing there? Check your spam folder first.</p>
                        <x-ds::button type="submit" variant="secondary" size="sm" class="mt-3">Send the link again</x-ds::button>
                    </form>
                @else
                    <h1 class="text-heading text-fg">Create your account</h1>
                    <p class="mt-1 text-body text-fg-muted">Free for teams of up to five. No card needed.</p>

                    @if ($errors->count() > 1)
                        <x-ds::alert tone="danger" title="Check {{ $errors->count() }} things before we can create your account" class="mt-5" tabindex="-1" autofocus>
                            <ul class="mt-1 list-disc ps-4">
                                @foreach (['name', 'email', 'password', 'terms'] as $field)
                                    @error($field)
                                        <li>
                                            <x-ds::link href="#{{ $field }}" variant="danger">{{ $message }}</x-ds::link>
                                        </li>
                                    @enderror
                                @endforeach
                            </ul>
                        </x-ds::alert>
                    @endif

                    <form method="POST" action="{{ route('sign-up.store') }}" class="mt-6 flex flex-col gap-5" novalidate>
                        @csrf
                        <x-ds::input
                            id="name"
                            name="name"
                            label="Full name"
                            autocomplete="name"
                            required
                            :value="old('name')"
                            :error="$errors->first('name')"
                        />
                        <x-ds::input
                            id="email"
                            type="email"
                            name="email"
                            label="Work email"
                            autocomplete="email"
                            required
                            :value="old('email')"
                            :error="$errors->first('email')"
                        />
                        <div class="flex flex-col gap-2">
                            <x-ds::input
                                id="password"
                                type="password"
                                name="password"
                                label="Password"
                                autocomplete="new-password"
                                help="At least 8 characters. A short sentence is easy to remember."
                                required
                                :reveal="true"
                                :error="$errors->first('password')"
                            />
                            <x-ds::password-strength for="password" />
                        </div>
                        <x-ds::checkbox
                            id="terms"
                            name="terms"
                            value="1"
                            label="I agree to the terms of service and the privacy policy"
                            help="Both are linked at the foot of this page."
                            :checked="(bool) old('terms')"
                            :error="$errors->first('terms')"
                        />
                        <x-ds::button type="submit" class="w-full">Create account</x-ds::button>
                    </form>

                    <div class="mt-6 flex flex-col gap-2">
                        <x-ds::divider label="Or continue with" class="mb-1" />
                        <x-ds::button variant="secondary" class="w-full" :href="route('oauth.redirect', 'harbor')">Harbor ID</x-ds::button>
                        <x-ds::button variant="secondary" class="w-full" :href="route('oauth.redirect', 'quayside')">Quayside</x-ds::button>
                    </div>

                    <p class="mt-6 text-body text-fg-muted">
                        Already have an account?
                        <x-ds::link :href="route('sign-in')">Sign in</x-ds::link>
                    </p>
                @endisset
            </x-ds::panel>
        </main>

        <footer class="mt-8">
            <nav aria-label="Legal" class="flex gap-4">
                <x-ds::link :href="route('terms')" variant="muted" size="sm">Terms of service</x-ds::link>
                <x-ds::link :href="route('privacy')" variant="muted" size="sm">Privacy policy</x-ds::link>
            </nav>
        </footer>
    </div>
</x-layouts.base>

Wire it up

A Form Request holds the rules and the words; the controller creates the user and leaves the email to Laravel's verification, which also gives the inbox panel its route.

// app/Http/Requests/SignUpRequest.php
namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Password;

class SignUpRequest extends FormRequest
{
    public function rules(): array
    {
        return [
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'email', 'max:255', 'unique:users,email'],
            'password' => ['required', 'string', Password::min(8)->uncompromised()],
            'terms' => ['accepted'],
        ];
    }

    public function messages(): array
    {
        return [
            'name.required' => 'Enter your name.',
            'email.required' => 'Enter your email address.',
            'email.email' => 'Enter an email address like [email protected].',
            'email.unique' => 'There is already an account with this email. Sign in instead.',
            'password.required' => 'Choose a password.',
            'password.min' => 'Use at least 8 characters.',
            'terms.accepted' => 'Agree to the terms to create an account.',
        ];
    }
}
// app/Http/Controllers/Auth/SignUpController.php
namespace App\Http\Controllers\Auth;

use App\Http\Requests\SignUpRequest;
use App\Models\User;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class SignUpController
{
    public function create()
    {
        return view('auth.sign-up');
    }

    public function store(SignUpRequest $request)
    {
        // The default User model casts password as `hashed`.
        $user = User::create($request->safe()->only(['name', 'email', 'password']));

        event(new Registered($user));
        Auth::login($user);

        return to_route('verification.notice');
    }

    public function sent(Request $request)
    {
        return view('auth.sign-up', ['sentTo' => $request->user()->email]);
    }
}
// routes/web.php
use App\Http\Controllers\Auth\SignUpController;
use Illuminate\Foundation\Auth\EmailVerificationRequest;
use Illuminate\Http\Request;

Route::middleware('guest')->group(function () {
    Route::get('/sign-up', [SignUpController::class, 'create'])->name('sign-up');
    Route::post('/sign-up', [SignUpController::class, 'store'])->name('sign-up.store');
});

Route::middleware('auth')->group(function () {
    Route::get('/email/verify', [SignUpController::class, 'sent'])->name('verification.notice');

    Route::get('/email/verify/{id}/{hash}', function (EmailVerificationRequest $request) {
        $request->fulfill();

        return redirect('/');
    })->middleware('signed')->name('verification.verify');

    Route::post('/email/verification-notification', function (Request $request) {
        $request->user()->sendEmailVerificationNotification();

        return back()->with('status', 'verification-link-sent');
    })->middleware('throttle:6,1')->name('verification.send');
});

The User model implements Illuminate\Contracts\Auth\MustVerifyEmail, so the Registered event sends the link, and the verified middleware on your app's routes sends anyone who has not opened it back to the inbox panel.

Continue with: each button links to route('oauth.redirect', $provider), your own route that starts the provider's sign-in. With Laravel Socialite that route returns Socialite::driver($provider)->redirect(), for any provider Socialite or its community providers support; leave the row out if you have none.

The error summary lists the fields in the form's order, not the order the rules failed in, and appears only for two or more errors: one error is easy to find under its field.

With Livewire, give the component $name, $email, $password and $terms, bind each field with wire:model (wire:model="terms" on the checkbox), swap the form's method/action for wire:submit="register", and validate with the same rules and messages through $this->validate(). The view reads $errors either way.

Phone, keyboard, no script

  • On a phone the card fills the width with a 16px margin and the fields are 44px tall, at 16px text so the page does not zoom on focus.
  • Keyboard: Tab goes name, email, password, Show password, the terms, Create account, the two providers, Sign in, then the footer. With errors, focus starts on the summary, and each link in it moves focus to its field.
  • No script: everything posts as a plain form. The strength meter and the Show button need the script: without it the meter's bars stay grey and the button is drawn but does nothing. The password field and its help text work as usual.
  • Links in the terms: Checkbox's label and help are text, so the terms and privacy policy cannot be linked from the sentence that agrees to them; they are linked in the footer.

From the package repo: edit this page on GitHub.

Was this page helpful?