Skip to content

Newsletter signup

An email signup framed by a stack of past issues; subscribing drops the next issue, addressed to you, onto the front.

npx shadcn@latest add @silicon-ui/newsletter-signup

Installation

With the shadcn CLI

npx shadcn@latest add @silicon-ui/newsletter-signup

Manually

  1. Install the dependencies

    npm install @radix-ui/react-switch lucide-react motion
  2. Copy these files into your project

    • components/silicon-ui/blocks/newsletter-signup/newsletter-signup.tsx
    • components/silicon-ui/blocks/newsletter-signup/newsletter-signup-data.ts
    • components/silicon-ui/blocks/newsletter-signup/newsletter-signup.module.css

    Shared with other components. Skip any you already have.

    • components/silicon-ui/lib/media.ts
    • components/silicon-ui/switch/switch.tsx
    • components/silicon-ui/switch/switch.module.css
    • components/silicon-ui/segmented-control/segmented-control.tsx
    • components/silicon-ui/segmented-control/segmented-control.module.css
    • components/silicon-ui/animated-counter/animated-counter.tsx
    • components/silicon-ui/animated-counter/animated-counter.module.css
    • components/silicon-ui/lib/fluid-hover.tsx
  3. Add the foundation, once per app, for the design and motion tokens

    npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

usage.tsx
import { NewsletterSignup } from "@/components/silicon-ui/blocks/newsletter-signup/newsletter-signup";

API reference

NewsletterSignup

PropTypeDefault
variant

`inline` puts the copy and form beside the issue stack; `card` is a self-contained card with the stack in a tray on top.

NewsletterVariant

"inline""card"

"inline"
titlestring—
descriptionstring—
placeholderstring"you@company.com"
buttonLabelstring"Subscribe"
privacyNote

Short line under the form about frequency and privacy.

ReactNodenewsletterCopy.privacy
privacyLink

Link after the privacy note. Pass null to hide it.

{ label: string; href: string } | nullnewsletterCopy.privacyLink
readers

Reader count and up to three faces. The count ticks up by one when someone subscribes. Pass null to hide it.

{ count: number; faces: string[] } | nullnewsletterReaders
publication

The issue stack. On success the upcoming issue, addressed to the new reader, lands on top. Pass null for a form without the stack.

NewsletterPublication | nullnewsletterPublication
onSubscribe

Called with a valid, trimmed email. Reject to show an error and keep the email; resolve to show the success state.

(email: string) => void | Promise<void>—
classNamestring—

Also accepts the props of HTMLAttributes.

Dependencies

npm
@radix-ui/react-switchlucide-reactmotion
Registry
silicon-motion-tokensanimated-countersegmented-controlswitch