Style
/ API ReferenceStyle
/ API Referenceextend
A convenience helper to conditionally extend styles.
If you've used clsx 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
| Parameter | Type | Description |
|---|---|---|
| condition | boolean | Whether to extend the styles. |
| style | T | The styles to extend. |
Returns
(T_Style) A resolved style object. It either returns an empty object or the extended styles.
© 2024-present Robin Weser. All Rights Reserved.