ThemeProvider
The ThemeProvider component is a context provider that manages and applies the overall theme of your application. It allows for dynamic theming, enabling users to switch between predefined themes like light or dark mode, or even custom themes provided by the user. This component is crucial for maintaining a consistent look and feel across the application while also giving users the flexibility to choose their preferred theme. It's especially useful in applications where user personalization and accessibility are key, such as in productivity tools or content-heavy websites.
useTheme
The useTheme hook is a custom React hook that provides access to the current theme context, allowing components to easily consume theme-related properties like colors, fonts, and spacing. This hook is essential for creating theme-aware components that adapt their styles dynamically based on the selected theme. It's particularly useful in design systems or large-scale applications where consistent theming is crucial. For example, in a dashboard app, useTheme can be used to adjust the styling of charts and widgets based on the active theme.
Code
import { ThemeProvider } from "@lumina-design/core/ThemeProvider"; <ThemeProvider initialTheme="light" customTheme={{ "primary-color": "#FF5733", // For general primary elements "secondary-color": "#C70039", // For general secondary elements "background-color": "#5188ce", // For the background color "text-color": "#FFC300", // For text color "button-primary-bg": "#FF5733", // For primary button background "button-secondary-bg": "#C70039", // For secondary button background "button-text-color": "#FFC300", // For button text color "button-disabled-bg": "#555" // For disabled button background }} > //Your entire application or sub-component-tree </ThemeProvider>