tomato

The full reference.

Every shortcut. Every keyword. The same language on the playground, the CLI, and your editor — what you see here is what the compiler accepts. 1.2.0

Ten sections, in order.

  1. Installation
    Global CLI, project dev dependency, or npx with nothing installed.
  2. Your first .tom file
    Write a stylesheet in Tomato, compile it to CSS, ship the CSS.
  3. CLI usage
    All the commands, the --watch flag, and exit codes.
  4. Selectors
    Elements, classes, IDs, compound selectors, and the auto-class rule.
  5. Components
    component name: + use name. Reusable blocks with overrides.
  6. Pseudo states
    hover, focus, active, disabled — one indent level.
  7. Responsive design
    Match Tailwind widths. @dark: / @light: included.
  8. Custom tokens
    Define a name once, share it across files with @import.
  9. Color reference
    22 Tailwind scales built in, plus raw CSS colors and opacity.
  10. All properties
    Every shortcut mapped to the CSS it produces.

Three ways to install.

Global install

Once per machine. The tomato command is then available everywhere.

bash
$ npm install -g @srivtx/tomato-css
$ tomato app.tom -o styles.css

Project install

Local to one repo. Add a build step to package.json.

bash
$ npm install --save-dev @srivtx/tomato-css
$ npx tomato src/app.tom -o dist/styles.css
package.json
{
  "scripts": {
    "build": "tomato src/app.tom -o dist/styles.css",
    "watch": "tomato --watch src/app.tom -o dist/styles.css"
  }
}

No install

Try it on a single file without touching node_modules.

bash
$ npx @srivtx/tomato-css app.tom

Write, compile, ship.

Create a file called styles.tom:

styles.tom
button:
  bg blue-500
  color white
  pad 2 4
  round lg
  pointer
  smooth

Compile it. Output is plain CSS you can ship to a browser or a CDN.

bash
$ tomato styles.tom -o styles.css
styles.css
button {
  background: #3b82f6;
  color: #ffffff;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

From the command line.

bash
$ tomato <input.tom> [-o output.css]
$ tomato --watch <input.tom> [-o output.css]
Command What it does
tomato app.tom Compile to app.css
tomato app.tom -o styles.css Custom output path
tomato --watch app.tom Recompile on file change (debounced)
tomato --version Print the version
Note The CLI exits with code 1 on a compile error and 0 on success, so it works as a build step in CI. Unknown properties, missing imports, and bad gradient syntax all surface as errors with line numbers.

Any selector you'd write in CSS.

The compiler is permissive. Elements, classes, IDs, and compound selectors all work.

HTML elements

styles.tom
button:
  bg blue-500

nav:
  row spread

input:
  pad 2 4

Classes

styles.tom
.btn-primary:
  bg blue-500
  color white

.card:
  bg white
  round xl
  shadow lg

IDs

styles.tom
#header:
  bg slate-900
  pad 4 6

#main-content:
  pad 8

Auto-class conversion

Names that aren't HTML elements become classes automatically. Use the dot prefix when you want to be explicit.

styles.tom
# these compile to the same rule
card:            # → .card { }
.card:           # → .card { }

# these stay as element selectors
button:         # → button { }
nav:            # → nav { }
Tip HTML elements like button, nav, div, header, footer stay as element selectors. Anything else becomes a class.

Define once, use everywhere.

Define a reusable style block with component name: and pull it into any selector with use name. Properties are expanded inline, so you can override them by adding your own after the use statement.

Basic components

styles.tom
component btn:
  pad 2 4
  round lg
  bold
  pointer
  smooth
  no border

button:
  use btn
  bg blue-500
  color white

.btn-secondary:
  use btn
  bg violet-500

Nested components

Components can use other components, including their nested pseudo states.

styles.tom
component base-input:
  pad 3 4
  round md
  border 1px solid slate-300
  smooth

component focus-ring:
  use base-input

  focus:
    ring 2px solid blue-400
    border-color blue-500

input:
  use focus-ring
  w-full

Form input components

styles.tom
component input-base:
  w-full
  pad 3 4
  round lg
  border 1px solid slate-200
  bg white
  smooth

  focus:
    border-color blue-500
    no outline

textarea:
  use input-base
  min-height 120px
  resize vertical

Layout components

styles.tom
component container:
  max-width 1200px
  margin 0 auto
  pad 4 6

component stack:
  column
  gap 4

.page:
  use container
  use stack
  gap 8
Order matters You can use multiple components with multiple use statements. Properties apply in order, so later ones override earlier ones.

One indent level.

Four supported pseudos: hover, focus, active, disabled. Indent one level inside the block.

styles.tom
button:
  bg blue-500
  color white
  smooth

  hover:
    bg blue-600
    shadow lg

  focus:
    ring 2px solid blue-400
    no outline

  active:
    bg blue-700

  disabled:
    opacity 0.5
    cursor not-allowed

Match Tailwind's widths.

Five breakpoints, plus dark/light mode. Indent one level inside the breakpoint block.

styles.tom
hero:
  pad 16
  grid 3
  gap 6

  @mobile:
    pad 4
    grid 1

  @tablet:
    grid 2
Query Breakpoint
@mobile: max-width: 640px
@tablet: max-width: 768px
@laptop: max-width: 1024px
@desktop: max-width: 1280px
@wide: max-width: 1536px
@dark: prefers-color-scheme: dark
@light: prefers-color-scheme: light

Name it once, use it everywhere.

Define a token once at the top of a file, use it as a value anywhere. Tokens are local to the file.

styles.tom
colors:
  primary blue-500
  secondary violet-500
  dark slate-900
  light slate-50
  muted slate-400
  danger red-500
  success green-500

button:
  bg primary
  color light

.alert-danger:
  bg danger
  color white

Sharing tokens across files

Use @import at the top of a file. The compiler exits 1 if the file is missing.

app.tom
@import "./tokens.tom"

.button-primary:
  bg primary

22 scales, plus raw CSS.

Every Tailwind color scale, from 50 to 950. Or pass raw CSS colors when you need something off the palette.

styles.tom
# 22 color scales built in
slate, gray, zinc, neutral, stone
red, orange, amber, yellow, lime
green, emerald, teal, cyan, sky
blue, indigo, violet, purple
fuchsia, pink, rose

# usage
bg rose-500
color slate-900
border 1px solid blue-300
styles.tom
# raw CSS colors pass through unchanged
bg #f43f5e
bg rgb(244 63 94 / 0.5)
bg transparent
bg currentColor

Every shortcut, every output.

The complete shortcut list. Anything Tomato doesn't recognise is passed through unchanged — grid-template-areas, CSS variables, the lot.