# Alt Text for Images in Custom Components

**URL:** <https://forum.builder.io/t/alt-text-for-images-in-custom-components/13372>\
**Category:** CMS\
**Tags:** react, nextjs\
**Created:** [March 11, 2025, 3:56pm UTC](https://forum.builder.io/t/alt-text-for-images-in-custom-components/13372 "2025-03-11T15:56:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicolle](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@nicolle](https://forum.builder.io/u/nicolle)\
**Post date:** [March 11, 2025, 3:56pm UTC](https://forum.builder.io/t/alt-text-for-images-in-custom-components/13372/1 "2025-03-11T15:56:31Z")

</div>

I’m using **[Builder.io](http://Builder.io)** and the **Next.js Image** component, and I’ve run into an issue with **alt text**.

**Context:**  
When uploading images to [Builder.io](http://Builder.io)’s library, there’s an option to set an **Alt Image** text, as shown in the image below.

 ![Screenshot 2025-03-11 at 12.43.18](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/f/f64f674abcdc53f05d84abdd6b69852512faf2c9.png)

However, when using an image input in a registered component we have something like this:

```js
{
  name: 'image',
  type: 'file',
  allowedFileTypes: ['jpeg', 'png'],
}

```

The received value is just a **string (image URL)**, meaning the alt text is **not included**. Since Next.js requires an `alt` prop for images, I have to manually add an extra field:

```js
{
  name: 'altText',
  type: 'string',
}

```

This means every image component requires an **alt text field** , making the process **repetitive** and error-prone.

### Question:

Is there a way to automatically pull the **Alt Image** text defined in [Builder.io](http://Builder.io)’s media library, instead of manually adding an `altText` field for every image instance?

---

<div class="post-metadata">

**Author:** ![sheema](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@sheema](https://forum.builder.io/u/sheema)\
**Post date:** [March 17, 2025, 1:02pm UTC](https://forum.builder.io/t/alt-text-for-images-in-custom-components/13372/2 "2025-03-17T13:02:41Z")

</div>

Hey @nicolle , welcome to the Builder forum!

You don’t need to manually add the `altText` for every image instance. Here is an example of a custom component I have created that displays the Alt text of an image based on what is added to the asset library-

```auto
import React from 'react';

interface ImageUploaderProps{
    altText?: string
}
function ImageUploader({altText=""}:ImageUploaderProps){
  return (
    <div >
        <h1>{altText}</h1>
    </div>
   
  );
}

export default ImageUploader;

```

This is the registration code for this component -

```auto
Builder.registerComponent(ImageUploader, {
  name: "ImageUploader",
  inputs: [
    {
      name: "imageUrl",
      type: "file",
      allowedFileTypes: ["jpeg", "jpg", "png", "gif"],
      helperText: "Upload an image file (jpeg, jpg, png, gif).",
    },
     
  ],
});

```

Here is a [loom](https://www.loom.com/share/b6beeca4d1c44e21ad9d524d7a91e58f?sid=fcb27984-0192-4ef9-8440-d3c41edba89e) for a better understanding of how to fetch the `altText` value from the asset library.  
This is a very simple example, feel free to customize it for your use-case.
