cschroeter / park-ui

Beautifully designed components built with Ark UI and Panda CSS that work with a variety of JS frameworks.
https://park-ui.com
MIT License
1.75k stars 75 forks source link

[Question] Form / Field components - Where to find the docs #393

Closed FranciscoKloganB closed 4 months ago

FranciscoKloganB commented 4 months ago

Hey I was about to start implementing a Form component on my project's lib and noticed park-ui already has a Field recipe which does much, if not all the heavy work regarding the styling. It's based on @ark/ui Field, which makes it even better. However, I can not find it on park-ui.com.

Can you link the docs?

cschroeter commented 4 months ago

@FranciscoKloganB

Hey mate,

I've kicked off a big initiative focused on form field components, starting with handling invalid states for regular inputs.

Regarding the Field component, here's a simple approach I'm using now:

<Field.Root>
  <Field.Label>Label</Field.Label>
  <Field.Input asChild>
    <Input />
  </Field.Input>
  <Field.HelperText>Some additional Info</Field.HelperText>
  <Field.ErrorText>Error Info</Field.ErrorText>
</Field.Root>

I'm also exploring and simplifying the API to something like this:

<TextField label="" helperText="" multiline={false} />

Visually, this should look like:

image

But I also want to support this style:

image

Looking forward to your thoughts when you get a chance.

FranciscoKloganB commented 3 months ago

I'm personally fan of the simplistic approach on top. Appreciate that it easily accept validation/error messages at the Form.Field and the Form.Root level.

The second stylistic approach is interesting and very unique in comparison. I can certainly image some applications that would appreciate the second version. However, on the project I'm working on I would use the second approach only for simple forms where I could anticipate the number of fields is limited, won't grow and, are tighly related. Like the example you gave.

Dunno if this what you were looking for!

Cheers