Skip to content

Global Configuration Options

useOptions is a global configuration hook function provided by Tune UI, used for managing global settings such as theme, size, internationalization, etc. of the component library.

Basic Usage

js
import { useOptions } from "tune-ui";

// Get configuration API
const { updateThemeColor, updateDefaultSize, setLocale, configOptions } = useOptions();

API Details

Output Parameters

The useOptions hook doesn't require any input parameters but returns the following methods and properties:

NameTypeDescription
updateThemeColor(theme: OptionsThemeType) => voidUpdate theme colors
updateDefaultSize(size: ElSizeType) => voidUpdate default element size
updateLoadingOptions(options: LoadingOptionsType) => voidUpdate loading configuration
setLocale(locale: LocaleType) => voidSwitch language
initOptions() => OptionsTypeInitialize and return default config
configOptionsRef<OptionsType>Reactive reference to current config
baseSizeComputedRef<ElSizeType>Computed property for current base size
localeComputedRef<LocaleType>Computed property for current language

Get Current Configuration

js
// Get configuration API
const { configOptions } = useOptions();

// Get current theme configuration
console.log(configOptions.value.theme);

// Get current size
console.log(configOptions.value.elSize);

// Get current language
console.log(configOptions.value.locale);

Reset All Configurations

js
// Get configuration API
const { initOptions } = useOptions();

// Reset all configurations to default values
const defaultOptions = initOptions();

Released under the MIT License