Chakra UI Pocketbook

Chakra UI Pocket Book — Uplatz

50 deep-dive flashcards • Wide layout • Fewer scrolls • 20+ Interview Q&A • Readable code examples

Section 1 — Getting Started with Chakra UI

1) What is Chakra UI?

Chakra UI is a modular, accessible component library for React that helps developers build design-consistent UIs fast. With built-in theme support, style props, and dark mode, it enhances productivity and scalability of frontend projects.

// Install Chakra UI
npm i @chakra-ui/react @emotion/react @emotion/styled framer-motion

2) ChakraProvider & Theme Setup

Wrap your app with ChakraProvider to enable Chakra’s theme and components. Customize via extendTheme to create a design system.

import { ChakraProvider } from '@chakra-ui/react';
const App = () => (
    
);

3) Components: Button, Box, Stack

Chakra’s components are styled via props. Box is a generic layout wrapper, Stack handles spacing, and Button supports variants and sizes out of the box.

import { Button, Box, Stack } from '@chakra-ui/react';

  

4) Responsive Design

Chakra supports mobile-first breakpoints using array or object syntax for style props. It’s intuitive and consistent with CSS best practices.

<Box fontSize={["sm", "md", "lg"]} padding={{ base: 2, md: 6 }} />

5) Theming & Color Modes

Support light and dark modes with ease. Chakra UI provides ColorModeProvider and useColorMode hook to toggle themes dynamically.

import { useColorMode } from '@chakra-ui/react';
const Toggle = () => {
  const { colorMode, toggleColorMode } = useColorMode();
  return ;
}

6) Forms & Validation

Form controls like Input, FormLabel, and FormErrorMessage support accessibility. Pair Chakra with Formik or React Hook Form for robust validation.

import { Input, FormControl, FormLabel } from '@chakra-ui/react';

  Email
  

7) Icons & Custom SVG

Chakra includes @chakra-ui/icons with common icons and supports custom SVGs via the Icon component.

import { AddIcon } from '@chakra-ui/icons';

8) Accessibility First

Chakra UI is built with WAI-ARIA standards in mind. All components have proper keyboard interactions and screen reader support by default.

Always test with keyboard and screen readers to verify.

9) Custom Components & Tokens

Define your own components with Chakra’s styled API or use extendTheme to register new variants, colors, and typography scales as design tokens.

const theme = extendTheme({
  colors: { brand: { 500: "#1a365d" } },
  fonts: { heading: "Georgia", body: "Arial" }
});

10) Q&A — “Why use Chakra over plain CSS or other UI kits?”

Answer: Chakra UI provides out-of-the-box accessibility, design consistency, responsive style props, and faster development speed. Compared to plain CSS, it’s declarative and composable. Compared to other kits, it blends style flexibility with developer ergonomics.