Liking cljdoc? Tell your friends :D

cssyes

Makes CSS nicer to look at in terminal environments.
Works with Clojure, ClojureScript(Node), Babashka, and Jolt



Setup  •  Usage  •  Themes  •  Developing


cssyes in a Babashka REPL cssyes in a Babashka REPL


Development Status

PeriodStageRelease
2026 Mar-NovExperimental-
2026 Nov-presentAlpha0.1.0

Setup

If using with Babashka, requires v1.13.222 or higher

If using with Jolt, requires v0.8.24 or higher


Add as a dependency to your project:


Deps:

design.kushi/cssyes {:mvn/version "0.1.0"}

Leiningen:

[design.kushi/cssyes "0.1.0"]

Require it:

(require '[cssyes.core :refer [beautify print-css]])

Or import into your namespace:

(ns myns.core
  (:require
    [cssyes.core :refer [beautify print-css]]))

Consuming via git

Using a tool without Maven support? See Consuming cssyes as a git dependency.



Usage

cssyes.core/beautify expects a string of valid CSS and returns a formatted string, tagged with ANSI SGR codes. The SGR codes will activate syntax highlighting in terminal/console environments.

(beautify ".btn{color:red;background-color:blue;&:hover{color:gold;}}")

Output (without color):

.btn {
  color:            red;
  background-color: blue;
  &:hover {
    color: gold;
  }
}

print-css prints the formatted string and returns nil.

(print-css ".foo{color:red;}")
(print-css ".foo{color:red;}" {:theme cssyes.themes/neutral})

Options

KeyDefaultDescription
:themecssyes.themes/monokaiMap of token to color
:color-variantnilUse one variant for every base color in the theme. See Color variants
:indentation2Spaces per nesting level
:align-values?trueAlign (left-justify) values within a block
:supports-colornilA supports-color :context map, for mocking the terminal in tests

Themes

Presets in cssyes.themes:

  • monokai, the default.
  • neutral, which colors only punctuation and comments, in gray.

cssyes colors text with sugar, so each base color adapts to the terminal's background. :red is a lighter red on a dark background, a darker red on a light background, and a medium red when the background is not detected. Colors are downsampled to the color level the terminal supports, and output has no color codes when the terminal supports none.

Theme tokens

TokenColors
:selectorsSelectors and at-rule text: .foo, @media
:ampersands&
:pseudo-colons: and :: in selectors and at-rules
:curly-brackets{ }
:round-brackets( )
:propertiesProperty names: color
:colons: after a property
:valuesPlain values and hex colors: silver, #fff
:stringsQuoted strings: "cssyes"
:numbersNumbers and units: 10px, 1.5, 50%
:varsCustom properties: --gap
:cssfnFunction names: calc, color-mix
:commas,
:semi-colons;
:comments/* ... */

Theme colors

A token's color is any color that sugar's :color option takes.

Base colors, which adapt to the terminal's background:

:red
:orange
:yellow
:olive
:green
:cyan
:blue
:purple
:magenta
:gray

:black, :white, fixed variants such as :dark-blue or :soft-red, hex strings such as "#ff5f00", rgb vectors such as [255 95 0], and 8-bit ids such as 202 do not adapt.

:neutral, or a missing token, prints uncolored.

View sugar's color docs, which list every variant.

Color variants

:color-variant puts the same variant on every base color in the theme, in place of the one sugar picks for the terminal's background. With :extra-dark, :blue becomes :extra-dark-blue.

(print-css ".foo{color:red;}" {:theme         cssyes.themes/monokai
                               :color-variant :extra-dark})

It takes one of :shadow, :extra-dark, :dark, :medium, :light, :extra-light or :highlight. Any other value leaves the theme unchanged. :black, :white, fixed variants, hex, rgb and 8-bit colors are not changed.

On a terminal with 256 colors, neighboring variants such as :extra-dark and :shadow can round to the same color.

Custom theme example

(def my-theme
  {:selectors      :blue
   :ampersands     :blue
   :pseudo-colons  :blue
   :properties     :green
   :strings        :green
   :curly-brackets :gray
   :round-brackets :gray
   :colons         :gray
   :commas         :gray
   :semi-colons    :gray
   :comments       :gray})

(print-css ".foo{color:red;}" {:theme my-theme})

Developing

Available dev tasks via bb.edn:

bb test            # Clojure tests
bb test:bb         # Babashka tests
bb test:jolt       # Jolt tests
bb test:cljs       # ClojureScript tests on Node (run npm install first)
bb test:all        # all of the above
bb test:visual     # print sample CSS in each preset theme and color variant
bb ci              # run the tests and build the jar
bb install         # install the jar to ~/.m2
bb docs:readme     # after tagging a release: update the version numbers in this README
bb docs:git-deps   # after tagging a release: regenerate doc/git-deps.md

Updating docs after a release

After tagging a release (for example git tag v0.2.0), run both docs tasks:

Commit both files and push.


Contributing

Issues for bugs, improvements, or features are very welcome. Please file an issue for discussion before starting or issuing a PR.


License

Copyright © 2026 Jeremiah Coyle

Distributed under the Eclipse Public License 2.0

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close