Skip to content

Subpath Exports

Dispersa exposes a main entry point and several subpath exports. Use subpaths to keep bundles small and import only what you need.

SubpathKey exportsTypical usage
dispersaDispersa, builders, defineRenderer, outputTree, isOutputTree, type guards, error classes, all public typesMain entry; full builds
dispersa/transformscolorToHex, nameKebabCase, dimensionToRem, etc. (23 factories) + Transform typePer-output or global transforms
dispersa/filtersbyType, byPath, isAlias, isBase + Filter typeToken filtering
dispersa/builderscss, json, js, tailwind, ios, android + builder config typesOutput configuration only
dispersa/renderersdefineRenderer, outputTree, isOutputTree + all renderer/build typesCustom renderers
dispersa/preprocessorsPreprocessor typeCustom preprocessors
dispersa/errorsAll 10 error classesError handling
dispersa/configdefineConfig, CliConfigCLI config files
dispersa/cliCLI entry pointInternal CLI runner

Values: Dispersa, css, json, js, tailwind, ios, android, defineRenderer, outputTree, isOutputTree, type guards (isColorToken, isDimensionToken, isShadowToken, isTypographyToken, isBorderToken, isDurationToken, isTransitionToken, isGradientToken), error classes

Types: OutputConfig, BuildConfig, BuildResult, BuildOutput, BuildError, ErrorCode, LifecycleHooks, DispersaOptions, ValidationOptions, ValidationMode, ResolvedToken, ResolvedTokens, TokenType, ModifierInputs, ResolverDocument, Transform, Filter, Preprocessor, Renderer, RenderContext, RenderMeta, PermutationData, RenderOutput, FormatOptions, OutputTree, SelectorFunction, MediaQueryFunction, DesignTokenValue, ColorToken, DimensionToken, ShadowToken, DurationToken, TypographyToken, BorderToken, TransitionToken, GradientToken, ColorValueObject, ColorValue, ColorSpace, ColorComponent, DimensionValue, DurationValue, ShadowValueObject, TypographyValue, BorderValue, TransitionValue, GradientValue, GradientStop, FontFamilyValue, FontWeightValue, CubicBezierValue, StrokeStyleValue, TokenValue, TokenValueReference, renderer options types, builder config types

import { Dispersa, css, json, defineRenderer } from 'dispersa'
import { isColorToken, isDimensionToken } from 'dispersa'
import type { BuildConfig, ResolvedToken, CssBuilderConfig } from 'dispersa'

Use for full build setups. Includes the Dispersa class, all builders, renderer utilities, type guard functions, error classes, and all public types.


Values: colorToHex, colorToRgb, colorToHsl, colorToOklch, colorToOklab, colorToLch, colorToLab, colorToHwb, colorToColorFunction, dimensionToPx, dimensionToRem, dimensionToUnitless, nameKebabCase, nameCamelCase, nameSnakeCase, namePascalCase, nameConstantCase, namePrefix, nameSuffix, nameCssVar, fontWeightToNumber, durationToMs, durationToSeconds

Types: Transform

import { colorToHex, nameKebabCase, dimensionToRem } from 'dispersa/transforms'
import type { Transform } from 'dispersa/transforms'

Use when you only need transforms. Keeps the main bundle smaller if you configure outputs elsewhere.


Values: byType, byPath, isAlias, isBase

Types: Filter

import { byType, byPath } from 'dispersa/filters'
import type { Filter } from 'dispersa/filters'

Use when you only need filters for token inclusion.


Values: css, json, js, tailwind, ios, android

Types: CssBuilderConfig, JsonBuilderConfig, JsBuilderConfig, TailwindBuilderConfig, IosBuilderConfig, AndroidBuilderConfig

import { css, json } from 'dispersa/builders'
import type { CssBuilderConfig } from 'dispersa/builders'

Use when you need only the builder functions, e.g. in a shared config file.


Values: defineRenderer, outputTree, isOutputTree

Types: Renderer, RenderContext, RenderMeta, PermutationData, RenderOutput, FormatOptions, OutputTree, BuildResult, BuildOutput, BuildError, ErrorCode, SelectorFunction, MediaQueryFunction, CssRendererOptions, JsonRendererOptions, JsModuleRendererOptions, TailwindRendererOptions, IosRendererOptions, AndroidRendererOptions

import { defineRenderer, outputTree } from 'dispersa/renderers'
import type { RenderContext, Renderer } from 'dispersa/renderers'

Use when building custom renderers. Lighter than the main entry if you don’t need Dispersa or builders. Also re-exports build result types and all renderer option types for convenience.


Exports: Preprocessor type

import type { Preprocessor } from 'dispersa/preprocessors'

Use when implementing custom preprocessors.


Exports: DispersaError, TokenReferenceError, CircularReferenceError, ValidationError, ColorParseError, DimensionFormatError, FileOperationError, ConfigurationError, BasePermutationError, ModifierError

import { TokenReferenceError, ValidationError } from 'dispersa/errors'

Use when you need to catch or handle specific error types, or implement custom error handling.


Exports: defineConfig, CliConfig

import { defineConfig } from 'dispersa/config'

Use in dispersa.config.ts to define a typed CLI configuration. defineConfig is an identity function that provides type checking and editor autocompletion.


Exports: CLI entry point

This is the internal entry point used by the dispersa CLI binary. You typically don’t import from this directly.