Nuxt UI:UFileUpload make the rendered image will have a class of object-fill
Good day I'm using new nuxt component called UFileUpload but by default it renders on object-cover and I want to render this as object-fill is there any props or other ways to do this thank you

6 Replies
Hi @MacAngel23. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the available knowledge sources, there is no direct prop on the
UFileUpload
component to change the rendered image's class from object-cover
to object-fill
. However, Nuxt UI components are highly customizable via the theme system and the ui
or class
props, which allow you to override default classes for component slots.
For components like UAvatar
(which is often used to preview images in custom UFileUpload
slots), you can override the image slot's class using the ui
prop:
If you are using a custom slot to render the image preview in UFileUpload
, you can apply your own class directly to the <img>
element:
If you want to globally override the default for all avatars, you can do so in your app.config.ts
:
This approach leverages the Nuxt UI theme system to change the default styling for the image slot in the avatar component, which is commonly used for image previews in file uploads. For other custom implementations, always ensure you apply the desired class directly to your image element in your slot template.
There is no mention in the knowledge sources of a direct prop on UFileUpload
itself to change the image's object-fit class, so using the slot customization or theme override is the recommended approach Components theme.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@532759469931757588> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
for the temporary resolution I just adjust the component height by using this props
@kapa.ai how to show the default image
Let me check the knowledge base for you again. One moment! :books:
----------------------
To show a default image with Nuxt UI's
UFileUpload
, you can use a custom slot to render an image when no file is selected. For example, in the avatar upload scenario, you can conditionally display a default image if state.avatar
is not set:
In this example, /default-image.png
is your default image path. The UAvatar
will show the uploaded image if available, otherwise it falls back to the default image. This pattern is demonstrated in the Nuxt UI documentation, where the src
prop of UAvatar
is set conditionally based on the presence of a file With Form validation.
If you want to use a fallback icon or text instead, you can use the icon
or text
props of UAvatar
as shown in the docs Avatar usage.
There is no built-in prop on UFileUpload
to specify a default image directly; you need to handle it in your slot/template logic.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1109045853857005613> Kapa.ai is still learning and improving, please let me know how I did by reacting below.