Lapikit

Discover the useTheme action in Lapikit

UseTheme

The useTheme function allows you to dynamically change your application’s theme by modifying the CSS class applied to the root HTML element. This makes it easy to implement dark or light themes, thereby improving the user experience.

You can use this action by calling useTheme with the desired theme name. For example, useTheme('dark') will apply the dark theme by adding the corresponding class to the HTML element.

You can also customize the storage key in localStorage by passing a second argument to the useTheme function. By default, this key is set to @lapikit/theme.

You can customize the available themes and their associated styles via the configuration file plugins/lapikit.(js|ts). Check the documentation on themes to discover all the options available to tailor Lapikit to your application.

Parameters

parametertypedefaultdescription
name $requiredstringset the theme name
keystring@lapikit/themeset the storage key

Do you have a question? Ask on GitHub or Discord server

Do you see a bug? Open an issue on GitHub