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
Loading…

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. Shared files are skipped if you already have them.

    • components/silicon-ui/blocks/newsletter-signup/newsletter-signup.tsx
    • components/silicon-ui/blocks/newsletter-signup/newsletter-signup-data.ts
    • components/silicon-ui/lib/media.ts shared
    • components/silicon-ui/blocks/newsletter-signup/newsletter-signup.module.css
    • components/silicon-ui/switch/switch.tsx shared
    • components/silicon-ui/switch/switch.module.css shared
    • components/silicon-ui/segmented-control/segmented-control.tsx shared
    • components/silicon-ui/segmented-control/segmented-control.module.css shared
    • components/silicon-ui/animated-counter/animated-counter.tsx shared
    • components/silicon-ui/animated-counter/animated-counter.module.css shared
  3. Install the foundation once per app for the design and motion tokens: npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

Source codetsx
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