Skip to content

[RAC] Add data-placeholder attribute to input fields as it is done in Select component #8304

Open
@mikhailkollen

Description

@mikhailkollen

Provide a general summary of the feature here

I am currently working on several input components based on RAC. According to the target designs these components should have specific border styling if:

  • They currently do not have value
  • They have not had any value entered
  • They have a placeholder provided

It was very easy to achieve this with the Select component, since it assigns data-placeholder attribute to SelectValue, but it turned out that other inputs like TextField and NumberField do not have it.

🤔 Expected Behavior?

It would be very beneficial to have a similar behavior for other inputs, so this state can be tracked without interfering with a component value handling logic.

😯 Current Behavior

Select component (data-placeholder attr is added to SelectValue):
Image

TextField component (data-placeholder is not present anywhere):
Image

See CodeSandbox for reference:
https://codesandbox.io/p/devbox/react-aria-components-forked-fxyn7j?workspaceId=ws_EKoPVtiibdNe2oieRn7G9L

💁 Possible Solution

<span ref={ref} {...DOMProps} {...renderProps} data-placeholder={!selectedItem || undefined}>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions