N
Nuxt4mo ago
WiFi Plug

how to override vue-emoji-picker css styles to match my site?

Hi I'm using vue-emoji-picker but I want to override its background color and border color to match my nuxt ui theme colors. I tried making an emoji-picker-custom.css and including it in my nuxt config
/* app/assets/css/emoji-picker-custom.css */

:root {
--v3-picker-bg: red;
}

html.dark {
--v3-picker-bg: red;
}
/* app/assets/css/emoji-picker-custom.css */

:root {
--v3-picker-bg: red;
}

html.dark {
--v3-picker-bg: red;
}
but this didn't work. in their github they have these variables I'm trying to override
// Default styles
.v3-emoji-picker {
--v3-picker-bg: #ffffff;
--v3-picker-fg: #000000;
--v3-picker-border: #dddddd;
--v3-picker-input-bg: var(--v3-picker-bg);
--v3-picker-input-border: #cccccc;
--v3-picker-input-focus-border: #000000;
--v3-group-image-filter: none;
--v3-picker-emoji-hover: #f7f7f7;

background: var(--v3-picker-bg);
color: var(--v3-picker-fg);

.v3-footer,
.v3-header {
border-color: var(--v3-picker-border);
}

.v3-groups {
filter: var(--v3-group-image-filter);
}

.v3-tone {
color: var(--v3-picker-fg);
}

.v3-search input {
background: var(--v3-picker-input-bg);
border-color: var(--v3-picker-input-border);
color: inherit;
&:focus {
border-color: var(--v3-picker-input-focus-border);
}
}

.v3-body .v3-body-inner .v3-group h5,
.v3-skin-tones {
background: var(--v3-picker-bg);
}

.v3-body .v3-body-inner .v3-group .v3-emojis button:hover {
background: var(--v3-picker-emoji-hover, #f7f7f7);
}
}

// Theme Default
.v3-emoji-picker.v3-color-theme-dark {
--v3-picker-bg: #000000;
--v3-picker-fg: #ffffff;
--v3-picker-border: #333333;
--v3-picker-input-bg: #222222;
--v3-picker-input-border: #444444;
--v3-picker-input-focus-border: #555555;
--v3-group-image-filter: invert(1);
--v3-picker-emoji-hover: #222222;
}
// Default styles
.v3-emoji-picker {
--v3-picker-bg: #ffffff;
--v3-picker-fg: #000000;
--v3-picker-border: #dddddd;
--v3-picker-input-bg: var(--v3-picker-bg);
--v3-picker-input-border: #cccccc;
--v3-picker-input-focus-border: #000000;
--v3-group-image-filter: none;
--v3-picker-emoji-hover: #f7f7f7;

background: var(--v3-picker-bg);
color: var(--v3-picker-fg);

.v3-footer,
.v3-header {
border-color: var(--v3-picker-border);
}

.v3-groups {
filter: var(--v3-group-image-filter);
}

.v3-tone {
color: var(--v3-picker-fg);
}

.v3-search input {
background: var(--v3-picker-input-bg);
border-color: var(--v3-picker-input-border);
color: inherit;
&:focus {
border-color: var(--v3-picker-input-focus-border);
}
}

.v3-body .v3-body-inner .v3-group h5,
.v3-skin-tones {
background: var(--v3-picker-bg);
}

.v3-body .v3-body-inner .v3-group .v3-emojis button:hover {
background: var(--v3-picker-emoji-hover, #f7f7f7);
}
}

// Theme Default
.v3-emoji-picker.v3-color-theme-dark {
--v3-picker-bg: #000000;
--v3-picker-fg: #ffffff;
--v3-picker-border: #333333;
--v3-picker-input-bg: #222222;
--v3-picker-input-border: #444444;
--v3-picker-input-focus-border: #555555;
--v3-group-image-filter: invert(1);
--v3-picker-emoji-hover: #222222;
}
11 Replies
kapa.ai
kapa.ai4mo ago
Hi @WiFi Plug. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To override the CSS variables of a third-party component like vue-emoji-picker and match it with your Nuxt UI theme, you need to ensure that your custom CSS is loaded after the component's styles and that your selectors are specific enough to take precedence. From your example, you are setting the variables on :root and html.dark, but vue-emoji-picker defines them on the .v3-emoji-picker element itself. This means your overrides on :root won't affect the component unless you target the correct selector. To match your Nuxt UI theme, you can use the Nuxt UI CSS variables (like --ui-bg, --ui-border, etc.) and override the vue-emoji-picker variables within the .v3-emoji-picker selector. For dark mode, target .v3-emoji-picker.v3-color-theme-dark. Here’s how you can do it in your custom CSS file (e.g., app/assets/css/emoji-picker-custom.css):
/* app/assets/css/emoji-picker-custom.css */

.v3-emoji-picker {
--v3-picker-bg: var(--ui-bg);
--v3-picker-border: var(--ui-border);
/* You can override more variables as needed */
}

.v3-emoji-picker.v3-color-theme-dark {
--v3-picker-bg: var(--ui-bg);
--v3-picker-border: var(--ui-border);
}
/* app/assets/css/emoji-picker-custom.css */

.v3-emoji-picker {
--v3-picker-bg: var(--ui-bg);
--v3-picker-border: var(--ui-border);
/* You can override more variables as needed */
}

.v3-emoji-picker.v3-color-theme-dark {
--v3-picker-bg: var(--ui-bg);
--v3-picker-border: var(--ui-border);
}
Then, include this CSS file globally in your Nuxt config:
// nuxt.config.ts
export default defineNuxtConfig({
css: [
'~/assets/css/emoji-picker-custom.css'
]
})
// nuxt.config.ts
export default defineNuxtConfig({
css: [
'~/assets/css/emoji-picker-custom.css'
]
})
This approach ensures your overrides use the same theme variables as Nuxt UI, keeping your design consistent. Make sure your custom CSS is loaded after the vue-emoji-picker styles for the overrides to take effect. You can further customize other variables (like --v3-picker-fg, --v3-picker-emoji-hover, etc.) in the same way. For reference on how Nuxt UI exposes and uses CSS variables for theming, see the Nuxt UI theming documentation and how to include global CSS in Nuxt Nuxt CSS config. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@679734274840330384> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
WiFi Plug
WiFi PlugOP4mo ago
@kapa.ai yeah it didn't work, how do i ensure it's loaded after the emoji pickers styles?
kapa.ai
kapa.ai4mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- To ensure your custom CSS is loaded after the vue-emoji-picker styles in Nuxt, you should add your CSS file to the css array in your nuxt.config.ts. Nuxt will include these files globally and in the order they appear in the array, so files listed later will override earlier ones if there are conflicting styles. For example:
export default defineNuxtConfig({
css: [
'vue-emoji-picker/dist/vue-emoji-picker.css', // or wherever the emoji picker CSS is
'~/assets/css/emoji-picker-custom.css' // your custom overrides
]
})
export default defineNuxtConfig({
css: [
'vue-emoji-picker/dist/vue-emoji-picker.css', // or wherever the emoji picker CSS is
'~/assets/css/emoji-picker-custom.css' // your custom overrides
]
})
This way, your custom CSS will be loaded after the emoji picker’s CSS, allowing your overrides to take effect Nuxt CSS config. If vue-emoji-picker is imported as a module or its CSS is injected by the component itself (not via the Nuxt css array), you may need to increase the specificity of your selectors in your custom CSS to ensure your rules take precedence. For example:
.v3-emoji-picker {
--v3-picker-bg: red !important;
}
.v3-emoji-picker {
--v3-picker-bg: red !important;
}
But generally, controlling the order in the css array is the recommended approach in Nuxt. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@679734274840330384> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
WiFi Plug
WiFi PlugOP4mo ago
@kapa.ai thanks that !important seems to have done the trick. so then my file would be what to use the nuxt ui variables for my theme to automatically switch between dark and light i use bg-default in my components so do i use that as the var?
kapa.ai
kapa.ai4mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- To match your Nuxt UI theme and have the emoji picker automatically switch between light and dark modes, you should use the Nuxt UI CSS variables. The variable for the default background is --ui-bg, which is what the bg-default utility class uses. For borders, use --ui-border Getting-started > CSS Variables. Here’s how your custom CSS should look:
.v3-emoji-picker {
--v3-picker-bg: var(--ui-bg) !important;
--v3-picker-border: var(--ui-border) !important;
}

.v3-emoji-picker.v3-color-theme-dark {
--v3-picker-bg: var(--ui-bg) !important;
--v3-picker-border: var(--ui-border) !important;
}
.v3-emoji-picker {
--v3-picker-bg: var(--ui-bg) !important;
--v3-picker-border: var(--ui-border) !important;
}

.v3-emoji-picker.v3-color-theme-dark {
--v3-picker-bg: var(--ui-bg) !important;
--v3-picker-border: var(--ui-border) !important;
}
This will ensure the emoji picker uses the same background and border colors as your Nuxt UI theme, and will automatically adapt to light and dark modes since --ui-bg and --ui-border are updated by Nuxt UI when the color mode changes Getting-started > CSS Variables. So yes, use var(--ui-bg) for the background and var(--ui-border) for the border in your overrides. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@679734274840330384> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
WiFi Plug
WiFi PlugOP4mo ago
@kapa.ai what's the variable for the input field border when it turns into my primary color i tried --ui-border-primary but thats white
kapa.ai
kapa.ai4mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- The knowledge sources do not explicitly mention a CSS variable named --ui-border-primary for the input field border when it turns into your primary color. However, based on the theming system in Nuxt UI, the primary color is typically referenced as --ui-primary, and the ring (focus) color for primary is often set using ring-primary in component variants, not a border variable. For example, in the theme configuration for components like input-number, the focus ring uses ring-primary for the primary color state:
{
color: 'primary',
variant: [
'outline',
'subtle'
],
class: 'focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary'
}
{
color: 'primary',
variant: [
'outline',
'subtle'
],
class: 'focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary'
}
This means the border color itself does not automatically become the primary color; instead, the focus ring does, and it uses the ring-primary utility, which is mapped to the --ui-primary variable InputNumber Theme. If you want to use the primary color as a border, you should use --ui-primary:
border-color: var(--ui-primary);
border-color: var(--ui-primary);
If you need to reference the actual CSS variable for the primary color, it is --ui-primary, not --ui-border-primary Getting-started > CSS Variables. Summary:
Use var(--ui-primary) for the primary color, and for focus rings, use the ring-primary utility or set border-color: var(--ui-primary) if you want the border itself to be the primary color. There is no --ui-border-primary variable documented in the knowledge sources. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@679734274840330384> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?