Hub checkbox grid — Newsletter block

Free

newsletter-hub-checkbox-grid · for journal, landing, account pages

Hub checkbox grid

A compact two-column checklist and one update button: preferences for someone who already subscribes

Documentation

Installation

One command copies the block into your project with the shadcn CLI (the registry is set once: Installation).

pnpm dlx shadcn-vue@latest add @trame/newsletter-hub-checkbox-grid

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import NewsletterHubCheckboxGrid from '@/components/trame/blocks/newsletter/newsletter-hub-checkbox-grid.vue'

const props = {
title: "Get our newsletters",
lead: "Four newsletters, each on its own schedule. Check the ones you like; you can change your mind at any time.",
lists: [
{
id: "atelier",
name: "The workshop journal",
cadence: "The first Monday of the month",
description: "One making-of story, one photo and what’s new in the shop, nothing else.",
image: "https://images.unsplash.com/photo-1676125105332-608345abe20e?w=1600&q=80",
alt: "A potter’s wheel surrounded by tools",
sample: {
action: "issue",
record: {
id: "atelier-12"
}
},
checked: true
},
{
id: "jardin",
name: "Greenhouse notebook",
cadence: "Twice a month",
description: "What we sow, what we bring in, and the seedlings available in the shop.",
image: "https://images.unsplash.com/photo-1508857650881-64475119d798?w=1600&q=80",
alt: "Inside a greenhouse, rows of young seedlings",
sample: {
action: "issue",
record: {
id: "jardin-8"
}
}
}
],
form: {
submit: "newsletter",
submitLabel: "Subscribe",
consent: "Your address is only used to send the newsletters you checked. Every email includes an unsubscribe link."
},
options: {
eyebrow: "Newsletters"
}
}
</script>

<template>
<NewsletterHubCheckboxGrid v-bind="props" />
</template>

Props

Each prop says who changes it: Words, Picture, Action, Design, Data.* required.

PropTypeDescription
title*stringWordswhat the page offers ("Get our letters")
leadstringWordsone or two sentences under the title
lists*List[]Datathe newsletters the merchant sends
form*Formthe sign-up form: where it posts and its words
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
List lists[] · 8 props
PropTypeDescription
id*string | numberDatathe list’s id in the tool that answers it: what the form sends back for it
name*stringWordsthe newsletter’s name ("The workshop journal")
cadence*stringWordshow often it is sent, as the merchant commits to it ("Every first Monday"): no promise the merchant does not keep
description*stringWordswhat it holds, in a sentence or two
imagestringPicturea picture: a root-relative path (/media/…) or an absolute URL
altstringWordsthe picture’s description
sampleSamplea past issue of this list, to read
checkedbooleanticked at first: the merchant’s choice for a list it recommends, or the lists a subscriber already has
Sample lists[].sample · 2 props
PropTypeDescription
action*stringActionthe action that opens a past issue of this list
recordRecord<string, unknown>Datathe record the action applies to, passed to the host with it, if any
Form form · 3 props
PropTypeDescription
submit*stringActionthe page action that receives the address and the chosen lists
submitLabel*stringWordsthe button’s words ("Subscribe", "Update")
consent*stringWordsthe consent sentence under the form: required, shown always
Options options · 5 props
PropTypeDescription
eyebrowstringWordsa short label over the title
subscriberstringWordsthe address of a subscriber who is changing their lists, as the app knows it
status'success' | 'error'the section’s status: success, error
statusTextstringWordsthe answer to the form, as the app gives it
mood'inverse' | 'brand' | 'warm' | 'tint' | stringa band of the page that redefines the theme surfaces inside it
What it asks your app for

The block never knows your app: it asks it, through one context provided once, where its links lead, what its actions do, how a price reads and which words to say (The host context).

MemberWhat it is for
hrefthe address an action leads to, or null to hide what leads there
actruns a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error }
canwhether the page has this action
cartCountthe cart badge’s number
cartDrawerwhether your app has a cart drawer
cartOpenwhether the cart drawer is open
labelyour word for an interface key, or undefined to keep the block’s own

The words it says itself, in English and French; label(key) replaces any of them:

KeyEnglishFrench
newsletter.alreadyYou are already subscribed.Vous êtes déjà inscrit.
newsletter.doneDone: you are subscribed.C’est noté : vous êtes inscrit.
newsletter.invalidCheck the email address.Vérifiez l’adresse e-mail.
newsletter.tooManyToo many attempts, try again in a moment.Trop de tentatives, réessayez dans un moment.

Features

  • Every word in the server HTML
  • Same markup in Vue and React
  • Theme tokens only: every theme, light and dark
  • Shows what you give it, invents nothing
  • Subtle motion: one short reveal; still under reduced motion
  • Real buttons and links, a visible focus
  • Asks your app through actions: lists[].sample, form.submit

A newsletter section, for journal, landing, account pages; it uses @lucide/vue, @vueuse/core, class-variance-authority, clsx, reka-ui, tailwind-merge.

More newsletter blocks

  • Email capture centered: the classic block of a home page: a title, one line of promise, one field.
  • Facts: the merchant states real figures about the letter: its facts as tiles beside the form.
  • Guide signup split form: one guide traded for an address: its cover and contents beside the field; the merchant’s own only.
  • Issue feed: one signup row over the stack of past issues (and the lists in a second tab): a journal that wants its archive read.
  • Issue preview split preview: the merchant has a real newsletter: the form beside a card showing what an issue looks like.
  • Journal signup with issues: the journal has already gone out: the form beside its last issues, as proof of what arrives.
  • Latest issue signup cover card: the latest issue shown as a cover card beside the form: one strong issue to sell the next ones.
  • Letter archive collage: an intro with a collage of the merchant’s pictures and the form, a sample archive beside it: one letter with a real history.

All 25 newsletter blocks