v24.0.0
Headlines
- We’ve re-platformed Coral to make use of Panda CSS in place of the previous styled-components.
- Coral now comes packaged with a light mode theme.
- Our colour token names have been updated to be more semantic and to remove reliance on qualifiers like
lightanddark. - The API for responsive props is updated to fit with Panda’s API, but also to make the API easier to use and understand at a glance.
- Theming has been overhauled to allow consumers to customise almost all aspects of the theme without needing esoteric configurations or hacks.
- The way we bundle Coral and all of its packages has changed to support tree-shaking, resulting in smaller bundle sizes for all consumers.
Upgrading your project
We’ve removed styled-components from the system, and replaced it with Panda CSS. This means that the configuration for Coral has changed significantly.
Upgrade to latest Blueprint
If your project uses Blueprint, you’ll need to upgrade to the latest versions of Blueprint packages before continuing with this Coral upgrade — this is because Blueprint depends on Coral.
pnpm update @krakentech/blueprint-utils@latest @krakentech/blueprint-onboarding@latest @krakentech/blueprint-dashboard@latest Install new dependencies
Install the new @krakentech/coral-design package that’s now required
pnpm add @krakentech/coral-design@latestInstall Panda CSS
Install the Panda CSS package as a dev dependency
pnpm add -D @pandacss/dev@latestUpgrade existing dependencies
Upgrade your existing Coral dependencies to the latest major versions
pnpm update @krakentech/coral@latest @krakentech/coral-charts@latest @krakentech/coral-formik@latest @krakentech/coral-media@latest @krakentech/coral-molecules@latest @krakentech/coral-organisms@latest @krakentech/coral-storyblok@latest @krakentech/icons@latestUpdate gitignore
Ignore the styled-system directory in your .gitignore file
# Panda CSS
styled-systemPanda configuration
Create a new file at the root of your app called panda.config.ts and add the following configuration
import { defineConfig } from '@pandacss/dev';
import { createCoralPreset, coralHooks, coralLayers } from '@krakentech/coral-design';
export default defineConfig({
presets: [createCoralPreset({})],
include: [
// Add any paths that may contain project files that consume Coral components
'./components/**/*.{js,jsx,ts,tsx}',
'./pages/**/*.{js,jsx,ts,tsx}',
// This is **mandatory** and must always be included
'./node_modules/@krakentech/coral-design/dist/panda.buildinfo.json',
],
exclude: [
// Exclude any files from static analysis, for example test files
],
// The following options do not need to be changed
preflight: false,
outExtension: 'js',
importMap: '@krakentech/coral-design',
jsxFramework: 'react',
syntax: 'object-literal',
strictPropertyValues: true,
hooks: coralHooks,
layers: coralLayers,
hash: true,
});Using Blueprint?
You’ll need to pass in build info from Blueprint to the include array within defineConfig as well.
"./node_modules/@krakentech/blueprint-utils/dist/panda.buildinfo.json",
"./node_modules/@krakentech/blueprint-dashboard/dist/panda.buildinfo.json",Panda PostCSS plugin
Create a new file at the root of your app called postcss.config.cjs and add the following configuration
module.exports = {
plugins: {
'@pandacss/dev/postcss': {},
},
};Panda CSS import
Create a new file at the root of your app called panda.css and add the following import
@layer reset, base, tokens, recipes, coral_utilities;In your _app.tsx file, import that panda.css file
import '../panda.css';Migrating
Start the journey of migrating from the old to the new.
Codemod
We have a codemod available to help with some of the changes in this release:
npx @krakentech/codemods coral-v24This CLI tool will guide you through modding files and should hopefully get you the majority of the way through the migration. This will attempt to migrate all files for you – there will be a lot of changes after running this command because of the nature of this release.
Review the API Changes section below to see if any of the components you use have breaking changes. You will need to update your code to accommodate these changes.
API Changes
CoralThemeProvider
CoralThemeProvider is now CoralConfigProvider.
Before:
import { CoralThemeProvider } from '@krakentech/coral';
<CoralThemeProvider>...</CoralThemeProvider>;After:
import { CoralConfigProvider } from '@krakentech/coral';
<CoralConfigProvider>...</CoralConfigProvider>;Styling is now controlled via panda.config.ts and not through the old CoralThemeProvider. Properties such as overrides, color or spacing have been migrated, with properties such as defaultIcons or LinkComponent being retained.
To learn more about the how to override styles, color, spacing etc, see the Migrate overrides from CoralThemeProvider section below.
GlobalCss
The <GlobalCss /> component has been removed, and global CSS is now handled by our Panda Coral Preset. If you want to override the Global CSS rules, you can read about this in the Basic Configuration section of our coral-design package.
Colour Tokens
The colour tokens have been updated to be more semantic and to remove reliance on qualifiers like light and dark.
| Old | New |
|---|---|
| base | colors.background.base.500 |
| base-main | colors.background.base.500 |
| base-dark | colors.background.base.900 |
| primary | colors.background.primary.500 |
| primary-main | colors.background.primary.500 |
| primary-main10 | colors.background.primary.10 |
| primary-light | colors.background.primary.100 |
| primary-dark | colors.background.primary.900 |
| primary-intense | colors.background.primary.600 |
| secondary | colors.background.secondary.500 |
| secondary-main | colors.background.secondary.500 |
| secondary-main10 | colors.background.secondary.10 |
| secondary-light | colors.background.secondary.100 |
| secondary-dark | colors.background.secondary.900 |
| tertiary | colors.background.tertiary.500 |
| tertiary-main | colors.background.tertiary.500 |
| tertiary-light | colors.background.tertiary.100 |
| tertiary-light10 | colors.background.tertiary.10 |
| tertiary-light20 | colors.background.tertiary.20 |
| main | colors.contents.base.900 |
| light | colors.contents.base.20 |
| dark | colors.contents.base.100 |
| text-main | colors.contents.base.900 |
| text-light | colors.background.base.200 |
| text-mid | colors.contents.primary.900 |
| text-mid20 | colors.background.base.20 |
| text-dark | colors.contents.base.100 |
| surface-main | colors.background.base.500 |
| surface-light | colors.background.base.100 |
| surface-mid | colors.background.secondary.900 |
| surface-dark | colors.background.base.900 |
| success | colors.background.actions.success.500 |
| success10 | colors.background.actions.success.10 |
| success30 | colors.background.actions.success.30 |
| successLight | colors.background.actions.success.100 |
| warning | colors.background.actions.warning.500 |
| warning10 | colors.background.actions.warning.10 |
| warning30 | colors.background.actions.warning.30 |
| warningLight | colors.background.actions.warning.100 |
| error | colors.background.actions.error.500 |
| error10 | colors.background.actions.error.10 |
| error30 | colors.background.actions.error.30 |
| errorLight | colors.background.actions.error.100 |
| info | colors.background.actions.information.500 |
| info10 | colors.background.actions.information.10 |
| info30 | colors.background.actions.information.30 |
| infoLight | colors.background.actions.information.100 |
Responsive Props
The API for responsive props has been updated to match Panda’s API. The new API is more intuitive and easier to use. Retrofitting to fit our old API would have been regressive and would negate the benefits of the new API.
Before:
<Accordion theme="midLight" lg={{ theme: 'dark' }}>
...
</Accordion>After:
<Accordion theme={{ base: 'secondary900', lg: 'base900' }}>...</Accordion>Compound Components
Compound components are no longer barrelled within the parent component, and must be imported and rendered individually, this allows Coral to better optimize its bundle size. For example:
<Breadcrumbs>
<Breadcrumbs.Link> ...now becomes
<Breadcrumbs>
<BreadcrumbsLink> ...This is relevant for the following components:
Atoms
- Breadcrumbs
- Blockquote
- Card
- Dropdown
- Grid
- List
- Radio
- Review
- Stack
- Switch
- ToggleButton
Molecules
- AppBanner
- CardGroup
- PageNavigation
Organisms
- CookiePreferences
- CreatePassword
- Footer
- Header
- Login
- ResetPassword
- All Formik equivalents of the above (ToggleButton, Radio, Switch)
General Changes
dataAttributes
The previously deprecated dataAttributes prop has been removed from all components. If you were using this prop, use attributes instead.
headerHeight
Previously you’d be able to get the configured headerHeight from useCoralTheme, this is now available from useCoralConfig instead.
Before
import { headerHeight } = useCoralTheme();After
import { headerHeight } = useCoralConfig();Component Changes - Atoms
Accordion
themevalues have changed:Before After darkbase900midbase500lightsecondary900
Alert
severityandthemeare now no longer responsive.themevalues have changed:Before After lightsemanticdarkbase900
Autocomplete
themevalues have changed:Before After lightbase100darksecondary500
Button
variant,sizeandcolorare now no longer responsive.colorvalues have changed:Before After primaryprimary500secondarysecondary500tertiarybase100
Container
-
maxWidthhas been split intomaxWidthandmaxWidthPreset. You can no longer passsm,md, etc. to themaxWidthproperty, as it only accepts valid values of the CSS property. If you are providing the breakpoint value, they need to be passed intomaxWidthPresetinstead.Before:
<Container maxWidth="lg">After:
<Container maxWidthPreset="lg"> -
themevalues have changed:Before After darkbase900lightbase100midbase500
Card
CardImage- No longer accepts a responsive
srcparameter positionhas been renamed tobackgroundPosition
- No longer accepts a responsive
bodyHeighthas been removed, and been replaced withheightapplied directly onCardBodythemevalues have changed:Before After lightbase100darkbase900midbase500midLightsecondary900tertiaryLighttertiary100
Checkbox
themevalues have changed:Before After lighttertiary500darksecondary500
Chip
variant,sizeandcolorare now no longer responsive.colorvalues have changed:Before After primaryprimary500secondarysecondary500tertiarytertiary500errorerror500warningwarning500successsuccess500
Dialog
maxWidthhas been renameddialogWidth
Drawer
positionis no longer responsive
Grid
templateAreasis now calledgridTemplateAreastemplateColumnsis now calledgridTemplateColumnstemplateRowsis now calledgridTemplateRowsareais now calledgridAreagap,rowGapandcolumnGapshould be set tononeand not0when setting the value to zero.
GridItem
colSpanhas been renamed togridColumn. It now requires you to manually addspanto the property, so what would previously have been, for example,colSpan={5}will now begridColumn="span 5".rowSpanhas been renamed togridRow. It now requires you to manually addspanto the property, so what would previously have been, for example,rowSpan={5}will now begridRow="span 5".colStarthas been renamed togridColumnStartcolEndhas been renamed togridColumnEndrowStarthas been renamed togridRowStartrowEndhas been renamed togridRowEnd
Link
colorvalues have changed:Before After darksecondary500lighttertiary500
Loader
colorvalues have changed:Before After primaryprimary500secondarysecondary500tertiarytertiary500basebase500textbase100
Radio
themevalues have changed:Before After lighttertiary500darksecondary500
Select
themevalues have changed:Before After lightbase100darksecondary500
Skeleton
- In order to remove animation, you should set
animation={undefined}rather thananimation={false}.
Slider
showLabelsandvalueLabelDisplayare now no longer responsive.
Stack
directionhas been renamedflexDirection. It now uses default CSS values (row,column, etc.) instead of the previous presethorizontal,verticaletc.gap,rowGapandcolumnGapshould be set tononeand0when setting the value to zero.
Switch
behaviouris now set on the parentSwitchrather thanSwitchInput
TextArea
themevalues have changed:Before After lightbase100darksecondary500
TextField
themevalues have changed:Before After lightbase100darksecondary500
Toast
toastIdis now calledcontainerId.
Tooltip
themevalues have changed:Before After midbase300lightbase100darkbase900
Typography
varianthas been renamedtextStyle, and is no longer responsive.- Additional
contentsvalues for thecolorprop have also been added, such ascontentsBase500,contentsBase900,contentsPrimary500,contentsSecondary500, etc. These are deemed safe text colours to use on top of the colour they reference in their name. - The values for the
colorprop have changed to match the new colour tokens, as below
| Old | New |
|---|---|
| base | base500 |
| base-main | base500 |
| base-dark | base900 |
| primary | primary500 |
| primary-main | primary500 |
| primary-main10 | primary10 |
| primary-light | primary100 |
| primary-dark | primary900 |
| primary-intense | primary600 |
| secondary | secondary500 |
| secondary-main | secondary500 |
| secondary-main10 | secondary10 |
| secondary-light | secondary100 |
| secondary-dark | secondary900 |
| tertiary | tertiary500 |
| tertiary-main | tertiary500 |
| tertiary-light | tertiary100 |
| tertiary-light10 | tertiary10 |
| tertiary-light20 | tertiary20 |
| main | base100 |
| light | base200 |
| dark | base900 |
| text-main | base100 |
| text-light | base200 |
| text-mid | contentsPrimary900 |
| text-mid20 | base20 |
| text-dark | base100 |
| surface-main | base500 |
| surface-light | base100 |
| surface-mid | secondary900 |
| surface-dark | base900 |
| success | success500 |
| success10 | success10 |
| success30 | success30 |
| successLight | success100 |
| warning | warning500 |
| warning10 | warning10 |
| warning30 | warning30 |
| warningLight | warning100 |
| error | error500 |
| error10 | error10 |
| error30 | error30 |
| errorLight | error100 |
| info | information500 |
| info10 | information10 |
| info30 | information30 |
| infoLight | information100 |
Component Changes - Molecules
ActionCard
themevalues have changed:Before After lightbase100darkbase900midbase500midLightsecondary900tertiaryLighttertiary100
CardGroup
directionnow acceptscolumn | row, rather thanvertical | horizontal- The
backgroundImageobject is no longer responsive onCardGroupCard
ErrorPage
PageNotFoundhas been removed
Footer
- The markup required to build a
Footerhas changed:- We no longer use
ListItem - The
Listcomponents renders as anavelement
- We no longer use
PageNavigation
PageNavigationItemandPageNavigationTogglenow accept aniconprop and only accepts astringas children.
Before:
<PageNavigationItem href="#">
<Stack alignItems="center" fullWidth>
<IconHome size={24} />
<Typography textStyle="button">Home</Typography>
</Stack>
</PageNavigationItem>After:
<PageNavigationItem href="#" icon={<IconHome size={24} />}>
Home
</PageNavigationItem>Component Changes - Formik
FormikTextField
themevalues have changed:Before After lightbase100darksecondary500
Component Changes - Charts
Animation has been removed from coral-charts, and the animation prop has been removed from all chart components. If you were using this prop, you will need to remove it from your code, as there is no alternative implementation. This is because there was no usage of the animation property by consumers, and the implementation was not particularly effective or useful.
Tokens
useCoralTheme()
useCoralTheme() no longer exists. You will need to make use of token from @krakentech/coral-design/tokens to access values previously accessed through useCoralTheme()
Before:
import { useCoralTheme } from '@krakentech/coral';
const { colors, spacing } = useCoralTheme();
<Component someProp={spacing.md} />
<Component otherProp={colors.primary.main} />After:
import { token } from '@krakentech/coral-design/tokens';
<Component someProp={token('spacing.md')} />
<Component otherProp={token('colors.background.primary.500')} />Colour
The colour tokens, like with Typography, have also been updated in line with the Colour Tokens section above.
Animation
Animation tokens have also been updated and expanded, and are now exported as follows:
| Before | After |
|---|---|
animation.duration | animation.duration.ms.asNumber |
animation.easing | animation.easing.asString |
animation.duration.ms.asString (new) | |
animation.duration.sec.asNumber (new) | |
animation.duration.sec.asString (new) | |
animation.easing.asArray (new) |
Migrate overrides from CoralThemeProvider
Note: Theming is more comprehensively explained in Basic and Advanced Configuration sections of the Design documentation.
Continuing on from above, here are some examples of how to migrate your overrides from the CoralThemeProvider to the new Panda CSS configuration.
Some migrations are fairly straightforward:
// CoralThemeProvider
overrides: {
typography: {
fontFamily: '"Figtree", sans-serif',
},
}
// panda.config.ts
createCoralPreset({
options: {
tokens: {
typography: {
fontFamily: '"Figtree", sans-serif',
},
}
}
}),However, declarations contained within overrides.components are likely to be considerably more complex. You may be able to set a basic token, however, you may also be required to apply the styles by extending the internal recipes instead.
For example, changing the colour of the Banner component is fairly straightforward:
// CoralThemeProvider
overrides: {
components: {
banner: {
root: {
background: 'red',
},
},
}
}
// panda.config.ts
createCoralPreset({
options: {
tokens: {
components: {
banner: {
secondary: {
background: 'red',
},
},
}
}
}
})However, adding a box shadow to the Card component would require you to extend the internal recipe:
// CoralThemeProvider
overrides: {
components: {
card: {
root: {
boxShadow: '0 0 10px rgba(0, 0, 0, 0.1)',
},
},
}
}
// panda.config.ts
createCoralPreset({
...
}),
theme: {
extend: {
recipes: {
StyledCard: {
base: partsList.cardParts({
root: {
boxShadow: '0 0 10px rgba(0, 0, 0, 0.1)',
},
})
}
}
}
}coral-storyblok
As Panda CSS is a build-time CSS-in-JS library, any arbitrary styles that you apply in Storyblok (think custom widths or heights) cannot be applied at build time, as the compiler cannot know that these values exist.
To account for this, we have introduced a GetStoryblokStaticCss hook that will generate the necessary CSS for the Storyblok components at build time.
However, to use this hook, you will need to ensure that you are using getStaticProps in your calls to getStoryblokApi. This is because GetStoryblokStaticCss needs to be able to pre-generate the CSS for the Storyblok components at build time, and this is only possible when the content for the page is pre-generated from the Storyblok API.
Your Storyblok page component could look something like this:
const Page: FC<{ story: ISbStoryData; css: any }> = ({ story: s, css }) => {
const story = useStoryblokState(s);
if (!story) {
return null;
}
return (
<Container
marginX="auto"
paddingX="sm"
paddingY="xl"
maxWidthPreset="md"
component="section"
>
<Head>
<style>{css}</style>
</Head>
<Stack flexDirection="column" gap="lg">
<Typography textStyle="hero2">{story.name}</Typography>
{story.content.body?.map((nestedBlok: SbBlokData) => (
<StoryblokComponent
key={nestedBlok._uid}
blok={nestedBlok}
/>
))}
</Stack>
</Container>
);
};
export default Page;
export const getStaticProps = async ({ params }) => {
const slug = params?.slug?.join('/') || 'home';
const { data } = await getStoryblokApi().get(`cdn/stories/${slug}`);
return {
props: {
story: data ? data.story : false,
css: data
? GetStoryblokStaticCss(data.story.content.body)
: undefined,
},
};
};styled-components
Although this new Panda-powered version of Coral and older styled-components code can co-exist, we recommend that you migrate away from styled-components in your project to avoid confusion and potential conflicts. Some migration options in order of preference:
- Swap old custom styled-components for Coral components and remove the custom styled-components
- For cases where you need custom CSS – re-write those styled-components to use Panda CSSÂ
To help with the first option above the Coral team have been on a worldwide mission to remove styled-components from all codebases , but as you can imagine this is no small task, and is still ongoing. However, once your project has migrated away from styled-components, you will be able to do the following:
- Remove
ServerStyleSheetfrom your_document.tsxfile - Remove
styled-componentspackage from your project
Light Mode
Coral now comes with a light colour mode baked into all components.
We’re currently working on a component that will allow users to switch between the colour modes and save that selection in local storage.
Light mode will work best when your project has migrated away from styled-components, and any other custom styles that don’t currently make use of Coral tokens. For now, please use this new Coral light mode as an incentive to migrate your custom styles to Coral components, or to Panda CSS. We will update with more soon!