npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@spark-web/field

v3.1.0

Published

--- title: Field isExperimentalPackage: false ---

Downloads

1,843

Readme


title: Field isExperimentalPackage: false

Using context, the field component connects the label, description, and message to the input element.

<Field label="Label">
  <TextInput />
</Field>

Example

Label

Each field must be accompanied by a label. Effective form labeling helps users understand what information to enter into an input.

Using placeholder text in lieu of a label is sometimes employed as a space-saving method. However, this is not recommended because it hides context and presents accessibility issues.

<Field label="Name">
  <TextInput />
</Field>

Label visibility

The label must always be provided for assistive technology, but you may hide it from sighted users when the intent can be inferred from context.

<Stack gap="xlarge">
  <Field label="Name" labelVisibility="hidden">
    <TextInput placeholder="hidden" />
  </Field>
  <Columns gap="small">
    <Field label="Name">
      <TextInput placeholder="visible" />
    </Field>
    <Field label="Name" labelVisibility="reserve-space">
      <TextInput placeholder="reserve-space" />
    </Field>
  </Columns>
</Stack>

Secondary label

Provide additional context, typically used to indicate that the field is optional.

<Field label="Name" secondaryLabel="(Optional)">
  <TextInput />
</Field>

Adornment

Optionally provide a utility or contextual hint, related to the field.

<Field
  label="Username"
  adornment={
    <Text>
      <TextLink href="#">Forgot username?</TextLink>
    </Text>
  }
>
  <TextInput />
</Field>

Description

Provides pertinent information that assists the user in completing a field. Description text is always visible and appears underneath the label. Use sentence-style capitalisation, and in most cases, write the text as full sentences with punctuation.

<Field
  label="Email"
  description="We take your privacy seriously. We will never give your email to a third party."
>
  <TextInput type="email" />
</Field>

Message and tone

The “message” is used to communicate the status of a field, such as an error message. This will be announced on focus and can be combined with a “tone” to illustrate intent.

<Stack gap="xlarge">
  <Field label="Label" tone="critical" message="Critical message">
    <TextInput />
  </Field>
  <Field label="Label" tone="positive" message="Positive message">
    <TextInput />
  </Field>
  <Field label="Label" tone="neutral" message="Neutral message">
    <TextInput />
  </Field>
</Stack>

Disabled

Mark the field as disabled by passing true to the disabled prop.

<Field label="Label" secondaryLabel="Secondary label" disabled>
  <TextInput value="Text in disabled field" />
</Field>

Props