JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.s3.yandex.net/react/libs/react.development.js"></script>
<script src="https://code.s3.yandex.net/react/libs/react-dom.development.js"></script>
<script src="https://code.s3.yandex.net/react/libs/babel.min.js"></script>
<div id="root"></div>
CSS
#root {
display: flex;
height: 50vh;
margin: 0 auto;
font-family: Helvetica, Arial, sans-serif;
overflow: hidden;
}
body {
padding: 0;
margin: 0;
}
.content {
display: flex;
width: 100%;
}
.aside {
background: #f00;
height: 100%;
flex: 0 0 200px;
}
.content__button {
width: 200px;
height: 64px;
background-color: #1a1b22;
font-style: normal;
font-weight: normal;
font-size: 24px;
line-height: 24px;
text-align: center;
color: #fff;
border: none;
outline: none;
margin: 26px auto auto;
cursor: pointer;
}
React
class SettingsMenu extends React.Component {
state = {
theme: "dark",
userSettings: {
notificationsEnabled: true,
sidebar: {
title: "Боковая панель",
enabled: false
}
}
};
toggleSidebar = () => {
this.setState((prevState) => ({
...prevState,
enabled: !this.state.enabled;
}));
};
render() {
const { enabled } = this.state.userSettings.sidebar;
return (
<>
{enabled && <aside className="aside" />}
<section className="content">
<button className="content__button" onClick={this.toggleSidebar}>
{enabled ? "Выключить" : "Включить"}
</button>
</section>
</>
);
}
}
ReactDOM.render(<SettingsMenu />, document.querySelector("#root"));