You will need a .active class, and a state for toggling active status:
In your App.js
function App() {
const [active, setActive] = useState(false);
const change = () => {
setActive(!active);
};
return (
<>
<div id="container" className={`${active && 'active'}`}>
<div id="inside" className={`${active && 'active'}`}>
<button id="button" onClick={change}></button> //this is a button
which wrapped in a div element.
</div>
</div>
</>
);
}
In your app.css
#inside {
width: 156px;
display: flex;
height: 49px;
/* it should changed to 7px solid black when button clicked. */
border: 7px solid yellowgreen;
border-radius: 50px;
align-items: center;
/* i want to change this to flex-end when button clicked. */
justify-content: flex-start;
}
#container {
display: flex;
height: 100vh;
border: 1px solid black;
justify-content: center;
align-items: center;
/* //when button clicked it should be changed to yellow color. */
background-color: black;
}
#button {
display: flex;
border-style: solid;
border-radius: 30px;
height: 45px;
width: 56px;
}
#container.active {
background-color: yellow;
}
#container.active #inside {
justify-content: flex-end;
border-color: black;
}
Hope this help.
styleprops to the components that change the style directly based on the state.