Hi, Wim
I’ll try to give your some pointers. I really think looking at the documentation first may help a lot, as you need to understand concepts on how components work. Components are powerful and enable you to keep variables inside the component, as well as configuring you to have properties going in. This is very valuable as you can contain logic inside each component and thus make it reusable as well.
When designing this component, i use a div for the wrapper, then a repeater div for “Options”. These “options” are designed with two states. Active, and not active. Here you can see how it looks in my sidebar.
The repeater will repeat the components “options” properties, which in my case has label and value. I do this to be able to easily use this tab selector component without recreating everything.
Here you can see the components “options” properties.
This will enable you to add as many options as you like “on the outside” of the component, and also seperate value and label. Label is what the text show, and value is its “key” which is used for database, or logic.
You can also see that the selected value is a variable. This variable is also exposed outside the component, so that you can fetch it from the outside.
For the option UI itself, I have a state called active, which is conditionally active when the selected_value == this items value (which is derived from the repeated options.value)
When clicking one of the options I set the selected_value to (item.value) so that the active state will be visible.
I would urge you to follow a example or tutorial to create a simple component, as these concepts may seem a bit abstract. Have you tried using WeWeb AI to build a component? It should be possible that it can make it for you, even though it might go Custom Code on you.
I tried to ask it this as a base, but it went directly to custom coded component:
I need a new weweb component that acts as a switcher or segmented control component. I need to have properties in for Option. One option will have label and value. The selected value of the component needs to be exposed to the outside. Options should be horizontal. give me controls for
pill color, selected text color, unselected option text color
It went OK. Had to tweak a bit, but i got this out of it:
The component does not have a background, so I created a div around it and set the background.