Forma Docs Live preview
Documentation

Forma, step by step

Everything you need to set up, customise and ship the Forma Tailwind CSS agency template.

Introduction

Forma is a design-led Astro template for agencies, creative studios and freelance portfolios — one of our best Astro templates for an agency landing page or a portfolio template, built with Astro 7, Tailwind CSS 4 and Magic UI, no React or other UI framework. It ships seventeen ready pages across five home variants, an Astro blog template for the Journal section, a validated contact form with a PHP handler, light and dark "Digital Violet" themes, and a fully static production build.

What is included

  • Tailwind CSS 4, compiled at build time (no CDN script in the browser)
  • Design tokens in one place: --forma-* custom properties in src/styles/tokens.css
  • Dark by default, with a light mode the visitor can switch to; their choice is remembered
  • Three Magic UI pieces (bento grid, marquee, number ticker) and a set of small unstyled form primitives
  • SEO: unique title, description and keywords per page, canonical URLs, Open Graph, sitemap via @astrojs/sitemap
  • Astro static build: every page pre-rendered to plain HTML, CSS and JavaScript in dist/
The live preview and demo pages are statically generated (SSG) by Astro at build time — plain pre-rendered HTML, CSS and JavaScript with no server-side rendering. That is why pages load instantly: the only thing that needs a live server is the PHP contact form. See Build and deployment for details.

Getting started

Install the tools, run one command and the template builds, opens in your browser and rebuilds whenever you save a file.

Requirements

ToolVersionNeeded for
Node.js18 or newerBuilding the template
npm9 or newerInstalling packages
PHP8 or newerOnly the contact form (contact.php)

Install and run

bash
cd forma-astro
npm install
npm run dev

npm run dev starts the Astro dev server at http://localhost:4321 with live reload; every change you save in src/ shows up in the browser.

Commands

CommandWhat it does
npm run devStart the dev server with live reload
npm run buildType-check with astro check, then build the static site into dist/
npm run previewServe the finished dist/ folder locally
npm run formatFormat the project with Prettier (Astro + Tailwind class-sorting plugins)
npm run format:checkCheck formatting without writing, for CI
Edit files in src/ and public/ only. Everything in dist/ is generated and is replaced on every build.

Folder structure

Everything you edit lives in src/; the build writes the finished site to dist/. Here is where each piece sits.

text
forma-astro/
├── src/
│   ├── pages/              ← seventeen routes (.astro), file name becomes the URL
│   │   ├── index.astro, home-classic.astro, home-corporate.astro
│   │   ├── home-creative.astro, home-video.astro
│   │   ├── about.astro, about-agency.astro, services.astro
│   │   ├── portfolio/index.astro, portfolio/[slug].astro
│   │   ├── blog/index.astro, blog/[...slug].astro, blog-sidebar.astro
│   │   ├── contact.astro, contact-maps.astro
│   │   └── privacy.astro, 404.astro
│   ├── components/
│   │   ├── ui/             ← small unstyled primitives: Button, Badge, TextField, SelectField …
│   │   ├── magicui/         ← bento-grid/, marquee/, number-ticker/ (one folder each, index.ts)
│   │   ├── common/          ← PageHero, SectionTitle, BlogCard, ProjectCard, Callout, RelatedPosts
│   │   ├── layout/           ← Navbar, NavLinks, ThemeToggle, MobileDrawer, Footer
│   │   └── sections/         ← one home-page section per file (StatsSection, …)
│   ├── features/            ← hero-visual/, portfolio-filter/, contact-form/ (plain .astro, no framework)
│   ├── content/              ← MDX collections: blog/, portfolio/
│   ├── data/                ← navigation.ts, home.ts (incl. testimonials), portfolio.ts, team.ts
│   ├── schemas/              ← one zod schema per form + fields.ts
│   ├── scripts/              ← form.ts (bindApiForm), portfolio-filter.ts, navbar.ts, theme.ts, …
│   ├── lib/                  ← site.ts (brand/SEO text), http.ts (postJson), utils
│   └── styles/               ← global.css (imports) + tokens.css, base.css, layout.css
├── public/
│   ├── contact.php           ← contact form handler
│   ├── favicon.svg
│   └── images/
├── dist/                     ← generated, upload this
├── static-files/             ← documentation and preview pages (this file)
├── astro.config.mjs, tsconfig.json
└── package.json

Content (MDX + data)

Blog posts and portfolio case studies are MDX files in src/content/blog/ and src/content/portfolio/. Everything else — navigation, home-page stats, the portfolio index, team bios — is typed data in src/data/*.ts, read by the Astro components. To change a headline, a stat, the menu or a case study, edit the file and rebuild.

Components

Shared UI lives in src/components/ in four folders: ui/ for small unstyled primitives with no copy of their own, magicui/ for the three installed Magic UI effects, common/ for Astro pieces shared across pages, and layout/ for the navbar, drawer, theme toggle and footer. Change a component once and every page updates.

ComponentUsed for
layout/Navbar.astro, MobileDrawer.astroFixed navigation with dropdown groups, and the mobile slide-in menu
layout/ThemeToggle.astroDark / light switch, persisted to localStorage
common/PageHero.astroThe hero block at the top of every non-home page
common/ProjectCard.astro, BlogCard.astroPortfolio and journal cards
magicui/bento-grid/Services / features bento layout
magicui/marquee/, number-ticker/Logo marquee and the animated stats row
features/contact-form/ContactForm.astroThe contact form, validated and submitted by its own inline script
features/portfolio-filter/Category filter on the Work index, wired by a vanilla script

Pages and components

Every page shares the same shell. Copy an existing page in src/pages/ to start a new one; the file name becomes the route (my-page.astro builds dist/my-page/index.html).

PageFileWhat it is
Home — Agency / Classic / Corporate / Creative / Videoindex.astro, home-classic.astro, home-corporate.astro, home-creative.astro, home-video.astroFive hero and layout variants to start from
About — Studio / Agencyabout.astro, about-agency.astroStory, team and two layout takes
Servicesservices.astroBrand identity, web design & build, product design, growth marketing
Workportfolio/index.astro, portfolio/[slug].astroFilterable case-study index and eight detail pages
Journalblog/index.astro, blog/[...slug].astro, blog-sidebar.astroMDX post grid, post detail and a sidebar layout variant
Contact — Form / Mapcontact.astro, contact-maps.astroThe validated PHP-backed form, with and without a map
Privacy, 404privacy.astro, 404.astroLegal page and the not-found page

Adding a page to the menu

Add an entry to src/data/navigation.ts (NAV for the header, FOOTER_COLUMNS for the footer); layout/Navbar.astro and MobileDrawer.astro both read from the same array.

Design tokens

Every colour, shadow and radius comes from --forma-* custom properties at the top of src/styles/tokens.css. Tailwind's @theme inline block maps them to utility classes, so changing one value updates the whole template, including dark mode.

Colours — "Digital Violet"

Primary--forma-primaryButtons, links, focus rings
Accent--forma-accentSecondary highlights
Page (dark)--forma-page-bgDefault background
Surface--forma-surfaceCards, nav (scrolled)
Error--forma-errorForm validation
Success--forma-successSuccess messages

Typography

UseFontWeights
HeadingsOutfit500 / 600 / 700
Body text, UIInter400 / 500 / 600

Headings follow one scale, set once in base.css: h1 60px (44px below 992px, 36px below 576px), h2 32px, h3 28px, h4 24px — never add a one-off text-[..px] to a heading.

Spacing and breakpoints

Spacing uses a fixed pixel scale (5, 10, 15, 20, 25, 30, 40, 50, 70, 100, 120) written as arbitrary Tailwind values (mb-[30px]), not the default mb-8 steps. Breakpoints follow Bootstrap's scale, defined in the @theme inline block: sm 576, md 768, lg 992, xl 1200, 2xl 1400.

Change the brand colour

css
/* src/styles/tokens.css */
:root {
  --forma-primary: #7c5cff;        /* change this */
  --forma-primary-hover: color-mix(in srgb, var(--forma-primary), #fff 12%);
  --forma-accent: #ff7ad1;
}
:root[data-theme='light'] {
  --forma-primary: #6a3dff;        /* and its light-mode value */
}
Three alternative palettes (Citrus Lime, Mocha Terracotta, Signal Coral) are documented at the top of the project README.md if Digital Violet is not the right fit for your brand.

Dark mode

Dark mode is attribute based, and dark is the default. A tiny inline script in <head> (layout/ThemeToggle.astro's companion script) sets data-theme="light" on <html> before the page paints, so there is no flash, if the visitor has chosen light before. The toggle saves the choice in localStorage under the key theme.

You never write dark: variants: the colour variables change instead, and light mode is the override.

css
:root[data-theme='light'] {
  --forma-page-bg: #f7f7fb;
  --forma-surface: #ffffff;
  --forma-heading-color: #0b0b14;
}

Tailwind CSS

Tailwind 4 is compiled during the build (the @tailwindcss/vite plugin inside Astro), so no Tailwind script runs in the browser. global.css imports Tailwind, then tokens.css (the --forma-* variables and the @theme inline map), base.css (element defaults) and layout.css (what Tailwind cannot express).

There is no tailwind.config file in Tailwind 4: colours, shadows, radius, fonts, breakpoints and the marquee/float/pulse-glow keyframes all live in the @theme inline block of tokens.css. Tailwind scans src/ for class names automatically.

If you add a class from JavaScript, write it as a complete string (for example class="border-error") so Tailwind can see it. Do not build class names by joining pieces.

Components

The template includes ready-made interface pieces, a mix of plain Astro components and Magic UI effects. No React, Vue or other UI framework ships to the browser.

Buttons and form fields

Use the Button, Badge, TextField, SelectField, TextareaField and FormStatus components from src/components/ui/; each wraps a shared FormField.astro for its label, error slot and ARIA wiring.

astro
<TextField id="email" name="email" type="email" label="Email" />
<Button variant="primary">Send message</Button>

Magic UI

ComponentUsed for
magicui/bento-gridServices / features layout with uneven card spans
magicui/marqueeInfinite-scrolling client-logo row
magicui/number-tickerThe animated stats row (120+ projects, 46 clients …)

Portfolio filter

The Work index filters eight case studies by category client-side (features/portfolio-filter/, wired by src/scripts/portfolio-filter.ts) without a page reload or a framework.

Contact form (PHP)

The form on contact.astro and contact-maps.astro (ContactForm.astro) is validated with Zod through bindApiForm (src/scripts/form.ts), then POSTed as JSON to public/contact.php, which validates everything again on the server and emails the message.

Set the recipient

php
// public/contact.php
const TO_EMAIL   = 'studio@forma.example.com';
const FROM_EMAIL = 'no-reply@forma-agency.example.com';
const SITE_NAME  = 'Forma';

Fields and rules

FieldRule
nameRequired, 2+ characters
emailRequired, valid address
companyOptional
budgetOptional, one of four ranges (Under $10k … $75k+)
messageRequired, 10+ characters
websiteHidden spam trap: a filled value is silently accepted and dropped

How it replies

  • A fetch request gets JSON: {"ok": true, "message": "…"}, or a non-200 status with ok: false.
  • Posts from another origin are refused with a same-origin check against HTTP_ORIGIN.
  • Only POST is accepted; anything else gets a 405.
The form needs a server that runs PHP and can send mail with mail(). It does not work on a static-only host or with npm run dev — test it after deploying, or with any local PHP server pointed at dist/.

SEO

Each page sets its own title, description and canonical URL; site-wide defaults (name, tagline, description, social handle) come from src/lib/site.ts.

SourceControls
src/lib/site.tsSite name, tagline, description, Twitter handle, contact email/phone/address
Each page's frontmatterPage title, meta description, canonical path
astro.config.mjs (site, base)Canonical domain and the /themes/.../app/ base path used across the build
@astrojs/sitemapGenerates sitemap-index.xml at build time
public/robots.txtCrawl rules and the sitemap URL

Change the site address

Set site and base in astro.config.mjs, update public/robots.txt's sitemap URL to match, and search src/ for the old domain.

Build and deployment

Astro builds src/ into dist/ as a fully static (SSG) site — every route becomes a directory with its own index.html (for example dist/about/index.html), ready for any Apache or static host.

StepWhat happens
checkastro check type-checks the project before building
pagesComponents are rendered into complete static HTML pages
cssTailwind and the files imported by global.css are compiled into one hashed stylesheet per entry
jsThe small vanilla scripts (ContactForm's submit handler, the portfolio filter) are bundled and run only on the pages that use them
publiccontact.php, favicon.svg and images/ are copied as they are

Deploy

Upload the contents of dist/ to your host. It is plain static HTML, CSS and JavaScript plus contact.php, so it works in the web root or in a sub folder that matches the base you configured. For the contact form the host must run PHP.

Dependencies

Every library the pages use comes from package.json and is imported in the source. Astro bundles it into dist/_astro/ when you build. Nothing is loaded from a CDN.

Libraries used by the pages

PackageVersionUsed for
astro^7.4.11Static site generator and bundler (Vite)
@astrojs/mdx^8.1.5MDX for blog and portfolio content
@astrojs/sitemap^3.7.4Sitemap generation
tailwindcss, @tailwindcss/vite^4.3.5Utility CSS, compiled at build time
zod^4.6.7Contact-form validation, read by bindApiForm
cn^0.5.2Conditional Tailwind class-name joining
boxicons^2.1.4Icons
motion^14.12.0Scroll and hover animation
@fontsource/outfit, @fontsource/inter^5.3.0 / ^5.2.5Self-hosted fonts

Build tools

Listed under devDependencies: @astrojs/check and typescript (type checking), prettier with prettier-plugin-astro and prettier-plugin-tailwindcss (formatting). They run on your computer only.

Add or update a library

bash
npm install some-library   # add it
npm update                 # update everything

Customisation

Make the template yours: rename it, change the colours and fonts, swap the copy and images, and update the services and prices.

Change the name and logo

Update SITE.name in src/lib/site.ts, the inline SVG mark in layout/Navbar.astro and layout/Footer.astro, and public/favicon.svg.

Change fonts

Fonts come from Fontsource packages. Run npm install @fontsource/your-font, import it where @fontsource/outfit and @fontsource/inter are imported today, and update --font-display / --font-sans in the @theme inline block of tokens.css.

Replace the imagery

Every image currently loads live from images.unsplash.com so the project runs with zero binary assets. IMAGE-ASSETS.md in the project root lists each image's purpose, exact crop size and source URL — download, crop and save each one locally, then update the matching src in src/data/*.ts before you ship.

Change services and prices

Edit the service cards directly in services.astro, and the headline stats in src/data/home.ts.

AI assistants

The project root contains CLAUDE.md and AGENTS.md: a short guide that coding assistants read before they touch your code, so they use the right commands and edit the right files.

This comes included with your purchase. Many templates leave you to explain your own codebase to an AI assistant from scratch, or charge extra for it; Forma ships CLAUDE.md and AGENTS.md already written, so tools such as Claude Code, Cursor, Codex and GitHub Copilot understand the project structure, commands and conventions from the first prompt.

CLAUDE.md is read by Claude Code; AGENTS.md by Cursor, Codex, Copilot and similar tools. The two files are identical.

What is inside

SectionTells the assistant
StackAstro, Tailwind and Magic UI versions, that there's no UI framework, and which form actually talks to PHP
CommandsThe exact install, dev, build and format commands, so it does not guess
Project structureWhere pages, components, data, schemas and styles live
How to customizeStep by step: brand colour, new page, menu, contact recipient, images
ConventionsCoding rules to follow (token classes, fixed spacing scale, one component per file …)
Do NOTFolders and changes that are off limits, and the known README/code mismatch around the contact-form endpoint

Keep them in sync

When the project changes (a new folder, command or rule), edit CLAUDE.md and copy it over AGENTS.md.

bash
cp CLAUDE.md AGENTS.md

Troubleshooting

Quick answers to the problems people run into most often when setting up the template.

The page looks unstyled after I build

Open the built site through a server (npm run dev or npm run preview), not by double-clicking a file, and make sure npm install finished without errors. Tailwind is compiled during the build, so a failed build leaves no stylesheet.

The contact form shows an error

The form needs a server that runs PHP and can send mail. Set TO_EMAIL in contact.php and check the server can send mail. It will not work with npm run dev alone.

My edits do not show up

Edit files in src/ and public/, never in dist/, which is rebuilt every time. With npm run dev the page reloads on save; if it does not, do a hard refresh.

How do I change the brand colour?

Change --forma-primary (and its light-mode override) at the top of src/styles/tokens.css. Buttons, links and focus rings all follow it.

Dark mode does not remember my choice

The choice is saved in localStorage. If the browser blocks storage (private mode, blocked cookies) the template stays on the default dark theme.

Credits and support

Forma builds on a few well-maintained open-source tools. Here is what they do, who to ask for help, and what changed in each release.

ResourceUsed for
Tailwind CSS 4Styling
Astro 7Static site build
ZodContact-form validation
Magic UIBento grid, marquee, number ticker
MotionScroll and entrance animation
FontsourceOutfit, Inter (installed from npm)

Need help? Email studio@forma.example.com.

Changelog

VersionDateNotes
1.0.2November 17, 2026Added CLAUDE.md and AGENTS.md (AI assistant guide) and an AI assistants section in this documentation
1.0.1November 17, 2026Rebuilt documentation and preview pages to match the current token system and real page list
1.0.0November 13, 2026Initial release: seventeen pages, PHP contact form, dark/light "Digital Violet" theme, Magic UI, production build