Layout preference rows — Settings block

Free

settings-layout-preference-rows · for app, account pages

Layout preference rows

A long settings document with controls aligned beside their labels for regional and account preferences.

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/settings-layout-preference-rows

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import SettingsLayoutPreferenceRows from '@/components/trame/blocks/settings/settings-layout-preference-rows.vue'

const props = {
title: "Settings",
sections: [
{
id: "profil",
label: "Shop profile",
group: "Workspace",
icon: "building",
description: "What your customers see in the shop and in their emails.",
groups: [
{
title: "Identity",
help: "The name and description shown in the footer and on invoices.",
fields: [
{
name: "shopName",
label: "Shop name",
required: true,
half: true
},
{
name: "legalName",
label: "Legal business name",
half: true,
placeholder: "Name as registered with the state"
}
]
},
{
title: "Contact details",
help: "Used to reply to customers and for the legal notice.",
fields: [
{
name: "email",
label: "Contact email address",
type: "email",
required: true,
half: true,
placeholder: "[email protected]"
},
{
name: "phone",
label: "Phone",
type: "tel",
half: true
}
]
}
]
},
{
id: "securite",
label: "Security",
group: "Personal",
icon: "shield",
description: "Protect access to your account.",
groups: [
{
title: "Sign-in",
fields: [
{
name: "password",
label: "New password",
type: "password",
help: "At least twelve characters."
},
{
name: "twoFactor",
label: "Two-step verification",
type: "switch",
help: "You’re asked for a code each time you sign in on a new device."
}
]
}
]
}
],
values: {
shopName: "Lumiere Studio",
legalName: "Lumiere Studio LLC",
about: "Handmade lighting from Portland, in small batches.",
email: "[email protected]",
phone: "(503) 555-0100",
language: "en",
currency: "USD",
twoFactor: true,
notifyOrders: true,
notifyReturns: false,
digest: "weekly",
billingAddress: "12 Weaver Street",
zip: "97209",
city: "Portland"
},
submit: "save-settings"
}
</script>

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

Props

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

PropTypeDescription
title*stringWordsthe page ("Settings")
sections*Section[]the sections shown, in order
valuesRecord<string, unknown>Datathe account’s current values by field name; an absent value leaves the field empty
submit*stringActionthe page action that saves the settings: through the host it receives `{ data, section, group? }` (group: the group saved on its own); an image field puts in `data` the File picked, or null once removed, and without the host the form posts as multipart/form-data (the file under the field’s name, `<name>:remove` set to 1 to remove the saved picture); a copy field is never sent
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Section sections[] · 6 props
PropTypeDescription
id*stringDesignthe section’s key
label*stringWordsthe section in the navigation ("Security")
groupstringWordsthe small heading above this section in the navigation ("Space", "Personal")
iconstringDesignuser, shield, bell, card, palette, globe, building, key, mail, users, settings, plug
descriptionstringWordsone sentence under the section’s title
groups*Group[]the section’s groups, in order
Group sections[].groups[] · 3 props
PropTypeDescription
title*stringWordswhat the fields of the group are about ("Contact details")
helpstringWordswhat the group changes, in a sentence
fields*Field[]the form’s fields, in order
Field sections[].groups[].fields[] · 12 props
PropTypeDescription
name*stringDesignthe key of the field in `values` and in what the form sends
label*stringWordsthe field’s name ("Email address")
type'text' | 'email' | 'tel' | 'url' | 'password' | 'number' | 'textarea' | 'select' | 'radio' | 'switch' | 'image' | 'color' | 'copy'what kind of field it is: text, email, tel, url, password, number, textarea, select, radio, switch; image (a picture to upload, its current address in `values`; posts the file under the field’s name, and `<name>:remove` to remove it), color (a hex colour, with its contrast checked), copy (a read-only value with a copy button, e.g. a workspace id; never sent)
helpstringWordsone sentence on what the field does or how it is used
placeholderstringWordsan example of the shape expected, never a value that looks real
optionsOption[]the choices, for a select
requiredbooleantrue: it must be filled in
readonlybooleantrue: the field is shown but cannot be changed
halfbooleanhalf the width of the group on wide screens, two to a row
prefixstringWordsthe fixed text attached before a text field’s value ("app.example.com/" before a slug); it is not part of what is sent
hintstringWordsa short note beside the field’s name ("Optional", "Up to 32 characters")
shape'square' | 'circle'Designan image field’s preview: square for a logo (the default), circle for an avatar
Option sections[].groups[].fields[].options[] · 2 props
PropTypeDescription
value*stringDesignwhat is sent
label*stringWordswhat is read
Options options · 7 props
PropTypeDescription
savePerGroupbooleaneach group has its own save button (the default for split-rows)
dangerZoneDangerZone[]destructive actions set apart at the end, e.g. "Delete the account"
dangerTitlestringWordsthe title of the destructive zone ("Sensitive area")
saveLabelstringWordsthe save button ("Save")
discardLabelstringWordsthe button that drops the unsaved edits ("Discard changes")
unsavedLabelstringWordsthe notice shown while edits are not saved ("Unsaved changes")
mood'inverse' | 'brand' | 'warm' | 'tint' | stringa band of the page that redefines the theme surfaces inside it
DangerZone options.dangerZone[] · 4 props
PropTypeDescription
label*stringWordsthe destructive action ("Delete the account")
helpstringWordswhat it does and that it cannot be undone
action*stringActiona named action of the page
recordRecord<string, unknown>Datathe record the action applies to, passed to the host with it, if any
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
asseta picture’s address as your app serves it
Linkyour router’s link component
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
  • No motion; still under reduced motion
  • Real buttons and links, a visible focus
  • Asks your app through actions: record.save, options.dangerZone[]
  • Reads settings from your app

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

Built with

The components this block is made of; each one installs on its own too.

More settings blocks

  • Integration settings keys webhooks: what developers manage: masked API keys to rotate or revoke and the webhook endpoints.
  • Integration status list: connected services with the state their last check found, a degraded one explained.
  • Integration switch list: a short list of connected apps turned on and off inside a settings page: one row each with a switch, the state named only when it is not operational.
  • Integration table: a developer or admin view auditing 6 to 20 services at once: one table with state, last event, figure and actions per service, an incident spanning its row.
  • Key list register: A key register with display prefixes, scopes and usage dates for the merchant’s own keys only.
  • Language coverage ledger: A language progress ledger beside the selected language’s keys, using the app’s own counts only.
  • Notification preferences channel matrix: the same events sent on several channels (e-mail, SMS, push): one table, an event per row and a channel per column; on a phone, a card per event.
  • Notification preferences switch groups: notification choices as switches grouped by channel, each with the reason it exists.

All 38 settings blocks