File size: 1,392 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
title: Creating custom breakpoints
description: Learn how to create custom breakpoints in Chakra UI
publishedAt: "2024-11-15"
collection: theming
---

Custom breakpoints are defined in the `breakpoints` property of your theme.

```tsx title="components/theme.ts" /breakpoints: {/
const config = defineConfig({
  theme: {
    breakpoints: {
      xl: "80em" ,
      "2xl": "96em" ,
      "3xl": "120em" ,
      "4xl": "160em" ,
    },
  },
})

export const system = createSystem(defaultConfig, config)
```

Next, you add the new `system` to your `components/ui/provider.tsx` files

```tsx {3} /value={system}/
"use client"

import { system } from "@/components/theme"
import {
  ColorModeProvider,
  type ColorModeProviderProps,
} from "@/components/ui/color-mode"
import { ChakraProvider } from "@chakra-ui/react"

export function Provider(props: ColorModeProviderProps) {
  return (
    <ChakraProvider value={system}>
      <ColorModeProvider {...props} />
    </ChakraProvider>
  )
}
```

Next, you run the CLI `typegen` command to generate the types.

```bash
npx chakra typegen ./components/theme.ts
```

> Note: You might need to restart your TypeScript server for the types to be
> picked up.

## Using the breakpoint

With that in place, you can use the breakpoints when writing responsive styles.

```tsx /"4xl"/
<Box fontSize={{ base: "sm", "4xl": "lg" }}>Hello world</Box>
```