Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solid-aria/textfield

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-aria/textfield

Primitives for building accessible text field component.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Solid Aria - TextField

@solid-aria/textfield

pnpm turborepo size version stage

TextFields are text inputs that allow users to input custom text entries with a keyboard.

Installation

npm install @solid-aria/textfield
# or
yarn add @solid-aria/textfield
# or
pnpm add @solid-aria/textfield

createTextField

Features

Text fields can be built with <input> or <textarea> and <label> elements, but you must manually ensure that they are semantically connected via ids for accessibility. createTextField helps automate this, and handle other accessibility features while allowing for custom styling.

  • Built with a native <input> or <textarea> element
  • Visual and ARIA labeling support
  • Change, clipboard, composition, selection, and input event support
  • Required and invalid states exposed to assistive technology via ARIA
  • Support for description and error message help text linked to the input via ARIA

How to use it

import { AriaTextFieldProps, createTextField } from "@solid-aria/textfield";

function TextField(props: AriaTextFieldProps<"input">) {
  let ref: HTMLInputElement | undefined;

  const { labelProps, inputProps, descriptionProps, errorMessageProps } = createTextField(
    props,
    () => ref
  );

  return (
    <div style={{ display: "flex", "flex-direction": "column", width: "200px" }}>
      <label {...labelProps}>{props.label}</label>
      <input {...inputProps} ref={ref} />
      <Show when={props.description}>
        <div {...descriptionProps} style={{ "font-size": "12px" }}>
          {props.description}
        </div>
      </Show>
      <Show when={props.errorMessage}>
        <div {...errorMessageProps} style={{ color: "red", "font-size": "12px" }}>
          {props.errorMessage}
        </div>
      </Show>
    </div>
  );
}

function App() {
  return (
    <>
      <TextField label="Email" />
      <TextField
        label="Email"
        description="Enter an email for us to contact you about your order."
      />
      <TextField label="Email" errorMessage="Please enter a valid email address." />
    </>
  );
}

Internationalization

RTL

In right-to-left languages, text fields should be mirrored. Ensure that your CSS accounts for this.

Changelog

All notable changes are described in the CHANGELOG.md file.

Keywords

FAQs

Package last updated on 15 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc