📅  最后修改于: 2023-12-03 15:19:44.470000             🧑  作者: Mango
React is a popular library for building user interfaces. It uses the concept of components to create reusable UI elements. Sass is a preprocessor for CSS that adds features like variables, mixins, and nesting. Javascript is a programming language that is widely used for front-end and back-end development.
import React from 'react';
import './styles.scss';
const App = () => {
return (
<div className="wrapper">
<h1>Hello, World!</h1>
<button className="button">Click me!</button>
</div>
);
};
export default App;
$primary-color: #007bff;
.wrapper {
display: flex;
flex-direction: column;
align-items: center;
}
h1 {
color: $primary-color;
}
.button {
background-color: $primary-color;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
&:hover {
background-color: lighten($primary-color, 10%);
}
}
In this example, we have a simple React component that uses Sass for styling. The wrapper
class defines a flex container for the h1
and button
elements. The $primary-color
variable is used for the text color and button background color. The button
class uses a Sass mixin to apply padding and border-radius. The &:hover
selector changes the background color of the button on hover.
React Sass with Javascript is a powerful combination for building modern and dynamic user interfaces. Using Sass with React allows for better organization and reusability of styles, while Javascript provides a rich ecosystem of tools for debugging and profiling.