--- title: Breakpoints description: "Learn how to customize breakpoints." --- :::tip Responsive design overview is [here](https://yamada-ui.com/docs/styling/responsive-design.md). ::: ## Overview Breakpoints are tokens used for responsive design, such as [Responsive Design](https://yamada-ui.com/docs/styling/responsive-design.md). The breakpoints defined in the theme are [here](https://github.com/yamada-ui/yamada-ui/blob/main/packages/react/src/theme/tokens/breakpoints.ts). ```tsx export const breakpoints = defineTokens.breakpoints({ sm: "30em", md: "48em", lg: "61em", xl: "80em", "2xl": "90em", }) ``` ## Customize ### Generate a Theme Use the [CLI](https://yamada-ui.com/docs/theming/cli.md) to generate a theme. :::warning Before running the following commands, you need to install `@yamada-ui/cli` and execute the `init` command. For more details, please see [here](https://yamada-ui.com/docs/get-started/cli.md). ::: ```bash pnpm yamada-cli theme ``` ```bash npm yamada-cli theme ``` ```bash yarn yamada-cli theme ``` ```bash bun yamada-cli theme ``` ### Change the Token Change the `tokens/breakpoints.ts` in the generated theme. ```tsx import { defineTokens } from "@yamada-ui/react" export const breakpoints = defineTokens.breakpoints({ sm: "27em", // [!code highlight] md: "48em", lg: "61em", xl: "80em", "2xl": "90em", }) ``` ### Update the Provider Set the generated theme to the `UIProvider`. ```tsx import { UIProvider } from "@workspaces/ui" import { theme } from "@workspace/theme" const App = () => { return ( ) } ``` ## Media Queries By default, the responsive design uses the `@media(max-width)` media query. ```tsx const config = defineConfig({ breakpoint: { direction: "up" } }) const Component: FC<{ query: string }> = ({ query }) => { const breakpoint = useBreakpoint() return ( The breakpoint when using{" "} {query} {" "} is "{breakpoint}". ) } return ( ) ``` If you want to use the `@media(min-width)` media query, set the `breakpoint.direction` to `"up"` in the config. ### Change the Config Change the `config.ts` in the generated theme. ```tsx import { defineConfig } from "@yamada-ui/react" export const config = defineConfig({ css: { varPrefix: "ui" }, breakpoint: { direction: "up", identifier: "@media screen" }, // [!code highlight] defaultColorMode: "light", defaultThemeScheme: "base", notice: { duration: 5000 }, theme: { responsive: true }, }) ``` ### Update the Provider Set the generated theme to `UIProvider`. ```tsx import { UIProvider } from "@workspaces/ui" import { theme, config } from "@workspace/theme" const App = () => { return ( ) } ``` ## Container Queries The responsive design uses the media query. If you want to use the container query, set the `breakpoint.identifier` to `"@container"` in the config. ```tsx const containerRef = useRef(null) const config = defineConfig({ breakpoint: { containerRef, identifier: "@container" }, }) const Component: FC<{ query: string }> = ({ query }) => { const breakpoint = useBreakpoint() return ( The breakpoint when using{" "} {query} {" "} is "{breakpoint}". ) } return ( ) ```