Skip to main content

Crate tangible

Crate tangible 

Source
Expand description

Design tokens as data — colors, type, space, shadows, gradients, and contrast — rendered to CSS.

tangible turns a structured token specification into a CSS custom-property sheet you can drop into any project. It is the library that powers the tangible command-line tool, but every step in the pipeline (parsing, resolving palettes, picking inks, emitting CSS) is available programmatically for embedding in build scripts, generators, or design-system tooling.

§At a glance

use tangible::{Renderer, Spec};

let json = std::fs::read_to_string("tokens.json")?;
let spec: Spec = serde_json::from_str(&json)?;
let manifest = Renderer::new().render(&spec)?;
std::fs::write("dist/tokens.css", manifest.to_string())?;

§Modules

  • color — color definitions, gradients, interpolation, sampling.
  • contrast — WCAG-driven ink selection for legible text on arbitrary backgrounds.
  • spec — the Spec structure and its sub-types (the input format).
  • render — the Renderer, its Config, and the resulting Manifest.

Re-exports§

pub use crate::error::Error;
pub use crate::render::Config;
pub use crate::render::Manifest;
pub use crate::render::Renderer;
pub use crate::spec::Spec;

Modules§

cli
Command-line interface, gated behind the cli feature.
color
Color definitions, gradients, and sampling.
contrast
WCAG contrast computation and ink selection.
error
The crate-wide error type.
io
Filesystem boundary for tangible’s CLI layer.
render
Rendering a Spec into a CSS Manifest.
spec
The token specification — what tangible consumes.

Type Aliases§

Result
A specialized Result type for tangible operations.