aboutsummaryrefslogtreecommitdiffstats
path: root/packages/forms/src/label/index.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/forms/src/label/index.tsx')
-rw-r--r--packages/forms/src/label/index.tsx47
1 files changed, 47 insertions, 0 deletions
diff --git a/packages/forms/src/label/index.tsx b/packages/forms/src/label/index.tsx
new file mode 100644
index 000000000..36fcfbedf
--- /dev/null
+++ b/packages/forms/src/label/index.tsx
@@ -0,0 +1,47 @@
1import classnames from 'classnames';
2import { Classes } from 'jss';
3import React, { Component } from 'react';
4import injectSheet from 'react-jss';
5
6import { IFormField } from '../typings/generic';
7
8import styles from './styles';
9
10interface ILabel extends IFormField, React.LabelHTMLAttributes<HTMLLabelElement> {
11 classes: Classes;
12}
13
14class LabelComponent extends Component<ILabel> {
15 static defaultProps = {
16 showLabel: true,
17 };
18
19 render() {
20 const {
21 title,
22 showLabel,
23 classes,
24 className,
25 children,
26 htmlFor,
27 } = this.props;
28
29 return (
30 <label
31 className={classnames({
32 [`${className}`]: className,
33 })}
34 htmlFor={htmlFor}
35 >
36 {showLabel && (
37 <span className={classes.label}>{title}</span>
38 )}
39 <div className={classes.content}>
40 {children}
41 </div>
42 </label>
43 );
44 }
45}
46
47export const Label = injectSheet(styles)(LabelComponent);