N
Nuxt2mo ago
PetyXbron

Nuxt UI - Chip with custom color

I am creating a SelectMenu component. There is a choice to set a chip for each item. Can I set a custom color for each item? (Not just pre-defined colors from config but color from hex or integer format for each item)
5 Replies
kapa.ai
kapa.ai2mo ago
Hi @PetyXbron. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I'm sorry, but the knowledge sources do not explicitly mention support for setting a custom color (such as a hex code or integer value) for a chip in the SelectMenu component. The documented approach for the <UChip> component and chips in SelectMenu items is to use the predefined color variants: 'primary', 'secondary', 'success', 'info', 'warning', 'error', and 'neutral' via the color prop or chip object property. There is no example or API reference showing support for arbitrary color values like hex codes or integers for chips in SelectMenu items—only these predefined color keys are supported in the configuration and usage examples Chip usage SelectMenu with chip in items. If you need to use a truly custom color, you may need to extend the component or use a custom slot to apply inline styles, but this is not covered in the official documentation provided. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@411436203330502658> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
PetyXbron
PetyXbronOP2mo ago
@kapa.ai how can I watch the event of ui button trigger? https://ui.nuxt.com/components/button I want to create a custom action than just a link or something
Nuxt UI
Vue Button Component - Nuxt UI
A button element that can act as a link or trigger an action.
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- To watch for a UI button trigger in Nuxt UI, you can use the standard Vue event handling with the @click event on the <UButton> component. This allows you to execute any custom action when the button is clicked. Here’s a basic example:
<script setup lang="ts">
function handleClick() {
// Your custom action here
console.log('Button was clicked!')
}
</script>

<template>
<UButton @click="handleClick" label="Click me" />
</template>
<script setup lang="ts">
function handleClick() {
// Your custom action here
console.log('Button was clicked!')
}
</script>

<template>
<UButton @click="handleClick" label="Click me" />
</template>
You can define any function and bind it to the @click event. This is the recommended way to handle button events in Nuxt UI, as shown in the documentation. You can also use the loading-auto prop if you want the button to show a loading state while your custom action (if it returns a promise) is pending Button usage Button loading. If you need to watch for more complex events or integrate with forms, you can use the button inside a form and listen for the form's @submit event as well. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@411436203330502658> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?