# Custom Elements

## Files

For creating a new element, you should create a folder in "elements" folder, the name of the folder would be your element's source ID. Each element can have 3 files: element.html, style.css, script.js

* Note: the styles in style.css will be loaded globally, so prevent duplicated class names.
* Note: the script.js content will be loaded upon element mount.

## Javascript globals

in Js file, you can access global data using `window.placeholderData` . This object will provide you an list of placeholder you defined (read [Placeholders](/scripts/justhud/elements.md) )

## Config

```lua
{
    id = "customelement-instance",
    type = "custom",
    source = "test-element",
    args = {
        data = "%time%"
    },
    show = {
        default = true,
        is_editable = true,
        settings_title = "Show custom",
        in_car = true,
        not_in_car = true,
    },
    position = {
        default = {
            bottom = 26,
            left = 26
        },
        is_editable = true
    },
    icon = "iconsax:Microphone2:Bold"
}
```

This is sample config, most of things are similar to other elements (read [Elements](/scripts/justhud/elements.md)).\
source - The source ID of your element (folder name)\
args - A table of data that can be used as placeholders<br>

## Sample

```html
<div class="test-element">
    <h1>
        %arg_data%
    </h1>
</div>
```

In this case, JustHud will first parse %arg\_data% which defined in Config above in args table, then the %time% placeholder will be replaced  as the final value.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.justscripts.net/scripts/justhud/custom-elements.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
