Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for alternative 'required' patterns #479

Open
mkernohanbc opened this issue Aug 28, 2024 · 0 comments
Open

Support for alternative 'required' patterns #479

mkernohanbc opened this issue Aug 28, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@mkernohanbc
Copy link
Contributor

mkernohanbc commented Aug 28, 2024

In our existing input components (eg. Select, TextField, etc.), we communicate an input's required/optional state by displaying a "(required)" appendage to the input label.

We should consider how to provide support for alternative conventions in our components, for example:

  • Showing a red asterisk rather than a text label to indicate a required field
  • Indicating optional fields, rather than required ones

I've done some initial POC work on a solution for this, using a new requiredConvention prop to toggle between text and asterisk formats:

Image

Image

In this example, I used a switch statement and RAC's isRequired prop:

<Label className="bcds-react-aria-TextArea--Label">
       {label} {isRequired && getRequiredIndicator(requiredConvention)}
</Label>

@ty2k suggested that a more generalised solution that can be implemented across all of our input components would be to break this functionality out into a RequiredIndicator utility component.

Some things to consider for this new component:

  • What are the common patterns that we want to support
  • What is the default behaviour
  • How do we provide a method for the user to apply their own styling/convention
  • Can/should we also support the inverse ("optional" rather than "required" labelling)

Putting this on the backlog to revisit in a future sprint. @Philip-Cheung I'd like to get your take on these questions, so please give it some thought!

@mkernohanbc mkernohanbc self-assigned this Aug 28, 2024
@mkernohanbc mkernohanbc added the enhancement New feature or request label Aug 28, 2024
@mkernohanbc mkernohanbc added this to the Components v0.4.0 milestone Aug 29, 2024
@mkernohanbc mkernohanbc removed this from the Components v0.4.0 milestone Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant