question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feat] New Component: Input prefix or suffix

See original GitHub issue

Input prefix or suffix

USWDS Version

2.11.0

Description

Use input prefixes and suffixes to show symbols or abbreviations that help users enter the right type of information in a form’s text input.

Requirements (proposed)

Prop Interface

interface InputPrefixSuffixProps = {
 type: ‘prefix’ | ‘suffix’
 className?: string
 children: React.ReactNode
} & JSX.IntrinsicElements['div']

Example Implementation (proposed)

return (
  <FormGroup>
    <label class="usa-label" for="example-input-prefix">Credit card number</label>
    <InputPrefixSuffix type="prefix">
      <Icon name="credit_card"/>
    </InputPrefixSuffix>
  </FormGroup>

  <FormGroup error={true}>
    <label class="usa-label" for="example-input-prefix-error">Credit card number (Error)</label>
    <InputPrefixSuffix type="prefix">
      <Icon name="credit_card"/>
    </InputPrefixSuffix>
  </FormGroup>

   <FormGroup>
     <label class="usa-label" for="example-input-suffix">Weight, in pounds</label>
    <InputPrefixSuffix type="suffix">
      lbs.
    </InputPrefixSuffix> 
  </FormGroup>
)

More Details

  • <div>root element

Other Considerations

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
jenbutongitcommented, Oct 5, 2021

👋 Hey there, I’m an engineer currently consulting in uk gov, are you still looking for contributors for this? Happy to look into it 🤓

@SirenaBorracha - I think for your proposed prop interface you meant to use type instead of interface. Using interface with & JSX.xx will give you this namespace error TS2708: Cannot use namespace ‘JSX’ as a value.

I’d also suggest two components here, but happy to concede (since we don’t have this component ourselves so I’m not sure how your developers would rather use this component), I’d have one component for InputPrefix and one for InputSuffix, and remove the need for type: ‘prefix’ | ‘suffix’

Is InputPrefix|Suffix only applicable to textInputs? Could I suggest an API similar to this? https://github.com/NHSDigital/nhsuk-react-components/tree/main/src/components/error-summary

so in this case the implementation would be

 <FormGroup>
    <label class="usa-label" for="example-input-prefix">Credit card number</label>
    <TextInput.Prefix>
      <Icon name="credit_card"/>
    </TextInput.Prefix>
    <TextInput/>
  </FormGroup>
1reaction
jenbutongitcommented, Oct 12, 2021

@brandonlenz circleCI says no 🚫 - I also don’t have write access so it wont let me push any commits up either

Read more comments on GitHub >

github_iconTop Results From Across the Web

Input prefix or suffix | U.S. Web Design System (USWDS)
Use input prefixes and suffixes to show symbols or abbreviations that help users enter the right type of information in a form's text...
Read more >
o-forms README - Origami Registry
Checkboxes & Radios; Prefix, Suffix; Toggles; Wrappers and Messages; Other changes ... More text input examples are available on the Origami Registry.
Read more >
Basics - styled-components
Styled components uses stylis.js package under the hood for prefixing the css rules. For additional information about the supported prefixes in stylis.js visit ......
Read more >
Angular PrimeNG Form InputNumber Prefix and Suffix ...
In this article, we will learn how to use the Form InputNumber Prefix and Suffix Component in Angular PrimeNG. We will also learn...
Read more >
spaCy 101: Everything you need to know
Whether you're new to spaCy, or just want to brush up on some NLP basics and implementation details – this ... Can a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found