Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FormGroup] add contentClassName and style props #3120

Merged
merged 2 commits into from
Nov 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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