MCPcopy Create free account
hub / github.com/adobe/react-spectrum / toString

Method toString

packages/react-stately/src/color/Color.ts:511–526  ·  view source on GitHub ↗
(format: ColorFormat | 'css' = 'css')

Source from the content-addressed store, hash-verified

509 }
510
511 toString(format: ColorFormat | 'css' = 'css') {
512 switch (format) {
513 case 'css':
514 return this.toHSL().toString('css');
515 case 'hex':
516 return this.toRGB().toString('hex');
517 case 'hexa':
518 return this.toRGB().toString('hexa');
519 case 'hsb':
520 return `hsb(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%)`;
521 case 'hsba':
522 return `hsba(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.brightness, 2)}%, ${this.alpha})`;
523 default:
524 return this.toFormat(format).toString(format);
525 }
526 }
527
528 toFormat(format: ColorFormat): IColor {
529 switch (format) {

Callers

nothing calls this directly

Calls 5

toHSLMethod · 0.95
toRGBMethod · 0.95
toFormatMethod · 0.95
toFixedNumberFunction · 0.90
toStringMethod · 0.65

Tested by

no test coverage detected