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-1.jsonPrefer to iterate with AI?Open in
Usage
The CLI writes the block to components/newsletter-1.tsx. Import it anywhere:
Loading...
Source
The CLI writes this component to components/newsletter-1.tsx.
'use client'
import { useState } from 'react'
import { Check, Mail } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
export default function Newsletter() {
const [status, setStatus] = useState<'idle' | 'done'>('idle')
return (
<section className="py-16 md:py-24">
<div className="mx-auto max-w-xl px-6 text-center">
<span className="bg-muted mx-auto flex size-12 items-center justify-center rounded-full border">
<Mail className="size-5" />
</span>
<h2 className="mt-6 text-balance text-3xl font-semibold sm:text-4xl">Get the monthly digest</h2>
<p className="text-muted-foreground mt-3 text-pretty">One email a month with new releases, guides and what we are building next. No spam, unsubscribe anytime.</p>
{status === 'done' ? (
<p
role="status"
className="mx-auto mt-8 inline-flex items-center gap-2 rounded-full border px-4 py-2 text-sm">
<Check className="size-4 text-emerald-600 dark:text-emerald-400" />
Thanks! Check your inbox to confirm.
</p>
) : (
<form
// Replace with a call to your email provider.
onSubmit={(e) => {
e.preventDefault()
setStatus('done')
}}
className="mx-auto mt-8 flex max-w-md flex-col gap-2 sm:flex-row">
<Label
htmlFor="newsletter-email"
className="sr-only">
Email address
</Label>
<Input
id="newsletter-email"
type="email"
required
autoComplete="email"
placeholder="you@company.com"
className="h-11"
/>
<Button
type="submit"
className="h-11 px-5">
Subscribe
</Button>
</form>
)}
<p className="text-muted-foreground mt-4 text-xs">Joined by 12,000+ developers and designers.</p>
</div>
</section>
)
}