React Sites with Chakra UI: Accessible Components & Dark Theme
You integrate a third-party design system into a React app and end up with inconsistent HTML/CSS classes, a broken dark theme, and inaccessible interactive elements. We've encountered this on dozens of projects, so for clients who prioritize accessibility and rapid prototyping, we recommend Chakra UI. With 5+ years in web development and 50+ React projects, we've refined an approach where a landing page takes 1–2 days to build, not a week. Savings on layout costs reach 30% thanks to ready-made components—confirmed by client feedback.
Chakra UI is not just another UI library; it's a system where every component meets WCAG 2.1 out of the box. The Style Props API lets you manage CSS directly in JSX, eliminating extra files. The built-in dark theme uses semantic tokens that automatically switch colors without a rebuild. For example, in one project we replaced 500 lines of CSS variables with 20 lines of tokens—the dark theme worked flawlessly with zero bugs.
How Chakra UI Solves the Dark Theme Problem
Before Chakra UI, developers stored color variables in CSS and manually swapped them via [data-theme="dark"]. In Chakra v3, the dark theme is a built-in feature: you define a token's dark color using _dark. The provider automatically reads the data-theme attribute on <html> and applies the correct palette. Configuration example:
import { createSystem, defaultConfig, defineConfig } from '@chakra-ui/react'; const customConfig = defineConfig({ theme: { tokens: { colors: { brand: { 500: { value: '#3b82f6' } }, }, }, semanticTokens: { colors: { 'bg.canvas': { value: { base: '#f9fafb', _dark: '#0f172a' } }, }, }, }, }); const system = createSystem(defaultConfig, customConfig); export default system; Now a component like Box bg="bg.canvas" adapts to the theme automatically. No media queries, no class toggles. The maintenance cost of such a theme is 2–3 times lower compared to custom solutions.
Why Chakra UI is Faster Than Material-UI for MVPs
| Parameter | Chakra UI (v3) | Material-UI (MUI) |
|---|---|---|
| Style props | Yes, built-in | Via sx prop, more boilerplate |
| Dark theme | Tokens + _dark, 5 minutes |
Themes via ThemeProvider, ~15 minutes |
| Accessibility | WCAG AA out of the box | Partial, requires extra work |
| Bundle size | ~25 kB gzip | ~40 kB gzip |
| Responsiveness | Objects in props: w={{ base: 'full', md: '50%' }} |
Via useMediaQuery or breakpoints in sx |
Chakra UI wins in prototyping speed: 2–3 times less code for responsive grids and forms. Additional savings come from the built-in token system that eliminates style duplication.
Chakra UI v2 vs v3 Comparison
| Feature | Chakra UI v2 | Chakra UI v3 |
|---|---|---|
| Provider | ChakraProvider + ColorModeScript |
Single ChakraProvider with config |
| Tokens | CSS variables + useColorMode |
Semantic tokens with _dark |
| Style props | Via chakra factory |
Built into all components |
| Size | ~30 kB gzip | ~25 kB gzip |
Migrating from v2 to v3 requires updating the provider and replacing useColorMode with _dark tokens, but pays off through simplified architecture.
How to Set Up a Chakra UI Theme in 3 Steps
-
Install the package:
npm install @chakra-ui/react @emotion/react. - Create a configuration in a separate file (as in the example above), define base tokens and semantic tokens for the dark theme.
- Connect the provider at the root of your app:
import { ChakraProvider } from '@chakra-ui/react'; import system from './theme/system'; function Root() { return ( <ChakraProvider value={system}> <App /> </ChakraProvider> ); } After that, style props and automatic dark theme support are available in all components.
Hero Section with Style Props
Style props are the key to speed: responsive padding is set via an object py={{ base: '12', md: '20', lg: '28' }}. The entire section is written in one JSX block:
import { Box, Flex, Heading, Text, Button, Stack } from '@chakra-ui/react'; const Hero = () => ( <Box as="section" bg="bg.canvas" py={{ base: '12', md: '20' }}> <Flex maxW="7xl" mx="auto" direction={{ base: 'column', lg: 'row' }}> <Box flex="1"> <Heading as="h1" size={{ base: '2xl', lg: '4xl' }} color="text.primary"> Product Title </Heading> <Text fontSize={{ base: 'md', lg: 'lg' }} color="text.muted" mb="8"> Value proposition </Text> <Button colorPalette="brand" size="lg">Get Started Free</Button> </Box> </Flex> </Box> ); Card Grid and Form with Validation
For cards, use SimpleGrid, which automatically adjusts columns based on breakpoint. Forms use standard Field + Input, validation via React Hook Form and Zod:
import { Field, Input, Button, Stack } from '@chakra-ui/react'; import { useForm } from 'react-hook-form'; import { z } from 'zod'; const schema = z.object({ name: z.string().min(2) }); const Form = () => { const { register, handleSubmit, formState: { errors } } = useForm({ resolver: zodResolver(schema) }); return ( <Stack gap="5"> <Field.Root invalid={!!errors.name}> <Field.Label>Name</Field.Label> <Input {...register('name')} /> {errors.name && <Field.ErrorText>{errors.name.message}</Field.ErrorText>} </Field.Root> <Button type="submit">Submit</Button> </Stack> ); }; Color Mode via Semantic Tokens
In Chakra v3 you don't need to change CSS—just use the useColorMode hook. A toggle button example is described above. To save space and reduce code redundancy, we often extract toggle logic into a separate hook. We guarantee that every component passes Core Web Vitals testing: bundle optimization, lazy-loading icons, and eliminating N+1 requests.
Common Mistakes When Building with Chakra UI
- Using
!important—overriding tokens via thecssprop breaks the system. - Omitting
_darkin semantic tokens—dark theme won't appear. - Missing
basebreakpoint—responsiveness breaks on mobile. - Ignoring the
asprop—semantic markup is broken. - Direct DOM manipulation instead of state—Chakra UI components are reactive.
What's Included in Our Chakra UI Layout Work?
We deliver not only finished code but also documentation on tokens, components, and color schemes. Deliverables include:
- Configured Chakra UI theme with semantic colors and fonts
- All project pages adapted for mobile and desktop breakpoints
- Forms with validation (React Hook Form + Zod)
- Style documentation (Storybook or Markdown)
- Access to repository with commit history
- Team training (1–2 hours) on style props and theme configuration
Contact us—we'll propose a turnkey solution with Chakra UI. Savings on layout costs reach 30% thanks to ready-made components and no custom CSS classes.
Timelines and Cost
Estimated timelines:
- System and theme setup: 3–4 hours
- Landing page: 1–2 days
- Product site (5+ sections, form, dashboard): 4–7 days
Final cost is calculated individually. Book a consultation to get an accurate estimate. Each client has a single manager and full technical oversight (certified specialists, 5+ years of React experience).
Do you have a React project needing dark theme and accessibility? Get a turnkey solution with Chakra UI—reach out to us.







