Read the documentation on its replacement, which should be used for any new development.
We provide a Volvo Cars type scale for use across Volvo Cars digital ecosystem. It contains several distinct styles, some of which have sub-styles to portray more specific intentions
The variant prop defines the type style used, with Columbus being the default:
Each variant comes with its own sensible default HTML element, which can be overridden using the as
prop to fit your needs:
Some variants have their own sub-styles. These are for use cases where you may need to render a link, or emphasise a portion of text. You can set them with the subStyle
prop, for example:
The above examples use the default Columbus variant, but sub-styles are available for Hillary and Bates too:
Sub-styles can also be set without needing to explicitly set their parent variant too, this can be useful for cases where you are dynamically rendering text:
There may be occasions where you would like to use values from the existing type scale, or perhaps even make minor adjustments to the existing styles. For these cases, we provide two options:
As with many core components in VCC-UI, we have left the extend prop open on the Text component. Styles can be passed in as you would with a <Block>
element or similar:
The styles for all of the type scales are written in a notation that can be directly applied to any extend property. These styles are packaged as part of the theme, and can be loaded in like so:
const { typeScale } = useTheme();const { peary } = typeScale; // Contains "standard", "inline-link" and "emphasis"return (<Blockas={peary.standard.element}extend={{...peary.standard.styles,fontSize: '2rem',color: 'teal',}}>This is a custom variation of Peary.</Block>);
Name | Description | Type | Default Value |
---|---|---|---|
as | As<any> | n/a | |
extend | A CSS object or a function returning a CSS object, or an array of them | ExtendPropValue<CurrentTheme, { foreground?: ResponsiveProp<(('${string}var(--${string})${string}' | '${string}calc(${string})${string}' | Color) & (Omit<string, ""> | "foreground.primary" | "foreground.secondary" | "foreground.inverted" | "foreground.positive" | "foreground.alert" | "foreground.action")) | undefine... | n/a |
fg | ResponsiveProp<(('${string}var(--${string})${string}' | '${string}calc(${string})${string}' | Color) & (Omit<string, ""> | "foreground.primary" | "foreground.secondary" | "foreground.inverted" | "foreground.positive" | "foreground.alert" | "foreground.action")) | undefined> | n/a | |
foreground | ResponsiveProp<(('${string}var(--${string})${string}' | '${string}calc(${string})${string}' | Color) & (Omit<string, ""> | "foreground.primary" | "foreground.secondary" | "foreground.inverted" | "foreground.positive" | "foreground.alert" | "foreground.action")) | undefined> | n/a | |
ref | any | n/a | |
subStyle | ResponsiveProp<"standard" | "inline-link" | "emphasis"> | undefined | n/a | |
variant | * Amundsen (action text) - 14px * Bates - 12px * Columbus (default) - 16px * Cook - 32px / 36px / 40px * Hillary - 20px * Ootah - 24px / 28px / 32px * Peary - 48px / 52px / 56px * Yang (brand statement) - 40px / 72px / 72px * Kelly - 14px * Meir - 8px | ResponsiveProp<TypeVariants> | undefined | n/a |