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

ToggleControl allows setting custom classes #13804

Merged
merged 4 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions packages/components/src/toggle-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ A function that receives the checked state (boolean) as input.
- Type: `function`
- Required: Yes

### className

The class that will be added with `components-base-control` and `components-toggle-control` to the classes of the wrapper div. If no className is passed only `components-base-control` and `components-toggle-control` are used.

Type: String
Required: No

5 changes: 3 additions & 2 deletions packages/components/src/toggle-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import { isFunction } from 'lodash';
import classnames from 'classnames';

/**
* WordPress dependencies
Expand Down Expand Up @@ -29,7 +30,7 @@ class ToggleControl extends Component {
}

render() {
const { label, checked, help, instanceId } = this.props;
const { label, checked, help, instanceId, className } = this.props;
const id = `inspector-toggle-control-${ instanceId }`;

let describedBy, helpLabel;
Expand All @@ -42,7 +43,7 @@ class ToggleControl extends Component {
<BaseControl
id={ id }
help={ helpLabel }
className="components-toggle-control"
className={ classnames( 'components-toggle-control', className ) }
>
<FormToggle
id={ id }
Expand Down