Skip to content

Commit 2f2d988

Browse files
Add SASS/SCSS support documentation (#1325)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Alek Petuskey <[email protected]>
1 parent 67ad5cc commit 2f2d988

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

docs/styling/custom-stylesheets.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,76 @@ app.add_page(
6363
)
6464
```
6565

66+
## SASS/SCSS Support
67+
68+
Reflex supports SASS/SCSS stylesheets alongside regular CSS. This allows you to use more advanced styling features like variables, nesting, mixins, and more.
69+
70+
### Using SASS/SCSS Files
71+
72+
To use SASS/SCSS files in your Reflex app:
73+
74+
1. Create a `.sass` or `.scss` file in your `assets` directory
75+
2. Reference the file in your `rx.App` configuration just like you would with CSS files
76+
77+
```python
78+
app = rx.App(
79+
stylesheets=[
80+
"/styles.scss", # This path is relative to assets/
81+
"/sass/main.sass", # You can organize files in subdirectories
82+
],
83+
)
84+
```
85+
86+
Reflex automatically detects the file extension and compiles these files to CSS using the `libsass` package.
87+
88+
### Example SASS/SCSS File
89+
90+
Here's an example of a SASS file (`assets/styles.scss`) that demonstrates some of the features:
91+
92+
```scss
93+
// Variables
94+
$primary-color: #3498db;
95+
$secondary-color: #2ecc71;
96+
$padding: 16px;
97+
98+
// Nesting
99+
.container {
100+
background-color: $primary-color;
101+
padding: $padding;
102+
103+
.button {
104+
background-color: $secondary-color;
105+
padding: $padding / 2;
106+
107+
&:hover {
108+
opacity: 0.8;
109+
}
110+
}
111+
}
112+
113+
// Mixins
114+
@mixin flex-center {
115+
display: flex;
116+
justify-content: center;
117+
align-items: center;
118+
}
119+
120+
.centered-box {
121+
@include flex-center;
122+
height: 100px;
123+
}
124+
```
125+
126+
### Dependency Requirement
127+
128+
The `libsass` package is required for SASS/SCSS compilation. If it's not installed, Reflex will show an error message. You can install it with:
129+
130+
```bash
131+
pip install "libsass>=0.23.0"
132+
```
133+
134+
This package is included in the default Reflex installation, so you typically don't need to install it separately.
135+
66136
## Fonts
67137

68138
You can take advantage of Reflex's support for custom stylesheets to add custom fonts to your app.

0 commit comments

Comments
 (0)