3.0.15 • Published 3 months ago

@zendeskgarden/container-field v3.0.15

Weekly downloads
12,950
License
Apache-2.0
Repository
github
Last release
3 months ago

@zendeskgarden/container-field npm version

This package includes containers relating to field in the Garden Design System.

Installation

npm install @zendeskgarden/container-field

Usage

Check out storybook for live examples.

The useField hook will supply the prop getters to handle aria-labelledby along with for/id mapping and aria-describedby mapping when a hint and/or status message is applied.

useField

import { useField } from '@zendeskgarden/container-field';

const Field = () => {
  const { getLabelProps, getInputProps, getHintProps, getMessageProps } = useField();

  return (
    <>
      <label {...getLabelProps()}>Accessible Native Input</label>
      <p {...getHintProps()}>Optional Hint</p>
      <input {...getInputProps()} />
      <p {...getMessageProps()}>Optional Status Message</p>
    </>
  );
};

FieldContainer

FieldContainer is a render-prop wrapper for the useField hook.

import { FieldContainer } from '@zendeskgarden/container-field';

<FieldContainer>
  {({ getLabelProps, getInputProps, getHintProps, getMessageProps }) => (
    <>
      <label {...getLabelProps()}>Accessible Native Input</label>
      <p {...getHintProps()}>Optional Hint</p>
      <input {...getInputProps()} />
      <p {...getMessageProps()}>Optional Status Message</p>
    </>
  )}
</FieldContainer>;
3.0.14

3 months ago

3.0.15

3 months ago

3.0.13

3 months ago

3.0.9

8 months ago

3.0.12

7 months ago

3.0.10

8 months ago

3.0.11

7 months ago

3.0.8

8 months ago

3.0.7

9 months ago

3.0.6

10 months ago

3.0.5

11 months ago

3.0.4

1 year ago

3.0.3

1 year ago

3.0.1

1 year ago

2.1.2

1 year ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

3.0.0

1 year ago

1.3.10

2 years ago

1.3.9

2 years ago

1.3.8

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.4

4 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago