Skip to content

Feature request: merge className prop on the outermost container of a component #7214

@cliren

Description

@cliren

We can use className prop on any HTML element but not an a custom react component. Requesting to support this feature as it simplifies the component usage when there is a need to apply additional styles without having to wrap the component in an external DIV.

//MyComponent
render() {
   return <div className="message">Hello!</div>;
}

//expected usage
<MyComponent className="message--blue"/>

should render 
<div className="message message--blue">Hello!</div>

This affect can be achieved by a mixin but non-mounted tests cannot use this.props.className to find the components.

componentDidMount() {
if (this.props.className) {
   ReactDOM.findDOMNode(this).classList.add(this.props.className);
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions