Private betav0.1.0
Docs
Format developer documentation

format new

Scaffold a new Format project or document.

Use format new to create a completely fresh new Format project or add new Format documents to existing projects.

If you are looking to add Format to an existing repo with an existing package.json, you should use format init.

Create a project

npx format new project ./my-docs
pnpm dlx format new project ./my-docs
yarn dlx format new project ./my-docs
bun x format new project ./my-docs

Reference

NameDescription
directory
Where to create the project. Prompted if omitted.
--framework
The framework to build your documents with.
--no-install
Don't install dependencies after creating the project.
-y, --yes
Skip all prompts and use the defaults for every option that isn't provided.

Create a document

Run it with a name, or omit the name to be prompted with a random suggestion.

npx format new document invoice
pnpm dlx format new document invoice
yarn dlx format new document invoice
bun x format new document invoice

You will be prompted on your initial page size, what styling library you would like to use, whether to use a schema and any dynamic data you want to start with.

The framework (React, Vue or HTML) will be inferred from your config.

All the prompts can be controlled automatically via the flags documented below. For example, the following would preset Tailwind as the styling library, but prompt for the remaining options.

npx format new document invoice --styling tailwind
pnpm dlx format new document invoice --styling tailwind
yarn dlx format new document invoice --styling tailwind
bun x format new document invoice --styling tailwind

Reference

NameDescription
The document directory name (kebab-case recommended). Omit it to be prompted with a random suggestion.
Styling method for the document. Choices are filtered to your project framework. See the styling docs for more information.
Scaffold a data/schema.ts with this validation library, or "none" for no schema. Format validates any Standard Schema compliant library, so you can also wire up others by hand.
Path to a JSON file to seed the default data variant. Its shape is used to infer the schema and the entry's data type.
Page size for the document. A4 is the default; pass "custom" with --width and --height for an exact size.
Custom page width in CSS pixels. Requires --height; ignored unless --size is "custom" or omitted.
Custom page height in CSS pixels. Requires --width; ignored unless --size is "custom" or omitted.
Don't install missing styling/schema dependencies after creating the document.
Skip all prompts and use the defaults for every option that isn't provided.
Scaffold the most minimal document. Can be combined with other flags.

Details

[name]

Description
The document directory name (kebab-case recommended). Omit it to be prompted with a random suggestion.
Type
argument

--styling <method>

Description
Styling method for the document. Choices are filtered to your project framework. See the styling docs for more information.
Type
"css" | "css-modules" | "vue-sfc-scoped" | "scss" | "tailwind" | "linaria" | "vanilla-extract" | "panda-css"
Default value
css

--schema <library>

Description
Scaffold a data/schema.ts with this validation library, or "none" for no schema. Format validates any Standard Schema compliant library, so you can also wire up others by hand.
Type
"none" | "zod" | "valibot" | "joi" | "yup"
Default value
none

--data <path>

Description
Path to a JSON file to seed the default data variant. Its shape is used to infer the schema and the entry's data type.
Type
string

--size <id>

Description
Page size for the document. A4 is the default; pass "custom" with --width and --height for an exact size.
Type
"a3" | "a4" | "a5" | "letter" | "slide-16-9" | "slide-4-3" | "custom"
Default value
a4

--width <px>

Description
Custom page width in CSS pixels. Requires --height; ignored unless --size is "custom" or omitted.
Type
string

--height <px>

Description
Custom page height in CSS pixels. Requires --width; ignored unless --size is "custom" or omitted.
Type
string

--no-install

Description
Don't install missing styling/schema dependencies after creating the document.
Type
boolean
Default value
true
Note
Negation flag: default is true. Passing --no-install sets this to false.

-y, --yes

Description
Skip all prompts and use the defaults for every option that isn't provided.
Type
boolean
Default value
false

--empty

Description
Scaffold the most minimal document. Can be combined with other flags.
Type
boolean
Default value
false
Was this page helpful?