Style
/ API Reference
Style
/ API Reference

extend

A convenience helper to conditionally extend styles.
If you've used clsx (new tab) before, this is a similar concept.

The Gist

import { extend } from '@weser/style'

function style(variant: 'info' | 'error') {
  return {
    color: 'blue',
    fontSize: 16,
    ...extend(variant === 'error', {
      color: 'red',
      fontWeight: 700,
    }),
  }
}

Parameters

ParameterTypeDescription
conditionbooleanWhether to extend the styles.
styleTThe styles to extend.

Returns

(T_Style) A resolved style object. It either returns an empty object or the extended styles.

On this page