Skip to content

Newsletter 2

Newsletter panel with a pill email form and a list of subscriber perks.

02 / 02

Installation

Run this in a project that already uses shadcn/ui. The CLI adds the block, its components and npm dependencies.

pnpm dlx shadcn@latest add https://ui.sumansharma.info.np/r/newsletter-2.json
Prefer to iterate with AI?Open in

Usage

The CLI writes the block to components/newsletter-2.tsx. Import it anywhere:

Loading...

Source

The CLI writes this component to components/newsletter-2.tsx.

'use client'

import { useState } from 'react'
import { ArrowRight, BookOpen, Check, Rocket, Zap } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'

const perks = [
    { icon: Rocket, title: 'Release notes first', body: 'Hear about new features a week before the public launch.' },
    { icon: BookOpen, title: 'Deep-dive guides', body: 'Long-form tutorials written by the people who built it.' },
    { icon: Zap, title: 'Five-minute read', body: 'Short, skimmable and sent once every two weeks.' },
]

export default function Newsletter() {
    const [done, setDone] = useState(false)

    return (
        <section className="py-16 md:py-24">
            <div className="mx-auto max-w-6xl px-6">
                <div className="bg-muted/40 relative isolate overflow-hidden rounded-3xl border p-8 sm:p-12 lg:p-16">
                    <div
                        aria-hidden
                        className="absolute inset-0 -z-10 bg-[radial-gradient(var(--color-border)_1px,transparent_1px)] [background-size:18px_18px] [mask-image:linear-gradient(to_left,#000,transparent_70%)]"
                    />
                    <div className="grid gap-12 lg:grid-cols-2 lg:items-center">
                        <div>
                            <h2 className="text-balance text-3xl font-semibold sm:text-4xl">Stay ahead of every release</h2>
                            <p className="text-muted-foreground mt-4 max-w-md text-pretty">Join the newsletter for product updates, engineering stories and early access to what we ship next.</p>

                            {done ? (
                                <p
                                    role="status"
                                    className="mt-8 flex items-center gap-2 font-medium">
                                    <Check className="size-5 text-emerald-600 dark:text-emerald-400" />
                                    You are on the list.
                                </p>
                            ) : (
                                <form
                                    onSubmit={(e) => {
                                        e.preventDefault()
                                        setDone(true)
                                    }}
                                    className="bg-background mt-8 flex max-w-md items-center gap-1 rounded-full border p-1 shadow-sm focus-within:ring-2 focus-within:ring-ring/40">
                                    <Label
                                        htmlFor="newsletter-email-2"
                                        className="sr-only">
                                        Email address
                                    </Label>
                                    <Input
                                        id="newsletter-email-2"
                                        type="email"
                                        required
                                        autoComplete="email"
                                        placeholder="Enter your email"
                                        className="h-10 border-0 bg-transparent pl-4 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0"
                                    />
                                    <Button
                                        type="submit"
                                        className="group h-10 shrink-0 rounded-full px-5">
                                        Join
                                        <ArrowRight className="size-4 transition-transform group-hover:translate-x-0.5" />
                                    </Button>
                                </form>
                            )}
                        </div>

                        <ul className="space-y-6">
                            {perks.map(({ icon: Icon, title, body }) => (
                                <li
                                    key={title}
                                    className="flex gap-4">
                                    <span className="bg-background flex size-10 shrink-0 items-center justify-center rounded-lg border shadow-sm">
                                        <Icon className="size-4" />
                                    </span>
                                    <div>
                                        <h3 className="font-medium">{title}</h3>
                                        <p className="text-muted-foreground mt-1 text-sm">{body}</p>
                                    </div>
                                </li>
                            ))}
                        </ul>
                    </div>
                </div>
            </div>
        </section>
    )
}