Specify Docs
Specify ↗︎Changelog ↗︎Guide ↗︎
V2
V2
  • Getting started
    • Introduction
    • What is Specify?
    • Pulling your first tokens with the CLI
    • Glossary
  • Collect
    • What is a Source?
    • Available sources
      • Figma Variables & Styles
      • Tokens Studio
  • Distribute
    • What is a Destination?
    • Available destinations
      • GitHub
      • Specify CLI
      • Specify SDK
      • HTTP API
  • Concepts
    • Overview
    • Parsers Engine
    • SDTF Client
      • SDTF Engine
    • Specify Design Token Format
  • Guides
    • Configuration file 101
    • Specify CLI usage 101
      • Getting started
      • Authentication
      • Generate Files
    • Specify SDK usage 101
      • Getting started
      • Retrieving and working with the tokens
      • Updating tokens
      • Converting a token to XXX
      • Executing generation parsers
    • Specify SDK Cheatsheet
    • Manage font files
    • Querying a SDTF graph
  • Reference
    • Parsers Engine
    • Parsers
      • change-case
      • convert-color
      • convert-dimension
      • make-line-height-relative
      • filter
      • register-view
      • select-modes
      • prefix-by
      • suffix-by
      • replace-string
      • to-css-custom-properties
      • to-css-text-style
      • to-css-font-import
      • to-flutter
      • to-javascript
      • to-json
      • to-json-list
      • to-kotlin
      • to-react-native
      • to-scss-mixin-text-style
      • to-scss-map
      • to-sdtf
      • to-style-dictionary
      • to-swift
      • to-tailwind
      • to-typescript
      • svgo
      • svg-to-jsx
      • svg-to-tsx
      • to-svg-file
      • to-bitmap-file
      • to-file
    • Specify SDK
      • SpecifyClient
      • SDTFClient
      • Converters
        • CSS
      • ParsersEngineResults
    • SDTF Engine
      • Query API
      • Mutation API
      • SDTF Query Language
      • SDTF QueryResult
      • TokenState
        • Stateful Value
    • HTTP API
      • POST /parsers-engine-rpc
    • Specify CLI
  • Resources
    • Parser Rules templates
      • CSS Custom Properties
      • Tailwind
      • React Native
      • Flutter
      • SDTF
      • JSON
    • Specify CLI VS Specify SDK
    • Playground
    • Best practices
  • Useful links
    • Discord
    • YouTube
    • Twitter
    • Help Center
    • Canny
Powered by GitBook
On this page
  • Primitives tokens
  • Border
  • Breakpoint
  • Color
  • Cubic bezier
  • Dimension
  • Duration
  • Font weight
  • Gradient
  • Gradients
  • Opacity
  • Radii
  • Radius
  • Shadow
  • Shadows
  • Spacing
  • Spacings
  • Steps timing function
  • Z-index
  • Composites tokens
  • Font
  • Text style
  • Transition

Was this helpful?

Export as PDF
  1. Reference
  2. Specify SDK
  3. Converters

CSS

To convert a token to CSS, you can import all the functions under the CSS namespace: @specifyapp/sdk/css

import { dimensionToCss, colorToCss, ... } from '@specifyapp/sdk/css';

Primitives tokens

Here is the list of the primitives tokens for the CSS parser with an example of their respective output type.

Border

Input:

{
  color: { model: 'hex', hex: '#ffffff', alpha: 0.5 },
  style: 'dashed',
  width: {
    value: 12,
    unit: 'px',
  },
  rectangleCornerRadii: null,
}

Output:

'12px dashed #ffffff80'

Breakpoint

Input:

{
  value: 12,
  unit: 'rem'
}

Output:

'12rem'

Color

RGB

Input:

{
  model: 'rgb',
  red: 12,
  green: 12,
  blue: 12,
  alpha: 0.5,
}

Output:

'rgba(12, 12, 12, 0.5)'

HEX

Input:

{
  model: 'hsb',
  hue: 12,
  saturation: 12,
  brightness: 12,
  alpha: 0.1,
}

Output:

'hsva(12, 12%, 12%, 0.1)'

HSB

Input:

{
  model: 'hex',
  hex: '#ff00ff',
  alpha: 0.5,
}

Output:

'#ff00ff80'

HSL

Input:

{
  model: 'hsl',
  hue: 12,
  saturation: 12,
  lightness: 12,
  alpha: 0.5,
}

Output:

'hsla(12, 12%, 12%, 0.5)'

LAB

Input:

{
  model: 'lab',
  bAxis: 12,
  aAxis: 12,
  lightness: 12,
  alpha: 0.5,
}

Output:

'lab(12% 12 12 / 0.5)'

LCH

Input:

{
  model: 'lch',
  chroma: 12,
  hue: 12,
  lightness: 12,
  alpha: 1,
}

Output:

'lch(12% 12 12)'

Cubic bezier

Input:

[0.12, 0.21, 0.12, 0.21]

Output:

'cubic-bezier(0.12, 0.21, 0.12, 0.21)'

Dimension

Input:

{
  value: 12,
  unit: 'px'
}

Output:

'12px'

Duration

Input:

{
  value: 1,
  unit: 's'
}

Output:

"1s"

Font weight

Input:

900

Output:

"900'

Gradient

Conic

Input:

{
  type: 'conic',
  colorStops: [
    {
      color: {
        model: 'hex',
        hex: '#ffffff',
        alpha: 1,
      },
      position: 0,
    },
    {
      color: {
        model: 'hex',
        hex: '#ffff00',
        alpha: 1,
      },
      position: 1,
    },
  ],
  angle: 12,
  position: 'center',
}

Output:

'conic-gradient(from 12deg at center, #ffffff 0%, #ffff00 100%)'

Linear

