JustWeb3 UI
@justweb3/ui • Docs
@justweb3/ui
The @justweb3/ui library provides a unified UI experience and handles theme generation for the @justweb3/widget package. It simplifies theming across widgets by dynamically generating color variations and supports custom theming through its context provider.
Table of Contents
Installation
Install the library using npm or yarn:
Usage
Setup with JustWeb3ThemeProvider
JustWeb3ThemeProvider
To enable the theme context for your widget, wrap your application or component with the JustWeb3ThemeProvider
. This ensures consistent theming across components and allows you to customize colors dynamically.
Changing Theme Dynamically
The JustWeb3ThemeProvider
offers a changeTheme
function to dynamically change the primary, background, or destructive colors. Here's an example demonstrating dynamic theme switching.
Hooks
useJustWeb3Theme
useJustWeb3Theme
The useJustWeb3Theme
hook provides access to the current theme and allows you to modify theme colors dynamically.
Usage
Hook Output
theme
: The current theme values.color
: The current primary, background, and destructive colors.changeTheme
: A function to dynamically change specific theme colors.
How It Works
The JustWeb3ThemeProvider
internally generates color variations for:
Primary Color: Base color with light and dark variations.
Destructive Color: Used for alerts and destructive actions.
Background Color: Provides variations for background and foreground colors.
The provider uses CSS variables for theme management, ensuring that components and styles are synchronized.
Example CSS Variables:
Contributing
We welcome contributions! Please submit issues or pull requests on our GitHub repository.
Last updated