v10 Migration Guide
The new components available are a complete rewrite and therefore some of the props have changed.
You will need to reference the docs for each component to see how best to migrate each component
The new components are less opinionated and gives you better flexibility but this means that you will now be required to use tailwind and add your own className to your components to get the required styling.
Components
Where possible a guide for each component is included below to ease the transition from v10
Alert
Convert boolean props to variant, eg. info should convert to variant="information"
// v10
<Alert info />
// New
<Alert variant="information" />
Convert the margin prop to the equivalent Tailwind classes
// v10
<Alert margin={{ bottom: 3 }} />
// New
<Alert className="mb-3" />
Remove heading prop use the value inside a new <h2> element inside the <Alert>. Set heading classes with Tailwind.
// v10
<Alert heading="heading" />
// New
<Alert>
<h2 className="mb-3">Heading</h2>
</Alert>
Badge
Convert boolean props to variant, eg. info should convert to variant="information".
// v10
<Badge info />
// New
<Badge variant="information" />
numbered prop should convert to rounded prop
// v10
<Badge numbered />
// New
<Badge rounded />
ariaLabel prop should use the native DOM attribute aria-label
// v10
<Badge ariaLabel="Message" />
// New
<Badge aria-label="Message" />
Convert u-font-- classes to Tailwind font size equivalent classes
// v10
<Badge className="u-font--22" />
// New
<Badge className="text-[22px]" />
noRole prop can be removed, role in the new component is flipped so that you have to define it to add it
// v10
<Badge noRole />
// New
<Badge />
Box
Convert to a <div> with classes replacing the component
// v10
<Box></Box>
// New
<div></div>
Convert the margin prop to the equivalent Tailwind classes
// v10
<Box margin={{ bottom: 3 }}
// New
<div className="mb-3">
Convert the padding prop to the equivalent Tailwind classes
// v10
<Box padding={{ bottom: 3 }}
// New
<div className="pb-3">
Convert textAlign prop to corresponding Tailwind classes, eg. textAlign="center" to text-center
// v10
<Box textAlign="center" />
// New
<div className="text-center">
Convert alignSelf to corresponding Tailwind classes, eg. alignSelf="center" to self-center
// v10
<Box alignSelf="center" />
// New
<div className="self-center">
Convert width prop, this is responsive so will need multiple TW classes:
// v10
<Box width={{ xs: 100, sm: 50 }}>
// New
<div className="w-full sm:w-1/4">
Button Group
Convert the margin prop to the equivalent Tailwind classes
// v10
<ButtonGroup margin={{ bottom: 3 }} />
// New
<ButtonGroup className="mb-3" />
Convert boolean maxWidth prop to the Tailwind class flex-wrap and for the maxWidth="xs" use flex-wrap sm:flex-nowrap
// v10
<ButtonGroup maxWidth="xs" />
// New
<ButtonGroup className="flex-wrap sm:flex-nowrap" />
Boolean equalWidth and equalWidth="xs" needs to remove the prop and update the classes of the containing buttons with Tailwind classes to w-1/2 and w-1/2 sm:w-auto respectively to each Button
// v10
<ButtonGroup equalWidth="xs" />
// New
<ButtonGroup className="w-1/2 sm:w-auto" />
prev/next style example is achieved by reversing the order for mobile with css classes,
convert the className="u-flex--column-reverse u-flex-sm--row" to className="flex-col-reverse justify-end flex-wrap md:flex-row md:justify-start"
// v10
<ButtonGroup className="u-flex--column-reverse u-flex-sm--row" />
// New
<ButtonGroup className="flex-col-reverse justify-end flex-wrap md:flex-row md:justify-start" />
Button
- Convert the old boolean props to equivalent variant props eg.
<Button primary>to<Button variant="primary"> - Convert the
marginprop to the equivalent Tailwind classes - Convert
maxWidthandmaxWidth="xs"props toclassName="w-full"andclassName="w-full sm:w-fit"respectively - Convert
loadingprop to use the "Button Loading State" example
Checkbox
- Convert the
valuesprop tooptions - Convert boolean
inlineprop tovariant="inline"
Divider
- Remove
colorprop - Convert the
marginprop to the equivalent Tailwind classes - Convert
typeprop tovariant, this is literally a prop name change as the values are identical
Fieldset
- Convert to
<fieldset>and insert a<legend>using the<Fieldset legend>prop value. - Use the
idprop on the<fieldset id="..."> - Convert
labelHiddenprop to TW class on the legend , eg.<fieldset><legend className="sr-only">
Flex
Easy to convert using Tailwind classes for all of the props:
flexGrow=className="grow"or"grow-0"flexDirection=className="flex-col"or"flex-row"flexWrap=className="flex-wrap"justifyContent= https://tailwindcss.com/docs/justify-contentalignContent= https://tailwindcss.com/docs/align-contentalignItems= https://tailwindcss.com/docs/align-items- Convert the
marginprop to the equivalent Tailwind classes - Convert
heightprop fromu-height--to a spacing var, eg.h-300
Form
- Convert to dom element
<form> - Convert
noMarginprop to TW classmar-0
Heading
- Convert the
marginprop to the equivalent Tailwind classes - Convert
colorprop to Tailwind classes, eg.color="primary"toclassName="text-primary" - Convert
fontSizeprop to Tailwind classes, eg.fontSize="24"toclassName="text-600"however, there may be some font sizes that do not correspond to new sizing and may have to map to other sizes - Convert
textAlignprop to corresponding Tailwind classes, eg.textAlign="center"totext-center - Convert
sizeprop, this is used to set the Heading level so can be used to create the correct element, eg.<Heading size="2" fontSize="18">would become<h2 className="text-500"> - Convert
alignItemsto Tailwind class eg,alignItems="center"toclassName="items-center" - Convert
hiddenprop which is used per breakpoint to Tailwind classes,hidden="sm"tosm:max-md:hidden - Convert
visibleprop again per breakpoint,visible="sm"tohidden sm:max-md:visible
Icon
- Convert
ariaLabelto proper dom attributearia-label="" - Convert
color,fontSize,margin,hiddenandvisibleprops as above - Remove
ariaHidden - Remove
tabIndex
Image
- Convert to dom element
<img> - Convert the
marginprop to the equivalent Tailwind classes - Convert
height&widthprops to<img height="Ypx" width="Xpx"> - Convert
maxHeightto<img style="max-height: Ypx"> - Convert
fluidprop to TW classes:max-w-full h-auto" - Convert
print="none"to TW classclassName="print:hidden" - Convert
print="visible"toclassName="visible"
Input
- Convert
ariaLabelandariaControlsprops to native attributesaria-labelandaria-controls
InputGroup
- Convert
ariaLabelprop to native dom attributearia-label - Remove
loadingprop, use the Button Loading State example
LicencePlate
Use the Number Plate example
Label/Legend
- Convert the
marginprop to the equivalent Tailwind classes - Convert the
hiddenprop to TW classclassName="sr-only"
Link
- Convert boolean variants such as 'primary' to the variant prop equivalent eg.
variant="primary" - Convert
buttonprop to variant equivalents eg.button="primaryOutline"becomesvariant="buttonPrimaryOutline" - Convert
alignTopto TW class:className="items-start" - Convert
whiteprop tovariant="inverse" - Convert
noWrapprop to TW class:className="whitespace-nowrap" - Convert
maxWidthprop to TW classes,maxWidth===className="w-full",maxWidth="xs"===className="xs:max-sm:w-full"(just xs as per v10 prop)
List
This may need a multi-component approach eg:
- Convert
<List>to<ul>with appropriate TW classes - Convert
<ListItem>to<li>with appropriate TW classes - Convert
<ListItemContent>to<div>with appropriate TW classes
<List> props to TW classes:
inlinetoclassName="flex"bullettoclassName="list-disc"numberedtoclassName="list-decimal"bordertoclassName="divide-y"
<ListItem> props to TW classes:
- Convert the
marginprop to the equivalent Tailwind classes - Convert the
paddingprop to the equivalent Tailwind classes
<ListItemContent> props to classes:
spaceBetweentojustify-betweencolumntoflex-colalignItems="start|center|end"toitems-start|items-center|items-endverticalCentertoitems-center
Main
- Convert to native
<main>dom element - Convert the
marginprop to the equivalent Tailwind classes - Convert the
paddingprop to the equivalent Tailwind classes - Convert
maxHeightto TW classes:className="flex grow" - Convert
columnto TW:className="flex flex-col"
Price
- Convert
fontSizeprop to Tailwind classes, eg.fontSize="24"toclassName="text-600" - Convert the
marginprop to the equivalent Tailwind classes - Remove
ignoreDecimals,roundAmountandhideDecimalsprops, new component simply displays the amount value
Radio
- Convert
valuesprop name tooptions
RadioBlock
- Convert
valuesprop name tooptions - Convert the
marginprop to the equivalent Tailwind classes - Convert
columnprop to TW classes, note the new version only allows for columns to display in a small and up breakpoint, xs will stack. The only options available are 2 - 6 so if the largest breakpoint value is > 6, use 6
<RadioBlock columns={{ xs: 6, md: 6 , lg: 12 }}>
// becomes
<RadioBlock cols="6">
SegmentedControl
- Convert
valuesprop name tooptions
Message
- Convert boolean variants to the variant prop, eg.
infotovariant="information" - Convert the
marginprop to the equivalent Tailwind classes
Select
- Convert
valuesprop name tooptions
Spinner
- Convert the
marginprop to the equivalent Tailwind classes - Convert
whiteprop tovariant="inverse" - Remove
brandprop
Text
- The
<Text>component does not exist in the new Chroma components and need to be convert to a<p>however there are a number of helper props that will need to be converted into the equivalent Tailwind classes - Convert
colorprop to Tailwind classes, eg.color="primary"toclassName="text-primary" - Convert
fontSizeprop to Tailwind classes, eg.fontSize="24"toclassName="text-600"however, there may be some font sizes that do not correspond to new sizing and may have to map to other sizes - Convert
weightprop to corresponding Tailwind classes, eg.weight={700}tofont-700 - Convert
textAlignprop to corresponding Tailwind classes, eg.textAlign="center"totext-centerhowever, this prop is responsive so will also need to be able to convert the following:
<Text textAlign={{ xs: 'center', sm: 'left' }}>
// to
<p className="text-center sm:text-left">
- Convert boolean
inlineprop to Tailwind classclassName="inline" - Convert the
marginprop to the equivalent Tailwind classes