Skip to content

Resources

Migrating from 1.x

cherry 2.0 ships as @cherry-design-system/react. It replaces cherry-styled-components (cherry 1.x) and drops styled-components: components ship static CSS and are styled through --cherry-* tokens. It keeps the 1.x theme behavior (light, dark and system, with the same storage keys and cookie), so visitors keep their mode across the upgrade.

The 1.x documentation stays available at /v1 while you migrate.

Install

Remove the old packages and add the new one:

npm uninstall cherry-styled-components styled-components
npm install @cherry-design-system/react lucide-react

Keep styled-components if your own code still uses it; cherry 2.0 no longer needs it. In Next.js, you can also drop compiler.styledComponents from next.config.ts once nothing else depends on it.

Setup

1.x2.0
CherryThemeProvider / ClientThemeProvider with theme and themeDarkImport @cherry-design-system/react/styles.css once. No provider.
StyledComponentsRegistry (cherry-styled-components/next)Not needed: the CSS is static.
themeInitScript / createThemeInitScript({ themeColor })Same names, from @cherry-design-system/react/theme-init. themeColor is { light, dark } or false.
resolveTheme(cookie, theme, themeDark)modeFromCookie(cookie) returns "light" or "dark".
ThemeContext { toggleTheme, setPreference }, useColorMode()useColorMode() returns { mode, preference, setPreference, toggle }.
useResolvedTheme() (JS theme values)Read --cherry-* CSS variables instead.
Custom theme objectscreateBrand(name, { accent, primary }) for a scoped brand, or override --cherry-l-* / --cherry-d-* in your own CSS.

Root layout

tsx
// app/layout.tsx
import { StyledComponentsRegistry } from "cherry-styled-components/next";
import { ClientThemeProvider, themeInitScript } from "cherry-styled-components";
import { theme, themeDark } from "./theme";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <head>
        <script dangerouslySetInnerHTML={{ __html: themeInitScript }} />
      </head>
      <body>
        <StyledComponentsRegistry>
          <ClientThemeProvider theme={theme} themeDark={themeDark}>
            {children}
          </ClientThemeProvider>
        </StyledComponentsRegistry>
      </body>
    </html>
  );
}

className="cherry-root" on <body> replaces the global styles the provider used to inject: it applies the canvas color, text color and font. See Installation.

Reading the mode

tsx
"use client";
import { useContext } from "react";
import { ThemeContext } from "cherry-styled-components";

export function ModeButton() {
  const { toggleTheme } = useContext(ThemeContext);
  return <button onClick={toggleTheme}>Toggle mode</button>;
}

On the server, replace resolveTheme with modeFromCookie:

tsx
import { cookies } from "next/headers";
import { modeFromCookie } from "@cherry-design-system/react/theme-init";

const mode = modeFromCookie((await cookies()).get("theme")?.value); // "light" | "dark"

The stored preference (themePreference, and the legacy theme key) and the theme cookie are read as before. See Dark mode.

Custom themes

tsx
import { theme as base, ClientThemeProvider } from "cherry-styled-components";

const theme = {
  ...base,
  colors: { ...base.colors, primary: "#5b5bd6" },
};

<ClientThemeProvider theme={theme}>{children}</ClientThemeProvider>;

See Brands for the full API and for overriding the --cherry-l-* / --cherry-d-* slots directly.

Props

  • The $ prefix is gone: $variant becomes variant, $size becomes size, $fullWidth becomes fullWidth.
  • Sizes are sm, md and lg (32, 36 and 44px) instead of small, default and big.
  • $error becomes invalid, or wrap the control in <Field error="...">. There is no success state; drop $success.
  • $label on inputs moves to <Field label="...">.
  • Icon props take a rendered element: leadingIcon={<Plus />}.
tsx
import { Button, Input } from "cherry-styled-components";

<Button $variant="secondary" $size="big" $fullWidth>
  Save
</Button>

<Input type="email" $label="Email" $error={!!errors.email} $fullWidth />

Values must be one of the listed options. An unknown value, such as a leftover size="big", renders unstyled instead of throwing. Check each component's Properties section.

Renamed or changed components

1.x2.0
ToastNotificationsProvider, ToastNotifications, useToastNotificationsToastProvider, Toaster, useToast
BoxCard
Col / Grid / Flex / ContainerSame names; responsive props take one value or { xs, md, lg, ... }
MaxWidth, SpaceRemoved: use Container and gap
Icon / DynamicIconImport lucide icons directly
ChatProviderRemoved: chat parts are controlled through props
modes(), modeValue(), alpha / shade / tint, mq()Not needed: write CSS against --cherry-* tokens and @media

Toasts

addNotification becomes show, promiseNotification becomes promise, and the Toaster props lose their $: $align, $bottom, $expand and $visibleToasts become align, position, expand and visibleToasts.

tsx
"use client";
import {
  ToastNotifications,
  ToastNotificationsProvider,
  useToastNotifications,
  Button,
} from "cherry-styled-components";

export function Providers({ children }: { children: React.ReactNode }) {
  return (
    <ToastNotificationsProvider>
      <ToastNotifications $bottom $align="right" />
      {children}
    </ToastNotificationsProvider>
  );
}

export function SaveButton() {
  const { addNotification, promiseNotification } = useToastNotifications();
  return (
    <Button
      onClick={() => {
        addNotification("Changes saved", { color: "success", autoHide: 4000 });
        promiseNotification(publishPost(), {
          loading: "Publishing your post",
          success: (post) => `Published "${post.title}"`,
          error: "Couldn't publish",
        }).catch(() => {});
      }}
    >
      Save
    </Button>
  );
}

useToast() returns { toasts, show, update, dismiss, remove, promise }. show takes the same options as before (color, autoHide, description, action, dismissible, id) and returns the toast's id. See Toast.

Layout

Responsive props no longer use one prop per breakpoint ($xsCols, $lgSpan, $mdGap). Each prop takes a single value or an object keyed by breakpoint, mobile first. Gaps and padding are spacing steps (gap={4} is 16px), not pixels.

tsx
import { Container, Grid, Col, Space, MaxWidth } from "cherry-styled-components";

<Container>
  <MaxWidth $size={800}>
    <Grid $xsCols={1} $lgCols={3} $gap={20}>
      <Col $lgSpan={2}>Main</Col>
      <Col>Aside</Col>
    </Grid>
    <Space $size={40} />
  </MaxWidth>
</Container>

MaxWidth and Space are gone: use Container for page width and gap on Flex, Stack or Grid for spacing. Constrain a narrower column with a class of your own if you need one. See Grid and Flex.

Box to Card

tsx
// 1.x
<Box>...</Box>

// 2.0
import { Card, CardTitle, CardDescription } from "@cherry-design-system/react";

<Card variant="outline">
  <CardTitle level={3}>Usage</CardTitle>
  <CardDescription>2,431 requests this month.</CardDescription>
</Card>

Icons

Icon and DynamicIcon are removed. Import the lucide glyphs you use and pass the element:

tsx
import { Button } from "@cherry-design-system/react";
import { Plus } from "lucide-react";

<Button leadingIcon={<Plus />}>New project</Button>

Styling your own components

Target cherry's stable hooks instead of styled-components interpolations, and read tokens instead of theme values:

tsx
import styled from "styled-components";
import { Button } from "cherry-styled-components";

const WideButton = styled(Button)`
  width: 100%;
  color: ${({ theme }) => theme.colors.grayDark};
`;

Every cherry rule is in @layer cherry, so your unlayered CSS wins without !important. style-api.json lists every class, data attribute and value. See Styling and Tokens.

Agent skill

If your coding agent used the 1.x cherry-design-system skill, install the 2.0 cherry-react skill for projects on the new package. The two can be installed side by side. See Skill for AI agents.