# Extend existing componants in coconut

**URL:** <https://community.haxe.org/t/extend-existing-componants-in-coconut/4606>\
**Category:** Haxe\
**Created:** [May 4, 2025, 2:04pm UTC](https://community.haxe.org/t/extend-existing-componants-in-coconut/4606 "2025-05-04T14:04:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![neimanpinchas](https://community.haxe.org/user_avatar/community.haxe.org/neimanpinchas/32/2348_2.png) [@neimanpinchas](https://community.haxe.org/u/neimanpinchas)\
**Post date:** [May 4, 2025, 2:04pm UTC](https://community.haxe.org/t/extend-existing-componants-in-coconut/4606/1 "2025-05-04T14:04:09Z")

</div>

Hi

I am porting a project from Vue to coconut, and I am trying to make it with the minimum changes, in the past I managed already to do this ```class TextBox extends coconut.ui.View {

```
@:controlled var model:String;
function render() {
    return hxx('<input type="text" value={model} oninput={e->model=e.src.value} />');
}

```

}```  
Which worked fine to emulate v-model behavior, I later changed the attribute name to vmodel, I would like to allow the hyphen too `v-model` but whatever.

I am haveing now an issue, I want to allow textbox to use all attributes availible to input such as style class and whaever, and pass them over to the input, I tried to extend the html input class, aswell as to call input as a function (like we could in tink\_hxx), but was unable to get it working.  
I wouldn’t make send to fill up the page with all my blind attempts, I will post to to explain where I was heading, in general I would like to hear more on how the hxx magic is working.

```class
    @controlled public var vmodel:String="";
    function render() {
        return textarea({value:vmodel.toString(),oninput:e->vmodel=e.src.value},[]);
    }
}

function vtextarea2(attributes:tink.domspec.Tags, children:Array<RenderResult>):View {
    return hxx('<textarea {...attributes}>{...children}</textarea>');
}

```

Thank you

---

<div class="post-metadata">

**Author:** ![neimanpinchas](https://community.haxe.org/user_avatar/community.haxe.org/neimanpinchas/32/2348_2.png) [@neimanpinchas](https://community.haxe.org/u/neimanpinchas)\
**Post date:** [May 5, 2025, 12:42am UTC](https://community.haxe.org/t/extend-existing-componants-in-coconut/4606/2 "2025-05-05T00:42:23Z")

</div>

Well while not being completel clear I did some research on it, and I would like to update my progress.

## Parctical

1. The folllowing is a valid render function

```haxe
import coconut.vdom.Html;
//...
function render(){
		return Html.div({},{className: "abc"},[]);
}

```

1. The above can be wrapped within a function that could modify the call parameters

## Technical

1. Coconut is relying on tink\_hxx, in coconut.vdom.macros.HXX the generator is being generated with all fields in its uncle `coconut.vdom.Html`
2. These `Html.whatever` fields are being generated with a build macro, by looping over the list of tags availible within tink.domspec.Tags.

## Remaining chalanges,

1. Observe how the props and controlled are working.
2. how we can make use of a own hxx function that would respect our own types.

Lets hope that one of the cocogeeks will enlight us.
