termiwind

package module
v0.0.0-...-4a23534 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 1 Imported by: 0

README

./termiwind

Style your terminal the Tailwind way 🍃

Documentation

Overview

Package termiwind provides Tailwind-like styling for terminal output.

Example:

fmt.Print(ti.Style("flex gap-2",
    ti.Style("bg-green-600 px-1", "Termwind"),
    ti.Style("italic", "CLI styling"),
).Render())

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Layout

func Layout(n *Node, width, height int)

Layout calculates positions and dimensions for all nodes in the tree. This is optional - Render calls Layout automatically with default 80x24. Use Layout explicitly when you need custom dimensions.

Example:

node := Style("flex gap-2",
    Style("bold", "Hello"),
    Style("italic", "World"),
)
Layout(node, 120, 40)  // Custom terminal size
fmt.Print(node.Render())

func Render

func Render(n *Node) string

Render produces ANSI-styled output from a node tree. Automatically calls Layout with default 80x24 if not already calculated.

Prefer using the method form: Style("bold", "Hello").Render()

Example:

node := Style("flex gap-2", Style("bold", "Hello"))
fmt.Print(Render(node))

Types

type Node

type Node = node.Node

Node is a styled element in the render tree. Can be a leaf node (with text) or a container (with children).

func Style

func Style(classes string, children ...any) *Node

Style creates a new Node with the given classes and children. Children can be strings (text content) or *Node (child elements).

Example:

// Leaf node with text
fmt.Print(Style("bold text-red-500", "Hello").Render())

// Container with children
fmt.Print(Style("flex gap-2",
    Style("bg-green-600", "Item 1"),
    Style("bg-blue-600", "Item 2"),
).Render())

Directories

Path Synopsis
Package buffer provides a 2D cell-based buffer for terminal rendering.
Package buffer provides a 2D cell-based buffer for terminal rendering.
cmd
Package node provides a tree-based structure for terminal UI composition.
Package node provides a tree-based structure for terminal UI composition.
Package style provides Tailwind CSS-inspired style parsing for terminal UI rendering.
Package style provides Tailwind CSS-inspired style parsing for terminal UI rendering.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL