---
title: ブレイクポイント
description: "ブレイクポイントをカスタマイズする方法を学ぶ。"
---
:::tip
レスポンシブデザインの概要は[こちら](https://yamada-ui.com/docs/styling/responsive-design.md)をご覧ください。
:::
## 概要
ブレイクポイントは、[レスポンシブデザイン](https://yamada-ui.com/docs/styling/responsive-design.md)などで使用されるトークンです。
テーマに定義されているブレイクポイントは[こちら](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",
})
```
## カスタマイズ
### テーマを生成する
[CLI](https://yamada-ui.com/docs/theming/cli.md)を使用してテーマを生成します。
:::warning
下記のコマンドを実行する前に、`@yamada-ui/cli`をインストールして`init`コマンドを実行する必要があります。詳しくは、[こちら](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
```
### トークンを変更する
生成したテーマの`tokens/breakpoints.ts`を変更します。
```tsx
import { defineTokens } from "@yamada-ui/react"
export const breakpoints = defineTokens.breakpoints({
sm: "27em", // [!code highlight]
md: "48em",
lg: "61em",
xl: "80em",
"2xl": "90em",
})
```
### プロバイダーを更新する
生成したテーマを`UIProvider`に設定します。
```tsx
import { UIProvider } from "@workspaces/ui"
import { theme } from "@workspace/theme"
const App = () => {
return (
)
}
```
## メディアクエリ
デフォルトでは、`@media(max-width)`のメディアクエリを用いたレスポンシブデザインを採用しています。
```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 (
)
```
もし、`@media(min-width)`のメディアクエリを採用する場合は、コンフィグの`breakpoint.direction`を`"up"`に設定します。
### コンフィグを変更する
生成したテーマの`config.ts`を変更します。
```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 },
})
```
### プロバイダーを更新する
生成したテーマを`UIProvider`に設定します。
```tsx
import { UIProvider } from "@workspaces/ui"
import { theme, config } from "@workspace/theme"
const App = () => {
return (
)
}
```
## コンテナクエリ
レスポンシブデザインは、メディアクエリを使用しています。もし、コンテナクエリを使用する場合は、コンフィグの`breakpoint.identifier`を`"@container"`に設定します。
```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 (
)
```