Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Build a component that toggles between light and dark themes with a button click.

Medium

Problem Statement

Build a component that toggles between light and dark themes with a button click.

Sample Input

Initial theme: 'light'

Sample Output

Background color switches between white and black.

Limits

Time: 2s · Memory: 256 MB

Code Editor

Try your code in this preview. Submit marks it done.

import React, { useState } from "react";
 
 const ThemeToggler = () => {
  return (
  <div>
  <button>Toggle Theme</button>
  </div>
  );
 };
 
 export default ThemeToggler;