1. Home
  2. /
  3. Chakra-ui
  4. /
  5. Chakra UI Tabs Example

Chakra UI Tabs Example - Chakra-ui Typing CST Test

Loading…

Chakra UI Tabs Example — Chakra-ui Code

Shows tab navigation using Chakra UI Tabs component.

import React from 'react';
import { ChakraProvider, Tabs, TabList, TabPanels, Tab, TabPanel, extendTheme } from '@chakra-ui/react';

const theme = extendTheme({});

const TabsExample = () => (
	<ChakraProvider theme={theme}>
		<Tabs variant='enclosed' mt={10} mx='auto' maxW='md'>
		<TabList>
		<Tab>Tab 1</Tab>
		<Tab>Tab 2</Tab>
		<Tab>Tab 3</Tab>
		</TabList>
		<TabPanels>
		<TabPanel><p>Content of Tab 1</p></TabPanel>
		<TabPanel><p>Content of Tab 2</p></TabPanel>
		<TabPanel><p>Content of Tab 3</p></TabPanel>
		</TabPanels>
		</Tabs>
	</ChakraProvider>
);

export default TabsExample;

Chakra-ui Language Guide

Chakra UI is a modular and accessible React component library that provides a set of composable, themeable, and responsive UI components.

Primary Use Cases

  • ▸React-based web applications
  • ▸Dashboards and admin panels
  • ▸Rapid prototyping with composable components
  • ▸Responsive and accessible UI projects
  • ▸Customizable component libraries with theming

Notable Features

  • ▸Accessible components with built-in ARIA support
  • ▸Style props for inline styling
  • ▸Themeable design system with global overrides
  • ▸Composable components (Box, Stack, Flex)
  • ▸Responsive props and utility-first styling

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.

Quick Explain

  • ▸Chakra UI allows developers to build React applications with prebuilt, accessible, and composable components.
  • ▸It offers theming, style props, and responsive design utilities for fast development.
  • ▸Chakra UI emphasizes developer productivity and accessibility.

Core Features

  • ▸Prebuilt React components (Button, Modal, Input, Card)
  • ▸Theming with extendable theme objects
  • ▸Responsive and mobile-first design
  • ▸Composable layout primitives (Box, Flex, Stack, Grid)
  • ▸TypeScript support and documentation

Learning Path

  • ▸Learn React fundamentals
  • ▸Understand Chakra UI layout primitives
  • ▸Explore prebuilt components and style props
  • ▸Practice responsive design with props
  • ▸Create custom themes with extendTheme

Practical Examples

  • ▸Responsive navigation bar with Flex and Box
  • ▸Card layout using Stack and Grid
  • ▸Form validation with Input, FormControl, and Button
  • ▸Modal dialogs with accessibility support
  • ▸Themed buttons with hover and focus styles

Comparisons

  • ▸Style-prop-based vs theme-overrides (MUI uses ThemeProvider + sx)
  • ▸Composable primitives vs component-heavy libraries
  • ▸Accessible by default vs needing configuration
  • ▸Lightweight and flexible vs opinionated Material Design
  • ▸React-only library

Strengths

  • ▸Accessible out of the box
  • ▸Highly composable and flexible
  • ▸Developer-friendly syntax using style props
  • ▸Customizable theming system
  • ▸Lightweight and tree-shakeable

Limitations

  • ▸React-only library
  • ▸Style props may lead to verbose JSX
  • ▸Not opinionated about design language (no Material Design)
  • ▸Limited prebuilt advanced components compared to MUI
  • ▸Requires learning Chakra-specific props and theming

When NOT to Use

  • ▸Projects not using React
  • ▸When prebuilt Material Design components are required
  • ▸For static websites with minimal interactivity
  • ▸When team prefers separate CSS files
  • ▸For advanced enterprise dashboards requiring built-in complex components

Cheat Sheet

  • ▸`Box`, `Flex`, `Stack` - layout primitives
  • ▸`Button`, `Input`, `Modal` - common components
  • ▸`colorScheme` - component theming
  • ▸`p`, `m`, `gap` - spacing style props
  • ▸`w={{ base: '100%', md: '50%' }}` - responsive width

FAQ

  • ▸Is Chakra UI free?
  • ▸Yes - MIT license.
  • ▸Does Chakra UI include JS?
  • ▸Yes - React components include behavior.
  • ▸Is Chakra UI responsive?
  • ▸Yes - style props support breakpoints.
  • ▸Can I customize Chakra UI?
  • ▸Yes - extendTheme for colors, typography, and components.
  • ▸Which browsers does Chakra support?
  • ▸All modern browsers supported by React.

30-Day Skill Plan

  • ▸Week 1: Basic components (Button, Box, Text)
  • ▸Week 2: Layout using Flex, Stack, Grid
  • ▸Week 3: Responsive design and breakpoints
  • ▸Week 4: Custom theming
  • ▸Week 5: Compose complex UIs and reusable components

Final Summary

  • ▸Chakra UI is a React component library focused on accessibility and composability.
  • ▸Provides flexible style props and responsive design utilities.
  • ▸Themeable system allows global styling overrides.
  • ▸Ideal for dashboards, SPAs, and rapid prototyping.
  • ▸Developer-friendly, lightweight, and accessible by default.

Project Structure

  • ▸src/ - main React source folder
  • ▸src/components/ - reusable Chakra components
  • ▸src/theme/ - optional theme overrides
  • ▸package.json - Chakra dependencies
  • ▸public/ - static assets and index.html

Monetization

  • ▸Develop Chakra UI templates or dashboards
  • ▸Offer React app development
  • ▸Build reusable component libraries
  • ▸Consulting for accessible UI projects
  • ▸Rapid prototyping services

Productivity Tips

  • ▸Leverage composable primitives
  • ▸Use ChakraProvider early for consistent theming
  • ▸Responsive props reduce CSS overhead
  • ▸Lazy-load heavy components
  • ▸Use TypeScript for type safety

Basic Concepts

  • ▸Components: Button, Input, Modal, Accordion
  • ▸Layout: Box, Flex, Stack, Grid
  • ▸Styling: style props (`p`, `m`, `color`, `bg`) and `sx` prop
  • ▸Theming: global theme overrides via `extendTheme`
  • ▸Responsive props using breakpoints (`sm`, `md`, `lg`, `xl`)

Official Docs

  • ▸https://chakra-ui.com/
  • ▸https://github.com/chakra-ui/chakra-ui
  • ▸https://chakra-ui.com/getting-started

More Chakra-ui Typing Exercises

Chakra UI Counter ExampleChakra UI Button ExampleChakra UI Card ExampleChakra UI Modal ExampleChakra UI Form ExampleChakra UI Alert ExampleChakra UI Progress ExampleChakra UI Accordion ExampleChakra UI Tooltip Example

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher