|
| 1 | +# Theme Configuration Guide |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Vue Custom Tooltip supports predefined UI framework themes! You can easily apply PrimeVue or Vuetify styling to all your tooltips with a simple configuration option. |
| 6 | + |
| 7 | +## Available Themes |
| 8 | + |
| 9 | +- **`default`**: The built-in theme using the component's original styles (no additional CSS loaded) |
| 10 | +- **`primevue`**: Styles inspired by PrimeVue's design system |
| 11 | +- **`vuetify`**: Styles inspired by Vuetify's Material Design implementation |
| 12 | + |
| 13 | +## Basic Usage |
| 14 | + |
| 15 | +### Option 1: Global Theme Configuration |
| 16 | + |
| 17 | +Apply a theme to all tooltips in your application: |
| 18 | + |
| 19 | +```typescript |
| 20 | +import { createApp } from 'vue' |
| 21 | +import { VueCustomTooltip } from 'vue-custom-tooltip' |
| 22 | +import App from './App.vue' |
| 23 | + |
| 24 | +const app = createApp(App) |
| 25 | + |
| 26 | +app.use(VueCustomTooltip, { |
| 27 | + theme: 'primevue' // or 'vuetify' or 'default' |
| 28 | +}) |
| 29 | + |
| 30 | +app.mount('#app') |
| 31 | +``` |
| 32 | + |
| 33 | +### Option 2: Theme with Global Config |
| 34 | + |
| 35 | +Combine theme styling with global configuration: |
| 36 | + |
| 37 | +```typescript |
| 38 | +app.use(VueCustomTooltip, { |
| 39 | + theme: 'primevue', |
| 40 | + globalConfig: { |
| 41 | + position: 'top', |
| 42 | + trigger: 'hover', |
| 43 | + showDelay: 200, |
| 44 | + hideDelay: 150, |
| 45 | + dark: 'auto', // Supports auto-detection, true, or false |
| 46 | + showArrow: true, |
| 47 | + offset: 12, |
| 48 | + maxWidth: '300px', |
| 49 | + }, |
| 50 | +}) |
| 51 | +``` |
| 52 | + |
| 53 | +### Option 3: No Theme (Default Styling) |
| 54 | + |
| 55 | +If you don't specify a theme, the default tooltip styling will be used: |
| 56 | + |
| 57 | +```typescript |
| 58 | +// These are equivalent |
| 59 | +app.use(VueCustomTooltip) |
| 60 | +app.use(VueCustomTooltip, { theme: 'default' }) |
| 61 | +``` |
| 62 | + |
| 63 | +## Programmatic Theme Control |
| 64 | + |
| 65 | +You can also change the theme programmatically: |
| 66 | + |
| 67 | +```typescript |
| 68 | +import { getTooltipGlobalTheme, setTooltipGlobalTheme } from 'vue-custom-tooltip' |
| 69 | + |
| 70 | +// Change theme at runtime |
| 71 | +setTooltipGlobalTheme('vuetify') |
| 72 | + |
| 73 | +// Get current theme |
| 74 | +const currentTheme = getTooltipGlobalTheme() |
| 75 | + |
| 76 | +// Revert to default (uses component's built-in styles) |
| 77 | +setTooltipGlobalTheme('default') |
| 78 | +// or |
| 79 | +setTooltipGlobalTheme(undefined) |
| 80 | +``` |
| 81 | + |
| 82 | +## Theme Features |
| 83 | + |
| 84 | +### Dark Mode Support |
| 85 | + |
| 86 | +All themes automatically support dark mode through: |
| 87 | +1. **Auto detection** (`dark: 'auto'`): Responds to Tailwind's `.dark` class or `prefers-color-scheme` |
| 88 | +2. **Forced dark mode** (`dark: true`): Always use dark theme |
| 89 | +3. **Forced light mode** (`dark: false`): Always use light theme |
| 90 | + |
| 91 | +```typescript |
| 92 | +// Auto-detect dark mode |
| 93 | +app.use(VueCustomTooltip, { |
| 94 | + theme: 'primevue', |
| 95 | + globalConfig: { |
| 96 | + dark: 'auto', // Default |
| 97 | + }, |
| 98 | +}) |
| 99 | + |
| 100 | +// Force dark mode |
| 101 | +app.use(VueCustomTooltip, { |
| 102 | + theme: 'vuetify', |
| 103 | + globalConfig: { |
| 104 | + dark: true, |
| 105 | + }, |
| 106 | +}) |
| 107 | +``` |
| 108 | + |
| 109 | +### CSS Custom Properties |
| 110 | + |
| 111 | +Each theme uses CSS custom properties that you can override in your own styles: |
| 112 | + |
| 113 | +```css |
| 114 | +/* Override PrimeVue theme colors */ |
| 115 | +:root { |
| 116 | + --vct-primevue-background: #1a1a1a; |
| 117 | + --vct-primevue-text-color: #ffffff; |
| 118 | + --vct-primevue-border-radius: 8px; |
| 119 | +} |
| 120 | + |
| 121 | +/* Override Vuetify theme colors */ |
| 122 | +:root { |
| 123 | + --vct-vuetify-background: rgba(50, 50, 50, 0.95); |
| 124 | + --vct-vuetify-text-color: #e0e0e0; |
| 125 | + --vct-vuetify-font-family: 'Custom Font', sans-serif; |
| 126 | +} |
| 127 | +``` |
| 128 | + |
| 129 | +## Notes |
| 130 | + |
| 131 | +- Themes are injected as `<style>` elements in the document `<head>` |
| 132 | +- Only one theme can be active at a time |
| 133 | +- Changing themes at runtime will automatically remove the previous theme styles |
| 134 | +- Themes work with both the component API (`<Tooltip>`) and directive API (`v-tooltip`) |
| 135 | +- All theme styles respect the tooltip's position, trigger, and other configuration options |
| 136 | + |
| 137 | +## Creating Custom Themes |
| 138 | + |
| 139 | +See [styles/themes/README.md](../src/styles/themes/README.md) for information on creating your own custom themes. |
0 commit comments