Breakpoints

Learn how to customize breakpoints.

Overview

Breakpoints are tokens used for responsive design, such as Responsive Design.

The breakpoints defined in the theme are here.

export const breakpoints = defineTokens.breakpoints({
  sm: "30em",
  md: "48em",
  lg: "61em",
  xl: "80em",
  "2xl": "90em",
})

Customize

  • 1

    Generate a Theme

    Use the CLI to generate a theme.

    pnpm yamada-cli theme
    
  • 2

    Change the Token

    Change the tokens/breakpoints.ts in the generated theme.

    theme/tokens/breakpoints.ts

    import { defineTokens } from "@yamada-ui/react"
    
    export const breakpoints = defineTokens.breakpoints({
      sm: "27em", 
      md: "48em",
      lg: "61em",
      xl: "80em",
      "2xl": "90em",
    })
    
  • 3

    Update the Provider

    Set the generated theme to the UIProvider.

    import { UIProvider } from "@workspaces/ui"
    import { theme } from "@workspace/theme"
    
    const App = () => {
      return (
        <UIProvider theme={theme}>
          <YourApplication />
        </UIProvider>
      )
    }
    

Media Queries

By default, the responsive design uses the @media(max-width) media query.

The breakpoint when using @media(max-width) is "base".

The breakpoint when using @media(min-width) is "base".

If you want to use the @media(min-width) media query, set the breakpoint.direction to "up" in the config.

  • 1

    Change the Config

    Change the config.ts in the generated theme.

    theme/config.ts

    import { defineConfig } from "@yamada-ui/react"
    
    export const config = defineConfig({
      css: { varPrefix: "ui" },
      breakpoint: { direction: "up", identifier: "@media screen" }, 
      defaultColorMode: "light",
      defaultThemeScheme: "base",
      notice: { duration: 5000 },
      theme: { responsive: true },
    })
    
  • 2

    Update the Provider

    Set the generated theme to UIProvider.

    import { UIProvider } from "@workspaces/ui"
    import { theme, config } from "@workspace/theme"
    
    const App = () => {
      return (
        <UIProvider theme={theme} config={config}>
          <YourApplication />
        </UIProvider>
      )
    }
    

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.

The breakpoint when using @media(max-width) is "base".

The breakpoint when using @container is "base".

2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd