Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Demonstrates a simple counter layout using Chakra UI components and React for interactivity.
import React, { useState } from 'react';
import { ChakraProvider, Box, Button, Heading, extendTheme } from '@chakra-ui/react';
const theme = extendTheme({ config: { initialColorMode: 'light', useSystemColorMode: false } });
const Counter = () => {
const [count, setCount] = useState(0);
const [isDark, setIsDark] = useState(false);
return (
<ChakraProvider theme={theme}>
<Box textAlign='center' mt={10} bg={isDark ? 'gray.800' : 'gray.100'} color={isDark ? 'white' : 'black'} p={6} borderRadius='md'>
<Heading mb={4}>Counter: {count}</Heading>
<Button colorScheme='blue' mr={2} onClick={() => setCount(count + 1)}>+</Button>
<Button colorScheme='red' mr={2} onClick={() => setCount(count - 1)}>-</Button>
<Button colorScheme='gray' onClick={() => setCount(0)}>Reset</Button>
<br /><br />
<Button colorScheme='yellow' onClick={() => setIsDark(!isDark)}>Switch Theme</Button>
</Box>
</ChakraProvider>
);
};
export default Counter;Chakra UI is a modular and accessible React component library that provides a set of composable, themeable, and responsive UI components.
Origin & Creator
Created by Segun Adebayo in 2019 as a modern, developer-friendly React UI library.
Industrial Note
Chakra UI is popular for React projects that need quick prototyping, accessible components, and highly customizable UI without enforcing a specific design system.