Utility functions
import {
createTextStyle,
getColorHex,
getBackgroundStyle,
getContrastTextColor,
isColorDark,
getCurrentLanguageCode,
} from '@lightspeed/crane-api';Reference
Function
Arguments
Purpose
Examples
const titleDesign = useTextElementDesign<Design>('title');
const titleStyle = computed(() =>
createTextStyle(titleDesign, { defaultSize: 24 }),
);
const dark = isColorDark('#1F2937');
const textColor = getContrastTextColor('#1F2937');
const textColorCustom = getContrastTextColor('#1F2937', '#111111', '#FAFAFA');
const bgDesign = useBackgroundElementDesign<Design>('section_bg');
const bgValue = getBackgroundStyle(bgDesign, { fallbackColor: '#FFFFFF' });Notes
getBackgroundStyle — gradient fallback behaviour
getBackgroundStyle — gradient fallback behaviouruseButtonStyles — font weight is always 400
useButtonStyles — font weight is always 400Last updated
Was this helpful?
