PricingDocsAcademy
Bluesky ...
Wed, Dec 11, 11:15 PM

Is there a way to narrow the scope of the possible values that a component's attribute can take?

  • Belal

    2 months ago

    When setting a component's attribute from outside the component, I noticed that users are allowed to freely input any value they wish even though some attributes should be limited to only a few possible values. For example, while any truthy and falsy value can become a boolean in Javascript, in many cases, an attribute of type "boolean" should be limited to only two values: true and false (or "yes" and "no" - or some other set of two possible values). Similarly, if an attribute was responsible for specifying the component's "layout", there are likely only a handful of values that this attribute should take. Additionally, there are cases when the set of possible values for an attribute are determined by some external file's contents (e.g. the contents of a Rive file dictate what artboards, state machines, and inputs are present in the Rive animation, and many of its configuration options like "autoplay", "fit", and "alignment" only take a handful of values). Is there any way to limit a particular attribute's value to a small set of possible values and then the user only needs to select it via a dropdown or a toggle? Thanks.
  • Andreas Møller

    2 months ago

    Not at the moment, but we do plan on adding "types" to attributes and variables so you can specify that it is a string, boolean, number of even an enum
    🚀2
  • Kai

    2 months ago

    Yes, especially for component of other users that would be great. A type and the same input components for the attributes as in toddle would be fantastic. 🙂
  • Tod

    2 months ago

    Great energy @Kai! Your continuous contribution to the toddle Community just made you advance to Community Level 1!

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.