Input:

{
  type: 'linear',
  colorStops: [
    {
      color: {
        model: 'hex',
        hex: '#ffffff',
        alpha: 1,
      },
      position: 0,
    },
    {
      color: {
        model: 'hex',
        hex: '#ffff00',
        alpha: 1,
      },
      position: 1,
    },
  ],
  angle: 12,
}

Output:

'linear-gradient(12deg, #ffffff 0%, #ffff00 100%)'

Radial

Input:

{
  type: 'radial',
  colorStops: [
    {
      color: {
        model: 'hex',
        hex: '#ffffff',
        alpha: 1,
      },
      position: 0,
    },
    {
      color: {
        model: 'hex',
        hex: '#ffff00',
        alpha: 1,
      },
      position: 1,
    },
  ],
  position: 'center',
}

Output:

'radial-gradient(circle at center, #ffffff 0%, #ffff00 100%)'

Gradients

Input:

[
  {
    type: 'conic',
    colorStops: [
      {
        color: {
          model: 'hex',
          hex: '#ffffff',
          alpha: 1,
        },
        position: 0,
      },
      {
        color: {
          model: 'hex',
          hex: '#ffff00',
          alpha: 1,
        },
        position: 1,
      },
    ],
    angle: 12,
    position: 'center',
  },
  {
    type: 'linear',
    colorStops: [
      {
        color: {
          model: 'hex',
          hex: '#ffffff',
          alpha: 1,
        },
        position: 0,
      },
      {
        color: {
          model: 'hex',
          hex: '#ffff00',
          alpha: 1,
        },
        position: 1,
      },
    ],
    angle: 12,
  },
]

Output:

'conic-gradient(from 12deg at center, #ffffff 0%, #ffff00 100%), linear-gradient(12deg, #ffffff 0%, #ffff00 100%)'

Opacity

Input:

0.1

Output:

'0.1'

Radii

Input:

[
  { unit: 'px', value: 12 },
  { unit: '%', value: 24 },
]

Output:

'12px 24%'

Radius

Input:

{ unit: 'px', value: 24 }

Output:

'24px'

Shadow

Input:

{
  color: { model: 'hex', hex: '#ffffff', alpha: 1 },
  offsetX: { value: 12, unit: 'px' },
  offsetY: { value: 12, unit: 'px' },
  blurRadius: { value: 12, unit: 'px' },
  spreadRadius: { value: 12, unit: 'px' },
  type: 'inner',
}

Output:

'inset 12px 12px 12px 12px #ffffff'

Shadows

Input:

[
  {
    color: { model: 'hex', hex: '#ffffff', alpha: 1 },
    offsetX: { value: 12, unit: 'px' },
    offsetY: { value: 12, unit: 'px' },
    blurRadius: { value: 12, unit: 'px' },
    spreadRadius: { value: 12, unit: 'px' },
    type: 'inner',
  },
  {
    color: { model: 'hex', hex: '#ffffff', alpha: 1 },
    offsetX: { value: 12, unit: 'px' },
    offsetY: { value: 12, unit: 'px' },
    blurRadius: { value: 12, unit: 'px' },
    spreadRadius: { value: 12, unit: 'px' },
    type: 'inner',
  },
]

Output:

'inset 12px 12px 12px 12px #ffffff, inset 12px 12px 12px 12px #ffffff'

Spacing

Input:

{ unit: 'px', value: 24 }

Output:

'24px'

Spacings

Input:

[
  { unit: 'px', value: 12 },
  { unit: '%', value: 24 },
  { unit: 'rem', value: 4 },
]

Output:

'12px 24% 4rem'

Steps timing function

Input:

{
  stepsCount: 2,
  jumpTerm: 'start',
}

Output:

'steps(2, start)'

Z-index

Input:

10

Output:

"10"

Composites tokens

Here is the list of the composites tokens for the CSS parser with an example of their respective output type.

Font

Input:

{
  family: 'fontFamily',
  postScriptName: 'Postscript',
  files: [],
  weight: 'bold',
  style: 'italic',
}

Output:

{
  'font-style': 'italic',
  'font-family': "'Postscript'",
  'font-weight': 'bold',
}

Text style

Input:

{
  font: {
    family: 'textStyleFamily',
    postScriptName: 'Postscript',
    files: [],
    weight: 'bold',
    style: 'italic',
  },
  color: {
    model: 'hex',
    hex: '#ffffff',
    alpha: 0.5,
  },
  fontSize: { value: 12, unit: 'em' },
  fontFeatures: ['all-petite-caps'],
  lineHeight: { value: 12, unit: 'rem' },
  letterSpacing: { value: 12, unit: 'rem' },
  paragraphSpacing: { value: 12, unit: 'rem' },
  textAlignHorizontal: 'center',
  textAlignVertical: 'bottom',
  textDecoration: 'dashed',
  textIndent: { value: 12, unit: 'rem' },
  textTransform: 'capitalize',
}

Output:

{
  'font-style': 'italic',
  'font-family': "'Postscript'",
  'font-weight': 'bold',
  'font-size': '12em',
  color: '#ffffff80',
  'text-indent': '12rem',
  'line-height': '12rem',
  'letter-spacing': '12rem',
  'text-align': 'center',
  'text-transform': 'capitalize',
  'text-decoration': 'dashed',
}

Transition

Input:

{
  duration: {
    value: 12,
    unit: 's',
  },
  delay: {
    value: 10,
    unit: 'ms',
  },
  timingFunction: {
    jumpTerm: 'end',
    stepsCount: 2,
  },
}

Output:

{
  delay: '10ms',
  duration: '12s',
  'timing-function': 'steps(2, end)',
}
PreviousConvertersNextParsersEngineResults

Last updated 1 year ago

Was this helpful?