Build faster with Premium Chakra UI Components 💎

Learn more
release·

January 9, 2025

Chakra 3.3

SA

We're excited to announce the release of Chakra UI v3.3.0! This release brings several exciting new features and improvements to enhance your development experience.

QR Code

The new QRCode component allows users to generate QR codes for various use cases. This component is perfect for applications that need to generate QR codes for sharing information.

import { QrCode } from "@chakra-ui/react"


const Demo = () => {
  return (
    <QrCode.Root value="https://www.google.com">
      <QrCode.Frame>
        <QrCode.Pattern />
      </QrCode.Frame>
    </QrCode.Root>
  )
}

New Examples

File Upload with Paste Event

We showcase how to handle files pasted from the clipboard using the FileUpload component.

    "use client"
    
    import {
      FileUpload,
      Float,
      Input,
      type InputProps,
      useFileUploadContext,
    } from "@chakra-ui/react"
    import { HiX } from "react-icons/hi"
    
    const FilePasteInput = (props: InputProps) => {
      const fileUpload = useFileUploadContext()
      return (
        <Input
          {...props}
          onPaste={(e) => {
            fileUpload.setClipboardFiles(e.clipboardData)
          }}
        />
      )
    }
    
    const FileImageList = () => {
      const fileUpload = useFileUploadContext()
      return (
        <FileUpload.ItemGroup display="flex" flexWrap="wrap" gap="3">
          {fileUpload.acceptedFiles.map((file) => (
            <FileUpload.Item
              p="2"
              width="auto"
              key={file.name}
              file={file}
              pos="relative"
            >
              <Float placement="top-start">
                <FileUpload.ItemDeleteTrigger
                  p="0.5"
                  rounded="l1"
                  bg="bg"
                  borderWidth="1px"
                >
                  <HiX />
                </FileUpload.ItemDeleteTrigger>
              </Float>
              <FileUpload.ItemPreviewImage
                boxSize="12"
                rounded="l1"
                objectFit="cover"
              />
            </FileUpload.Item>
          ))}
        </FileUpload.ItemGroup>
      )
    }
    
    
    const Demo = () => {
      return (
        <FileUpload.Root maxFiles={3} accept="image/*">
          <FileUpload.HiddenInput />
          <FileImageList />
          <FilePasteInput placeholder="Paste image here..." />
        </FileUpload.Root>
      )
    }
    

    We showcase how to hide menu content when it's detached from its trigger using the hideWhenDetached positioning option.

    Item0

    Item1

    Item2

    Item3

    Item4

    Item5

    import { Box, Center, Flex, Menu, Portal, Text } from "@chakra-ui/react"
    
    
    const Demo = () => {
      return (
        <Center minH="sm">
          <Flex
            w="300px"
            h="full"
            overflowX="auto"
            gapX="6"
            p="4"
            borderWidth="1px"
            bg="bg.subtle"
          >
            {[...Array(6).keys()].map((x) => (
              <Box layerStyle="fill.surface" p="4" borderRadius="md" key={x}>
                <Text>Item{x}</Text>
              </Box>
            ))}
            <Box>
              <Menu.Root positioning={{ hideWhenDetached: true }}>
                <Menu.Trigger asChild>
                  <Box as="button" bg="green.100" p="4" borderRadius="md">
                    Menu
                  </Box>
                </Menu.Trigger>
                <Portal>
                  <Menu.Positioner>
                    <Menu.Content>
                      <Menu.Item value="new-txt">New Text File</Menu.Item>
                      <Menu.Item value="new-file">New File...</Menu.Item>
                      <Menu.Item value="new-win">New Window</Menu.Item>
                      <Menu.Item value="open-file">Open File...</Menu.Item>
                      <Menu.Item value="export">Export</Menu.Item>
                    </Menu.Content>
                  </Menu.Positioner>
                </Portal>
              </Menu.Root>
            </Box>
          </Flex>
        </Center>
      )
    }
    

    CLI Improvements

    We've enhanced our CLI with more flexible snippet installation options:

    New --tsx Flag

    By default, the CLI detects if your project is a TypeScript project and installs the appropriate jsx or tsx snippets.

    With this flag, you can explicitly install the jsx or tsx snippets.

    npx @chakra-ui/cli@latest snippet add [...components] --tsx

    Bug Fixes

    This release also includes important bug fixes:

    Upgrading

    To upgrade to the latest version, run:

    npm install @chakra-ui/react@latest