Migrating to v4 (See API changes)
- Using v4-rc.1
- Improvements
- Additions
- Deprecated
- Breaking Changes
DesygnaTheme
type scheme has changedstyled
has changed as$styled
variant
has changed as$variant
compose
has changed as$compose
composeAll
has changed as$composeAll
css
has changed as$css
background
has changed as$background
border
has changed as$border
color
has changed as$color
cursor
has changed as$cursor
flexbox
has changed as$flexbox
grid
has changed as$grid
layout
has changed as$layout
position
has changed as$position
shadow
has changed as$shadow
space
has changed as$space
typography
has changed as$typography
Using v4-rc.1
First, you need to install peer dependencies:
- npm
- Yarn
- pnpm
npm install @emotion/react@^11.10.0 @emotion/styled@^11.10.0 styled-system@^5.1.5 @styled-system/should-forward-prop@^5.1.5
yarn add @emotion/react@^11.10.0 @emotion/styled@^11.10.0 styled-system@^5.1.5 @styled-system/should-forward-prop@^5.1.5
pnpm add @emotion/react@^11.10.0 @emotion/styled@^11.10.0 styled-system@^5.1.5 @styled-system/should-forward-prop@^5.1.5
Install the package through npm
or yarn
:
Only the core package is available as version 4.0.0-rc.1
- npm
- Yarn
- pnpm
npm install @desygna/desygna-core@4.0.0-rc.1
yarn add @desygna/desygna-core@4.0.0-rc.1
pnpm add @desygna/desygna-core@4.0.0-rc.1
Improvements
Type-safety on theme variables
You can define your theme as a type definition, which will allow you to create components that are fully type-safe using your custom theme tokens. With this approach, you only need to include a few files to achieve this functionality.
By having a theme.ts file that defines your custom theme and a desygna.d.ts file that provides type definitions for the Desygna library, you can get typings in your code editor (such as VS Code). This means that your editor will provide autocomplete suggestions and type-checking for your custom theme properties, making it easier and faster to write type-safe components.
Additions
shouldForwardProp
$animation
system utility
DesygnaGenericProp
type
DesygnaGenericBreakpointValues
type
Deprecated
ResponsiveProp
type will be marked as deprecated
Breaking Changes
DesygnaTheme
type scheme has changed
styled
has changed as $styled
An example usage of v4
- Desygna v3
- Desygna v4
import { styled } from "@desygna/desygna";
export const Container = styled.div({
backgroundColor: "red",
padding: "10px",
borderRadius: "5px"
});
/**
*
* Changes:
* styled $styled
*
* Additions:
* shouldForwardProp
*
* You can use `shouldForwardProp` for prop forwarding
*
*/
import { $styled, shouldForwardProp } from "@desygna/desygna-core";
export type BoxProps = {
id?: string;
role?: string;
className?: string;
tabIndex?: number;
};
export const Box = $styled("div", {
shouldForwardProp
})<BoxProps>({
boxSizing: "border-box",
minWidth: 0,
transition: "all 0.2s ease"
});