JSPM

@sanity/color-input

0.136.3-purple-unicorn-patch.5627+c8b4b71ac
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 34129
  • Score
    100M100P100Q150041F
  • License MIT

Color input

Package Exports

  • @sanity/color-input
  • @sanity/color-input/schemas/color
  • @sanity/color-input/schemas/hslaColor
  • @sanity/color-input/schemas/hsvaColor
  • @sanity/color-input/schemas/rgbaColor

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sanity/color-input) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@sanity/color-input

Color input for Sanity that stores selected colors in hex, hsl, hsv and rgb format.

Installation

sanity install @sanity/color-input

Usage

Use it in your schema types:

// [...]
{
  fields: [
    // [...]
    {
      name: 'favoriteColor',
      title: 'Favorite color',
      type: 'color'
    }
  ]
}

Note that the above only works if you import and use the all:part:@sanity/base/schema-type part in your schema.

Options

To disable the alpha option, set disableAlpha to true:

// ...fields...
{
  name: 'favoriteColor',
  title: 'Favorite color',
  type: 'color',
  options: {
    disableAlpha: true
  }
}

Data model

{
  _type: 'color',
  hex: '#29158a',
  alpha: 0.9,
  hsl: {
    _type: 'hslaColor',
    h: 249.99999999999994,
    s: 0.7328000000000001,
    l: 0.313,
    a: 0.9
  },
  hsv: {
    _type: 'hsvaColor',
    h: 249.99999999999994,
    s: 0.8457987072945522,
    v: 0.5423664,
    a: 0.9
  },
  rgb: {
    _type: 'rgbaColor',
    r: 41
    g: 21,
    b: 138,
    a: 0.9
  }
}

License

MIT-licensed. See LICENSE.