# ak-field-base

> A React presentational component that wraps fields and provides styles for focus/hover states

Latest version **8.0.1** (published 2017-01-06) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install ak-field-base
pnpm add ak-field-base
yarn add ak-field-base
bun add ak-field-base
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 8.0.1 |
| Published | 2017-01-06 |
| First published | 2016-10-19 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Atlassian Pty Ltd |
| Maintainers | atlassian-aui |
| Keywords | atlaskit, ui |

## Links

- npm: https://www.npmjs.com/package/ak-field-base
- Repository: https://bitbucket.org/atlassian/atlaskit
- Homepage: https://bitbucket.org/atlassian/atlaskit#readme
- npm.io page: https://npm.io/package/ak-field-base

## Dependencies (4)

- [ak-icon](https://npm.io/package/ak-icon.md) ^12.1.2
- [classnames](https://npm.io/package/classnames.md) ^2.2.5
- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.11.6
- [akutil-shared-styles](https://npm.io/package/akutil-shared-styles.md) ^37.0.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 8.0.1 (latest) — 2017-01-06
- 8.0.0 — 2017-01-05
- 6.4.3 — 2017-01-03
- 6.4.2 — 2017-01-03
- 6.4.1 — 2016-12-30
- 6.4.0 — 2016-12-21
- 6.3.4 — 2016-12-16
- 6.3.3 — 2016-12-16
- 6.3.2 — 2016-12-14
- 6.3.1 — 2016-12-14
- 6.3.0 — 2016-12-13
- 6.2.0 — 2016-12-13
- 6.1.1 — 2016-12-11
- 6.1.0 — 2016-12-06
- 6.0.1 — 2016-12-06
- … 18 more at https://npm.io/package/ak-field-base/versions

## README

[![AtlasKit component registry](https://img.shields.io/badge/AtlasKit-components-FF5230.svg)](http://aui-cdn.atlassian.com/atlaskit/registry/)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://Commitizen.github.io/cz-cli/)
[![semantic-release](https://img.shields.io/badge/GitHub-semantic_release-ffab00.svg)](https://github.com/semantic-release/semantic-release)
[![Report an issue](https://img.shields.io/badge/Report-an_issue-6554C0.svg)](https://ecosystem.atlassian.net/browse/AK)
[![Ask in our forum](https://img.shields.io/badge/Ask-in_our_forum-6554C0.svg)](https://answers.atlassian.com/questions/ask?title=AtlasKit%3A%20&topics=atlaskit,ak-field-base,ak-field-base@8.0.1)

# FieldBase

This component contains all the common behaviour and styles for fields

FieldBase provides an Atlassian Design Guidelines compatible implementation for:
* Labels: spacing, margins, accessibility.
* Fields: sizing, borders, colors, wrapping behaviour, hover/focus states.
* Validation: styles (built in validation coming soon!)

FieldBase's *will* work by themselves but are really meant to be extended into a full field component.

![Example Fieldbase](https://bytebucket.org/atlassian/atlaskit/raw/e39a474ffd53a72b6d10ba3d206e5d4561503626/packages/FieldBase/docs/fieldbase.png)

## Try it out

Interact with a [live demo of the FieldBase component](https://aui-cdn.atlassian.com/atlaskit/stories/FieldBase/8.0.1/).

## Installation

```sh
npm install ak-field-base
```

#### Using the component

Import the component in your React app as follows:

```
import FieldBase from 'ak-field-base';
ReactDOM.render(<FieldBase />, container);
```

The typical use-case for an `FieldBase` is to create a new component.

Usually you will want some form of input for the extended component.

```html
<FieldBase label="A slotted input">
  <input type="text" value="I am slotted in a field-base!" />
</FieldBase>
```

This way, the component will tell you when it **wants** to update its props, without actually changing them.

## Classes

<dl>
<dt><a href="#FieldBase">FieldBase</a></dt>
<dd></dd>
</dl>

<a name="FieldBase"></a>

## FieldBase
**Kind**: global class  
* Properties

    *  [FieldBase.appearance](#FieldBase.appearance) : <code>string</code>
    *  [FieldBase.isInvalid](#FieldBase.isInvalid) : <code>boolean</code>
    *  [FieldBase.isFocused](#FieldBase.isFocused) : <code>boolean</code>
    *  [FieldBase.isRequired](#FieldBase.isRequired) : <code>boolean</code>
    *  [FieldBase.isDisabled](#FieldBase.isDisabled) : <code>boolean</code>
    *  [FieldBase.isPaddingDisabled](#FieldBase.isPaddingDisabled) : <code>boolean</code>
    *  [FieldBase.isReadOnly](#FieldBase.isReadOnly) : <code>boolean</code>
    *  [FieldBase.isFitContainerWidthEnabled](#FieldBase.isFitContainerWidthEnabled) : <code>boolean</code>
    *  [FieldBase.onFocus](#FieldBase.onFocus) : <code>function</code>
    *  [FieldBase.onBlur](#FieldBase.onBlur) : <code>function</code>
    *  [FieldBase.children](#FieldBase.children) : <code>ReactNode</code>
    *  [FieldBase.label](#FieldBase.label) : <code>string</code>
    *  [FieldBase.isLabelHidden](#FieldBase.isLabelHidden) : <code>boolean</code>
    *  [FieldBase.onClick](#FieldBase.onClick) : <code>function</code>
    *  [FieldBase.isRequired](#FieldBase.isRequired) : <code>boolean</code>

<a name="new_FieldBase_new"></a>

### new FieldBase()
Create instances of the FieldBase.

**Example**
```js
<FieldBase label="Email" />
```
<a name="FieldBase.appearance"></a>

### FieldBase.appearance : <code>string</code>
The appearance of the field.

Valid values for this property are: 'standard' (default), 'compact' and 'subtle'.

Compact will make the field have less padding and subtle will remove the background/border
until a user hovers over it.

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Default**: <code>&quot;standard&quot;</code>  
**Example**
```js
<FieldBase appearance="compact" />
```
<a name="FieldBase.isInvalid"></a>

### FieldBase.isInvalid : <code>boolean</code>
Whether or not a field should show a validation error.

This is shown to the user through a warning icon and an orange border.
A future release will allow a custom error message to be displayed.

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Default**: <code>false</code>  
**Example**
```js
<FieldBase isInvalid />
```
<a name="FieldBase.isFocused"></a>

### FieldBase.isFocused : <code>boolean</code>
Whether or not a field should show its focused styles by default.

By default, this component will automatically add and remove this prop if itself
or any child of it receives focus or blur events.

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Default**: <code>false</code>  
**HTML Example**
```js
<FieldBase isFocused />
```
<a name="FieldBase.isRequired"></a>

### FieldBase.isRequired : <code>boolean</code>
Whether or not the field is required.

If set to true, an asterisk will be appended to the label text.

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Default**: <code>false</code>  
**Example**
```js
<FieldBase label="First Name" isRequired" />
```
<a name="FieldBase.isDisabled"></a>

### FieldBase.isDisabled : <code>boolean</code>
Whether or not a field is disabled.

This is shown to the user through a disabled cursor icon when hovering over the field.

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Default**: <code>false</code>  
**Example**
```js
<FieldBase isDisabled />
```
<a name="FieldBase.isPaddingDisabled"></a>

### FieldBase.isPaddingDisabled : <code>boolean</code>
Whether or not the field should have padding.

Disables the field's padding css property.

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Default**: <code>false</code>  
**Example**
```js
<FieldBase isPaddingDisabled />
```
<a name="FieldBase.isReadOnly"></a>

### FieldBase.isReadOnly : <code>boolean</code>
Whether or not the field is in read-only mode.

Disables the field's hover effect to indicate that it is not editable.

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Default**: <code>false</code>  
**Example**
```js
<FieldBase isReadOnly />
```
<a name="FieldBase.isFitContainerWidthEnabled"></a>

### FieldBase.isFitContainerWidthEnabled : <code>boolean</code>
Whether or not the field should fill the width of its container.

If enabled, the field will fit the width of its container even
when the field content is not that wide.

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Default**: <code>false</code>  
**Example**
```js
<FieldBase isFitContainerWidthEnabled />
```
<a name="FieldBase.onFocus"></a>

### FieldBase.onFocus : <code>function</code>
Callback that is called whenever the Content is focused

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Default**: <code>() =&gt; void</code>  
**Example**
```js
<FieldBase onFocus={() => alert('content focused!')} />
```
<a name="FieldBase.onBlur"></a>

### FieldBase.onBlur : <code>function</code>
Callback that is called whenever the Content is blured

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Default**: <code>() =&gt; void</code>  
**Example**
```js
<FieldBase onBlur={() => alert('content blured!')} />
```
<a name="FieldBase.children"></a>

### FieldBase.children : <code>ReactNode</code>
The content that will be displayed within the field

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Example**
```js
<FieldBase><div>Hi!</div></FieldBase>
```
<a name="FieldBase.label"></a>

### FieldBase.label : <code>string</code>
The label to be rendered above the form field.

This prop is still required, even if the hideLabel prop is set as the label is also used to
make the field accessible for screen readers.

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Example**
```js
<FieldBase label="Email" />
```
<a name="FieldBase.isLabelHidden"></a>

### FieldBase.isLabelHidden : <code>boolean</code>
Whether the field should show a label above it.

If set to true no label will be shown and no space will be reserved for it.

**Note**: You must still provide a label for the component regardless of this prop.
The label is also used to make the field accessible to screen readers.

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Default**: <code>false</code>  
**Example**
```js
<FieldBase label="First Name" isLabelHidden />
```
<a name="FieldBase.onClick"></a>

### FieldBase.onClick : <code>function</code>
Callback that is called whenever the Label is clicked

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Default**: <code>() =&gt; void</code>  
**Example**
```js
<FieldBase onClick={() => alert('label click!')} />
```
<a name="FieldBase.isRequired"></a>

### FieldBase.isRequired : <code>boolean</code>
Whether or not the field is required.

If set to true, an asterisk will be appended to the label text.

**Kind**: static property of <code>[FieldBase](#FieldBase)</code>  
**Default**: <code>false</code>  
**Example**
```js
<FieldBase label="First Name" isRequired" />
```
<a name="default"></a>

## default : <code>enum</code>
FieldBase appearances values.

**Kind**: global enum  
**Properties**

| Name | Type | Default |
| --- | --- | --- |
| standard | <code>string</code> | <code>&quot;standard&quot;</code> | 
| compact | <code>string</code> | <code>&quot;compact&quot;</code> | 
| none | <code>string</code> | <code>&quot;none&quot;</code> | 
| subtle | <code>string</code> | <code>&quot;subtle&quot;</code> | 

## Support and feedback

### We're here to help!

Let us know what you think of our components and docs, your feedback is really important for us.

### Community support

Ask a question in our [forum](https://answers.atlassian.com/questions/ask?title=AtlasKit%3A%20&topics=atlaskit,ak-field-base,ak-field-base@8.0.1).

Check [if someone has already asked the same question before](https://answers.atlassian.com/questions/topics/42926171/atlaskit).


### Create a support ticket

Are you in trouble? [Let us know](https://ecosystem.atlassian.net/browse/AK)!

---
_Source: https://npm.io/package/ak-field-base · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
