Skip to content

Commit

Permalink
[FormGroup] add contentClassName and style props (#3120)
Browse files Browse the repository at this point in the history
* add contentClassName prop

* add style prop
  • Loading branch information
giladgray authored Nov 1, 2018
1 parent 4e93d2f commit 4b8aa49
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/core/src/components/forms/formGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import * as Classes from "../../common/classes";
import { DISPLAYNAME_PREFIX, IIntentProps, IProps } from "../../common/props";

export interface IFormGroupProps extends IIntentProps, IProps {
/**
* A space-delimited list of class names to pass along to the
* `Classes.FORM_CONTENT` element that contains `children`.
*/
contentClassName?: string;

/**
* Whether form group should appear as non-interactive.
* Remember that `input` elements must be disabled separately.
Expand Down Expand Up @@ -39,21 +45,24 @@ export interface IFormGroupProps extends IIntentProps, IProps {
* Optional secondary text that appears after the label.
*/
labelInfo?: React.ReactNode;

/** CSS properties to apply to the root element. */
style?: React.CSSProperties;
}

export class FormGroup extends React.PureComponent<IFormGroupProps, {}> {
public static displayName = `${DISPLAYNAME_PREFIX}.FormGroup`;

public render() {
const { children, helperText, label, labelFor, labelInfo } = this.props;
const { children, contentClassName, helperText, label, labelFor, labelInfo, style } = this.props;
return (
<div className={this.getClassName()}>
<div className={this.getClassName()} style={style}>
{label && (
<label className={Classes.LABEL} htmlFor={labelFor}>
{label} <span className={Classes.TEXT_MUTED}>{labelInfo}</span>
</label>
)}
<div className={Classes.FORM_CONTENT}>
<div className={classNames(Classes.FORM_CONTENT, contentClassName)}>
{children}
{helperText && <div className={Classes.FORM_HELPER_TEXT}>{helperText}</div>}
</div>
Expand Down

1 comment on commit 4b8aa49

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[FormGroup] add contentClassName and style props (#3120)

Previews: documentation | landing | table

Please sign in to comment.